zkSessions: Izaak Meckler on SnarkyJS
21 May 2021 · 10:46
Izaak Meckler of O1 Labs presents SnarkyJS at zkSessions: The ZK Languages Rundown, an event produced by the Zero Knowledge podcast, which has covered zero-knowledge proofs and cryptography research in decentralized systems since 2018. The talk introduces SnarkyJS as part of a broader survey of programming languages for building zero-knowledge applications, situating it alongside other approaches to ZK circuit development discussed at the event.
Speakers
Topics
Transcript
take it away cool there's some like uh cool so i'm gonna be i'm isaac um i work at owen labs on mina protocol i'm gonna be talking about snarky js so a little bit of backstory snarky is an o'camel embedded dsl um which used in production um in mina um snarky.js is an in development uh javascript and typescript framework which is based on snarky and just to start kind of who is snarky.js for um if you're a developer who wants to write either like a privacy preserving application where the end user will prove some statement to you know protect the privacy of some of their data or kind of uh roll up for scale where maybe
some kind of third-party roll-up operator proves then this you know is a good tool for you and um and also there's very tight integration with snaps which are kind of our smart private smart contracts on mina um so you know it's kind of the the best choice for that as well um so some of the design principles uh you know back to the history um snarky uses oh camel and we we uh you know there's one problem with ocamo which well i think okay well it's great running on camel but uh most people don't know a camel so um that's kind of a really big barrier to entry and so principle number one is like don't make the user learn a new programming
language um just to keep the barrier to entry as well as possible um then number two like a related principle is like don't make the user learn new tools um and three somehow provide a first class developer experience with like really good ide support a web prover for you know user facing apps like dark force or like other privacy preserver want to write um package management oh yeah i'm packing frenchmen okay and so i'm going to talk about some of the features like in our roadmap um and then i'm going to give a brief demo i'm going really fast i guess that's fine i don't know we'll have a lot of time for questions so that'll be cool um so uh right so
future is already implemented in class it's not i you know hey maybe yeah it's very similar it's kind of a question i i don't know about head-to-head comparison maybe we can talk about it um that has general purpose tooling so there's no setup for arsenal this is like our pickles plunk snark um very fast recursion so much faster than um you would see in a system like um like the zinc system or azix system um because we have sort of the cycle of curves thing going on um and like a library of cryptographic primitives hash functions signatures
integers all that good stuff um also very good tooling why because it's just typescript slash javascript so um uh we're we plan to have soon it was improver um ide support that kind of just works right out of the box packaging via npm obviously or whatever javascript packaging solution you like um and then of course seamless integration with javascript and typescript application i have a web app that has that uses snarks like this is a super easy way to go um and also integration with the mina snaps sdk for super easy development on top of meter so um that's kind of it for the talk part and then i'm going
to do a little demo just of what it looks like because i didn't show you anything about what it looks like um but here's some links and i'll put a link to the slideshow in the chat so you can get all these links but if you're interested in like you know providing feedback or job please like go to this interest form if you want to check out the github there it is and then if you want to join the meena discord where you can come talk about um whatever there it is so let me um now let's see put the slideshow in the chat cool so that's there um and now let me show you what it looks like so
this is um an application basically a smart contract um a snap for mina which does a kind of private two out of n multisig so what do i mean by that um it will be an account which has you know a balance and which uh for which the authorization is like multisig um there's like some set of keys that you know have to sign and if you have signatures from any two event of them or any two of them then you can send a transaction and we want it to work such that it's private so like it doesn't reveal who the signers were who which two um so uh it's super easy to do um i'll just kind of go uh like top down or whatever um first of all you
know to define a smart contract you just sort of define a class that sends this snap base class um and then the send function let's check that out so you have to provide some data associated to the send and that'll basically have what are the oops what are the signatures that you actually have the amount the fee the nonce in the account and the receiver okay pretty straightforward um and uh yeah basically you know all you have to do is kind of iterate all over all the signatures and uh and basically verify them okay so um uh let's you know just kind of this is a smart contract but like just for kind of one-to-one uh circuit kind of stuff let's look at
what signature verification looks like um so you can see like the id support is awesome right so it's like signature.verify takes the signature as the this takes a public key um a message and returns um so here's a signature um basically a schnorr signature which is kind of based on this scheme here okay from bip something 340. um the verification algorithm is really easy to write um so uh you basically take the mask it's really just a if you just i encourage you to like go and look at this afterwards and just like look at how it compares to this because it's
it's really uh really simple um and really kind of one to one so it's basically hash the message on and pack it into bits and then do you know uh group generator times s which is part of the signature plus uh like negative the public key times this hash value e okay so really couldn't get more straightforward than that and then you just check whether um the x coordinate of this r of this group group is equal to the r and the signature and also whether the y coordinate is even okay super simple and let me just kind of like show off the ide support so there's full like auto complete and stuff so oops it's like it's like we have the signature we can
be like this dot r okay it's a field element and then i can do you know see all the methods that are available on field elements check if it's zero oops uh check if it's zero you know invert it uh whatever you like you know add ads add etc etc and the id support is really great like there's doc comments and stuff like okay so like i can hover over oh yeah i have a group like what group is it okay there's a doc comment here it's the palace curve from uh ecc team you can check it out um go to the link you know um the field you might be wondering oh what's with that field it says it's an element of the pasta fp field so uh you know nice documentation functionality there um so
uh that's just kind of a taste but uh that explains things i don't know if there's it looks like there's no questions so i don't know are there any questions did you did you have earlier we had been talking about one of your colleagues joining does that person want to oh yeah yeah matt do you want to join i mean it seems like there's no question so i don't know matt was going to join to help with questions so okay patrick asked do you have any prover time benchmarks um this is before some ongoing options so this is kind of like with um
the yeah um so with the current setup um i think something like 200 000 like on my laptop probably like something like 250 000 you know whatever that power of q is to 260 something 1000 constraints is like on my laptop that's probably like 10 seconds something like that um i have kind of a beefy laptop but you know um wasm tbd um and yeah i can also i can remember offhand that like there's some overhead so like i remember like like a 2000 constraint proof is something like
uh like it's less than it's like 500 milliseconds or 200 milliseconds or something like that um so id you support yeah it's it's totally free like we don't have to do anything because it's like like okay so matthew is like one of the best programmers i've ever known and you know we spent some time like trying to you know like we a few years ago we like made a dsl it was like it was really cool actually and um uh but then it's like okay now you have a dsl like there's no editor support there's no nothing type script is kind of wonky but like there's literally thousands of hours whole people's lives whole people's lives invested in you know making the tooling and
everything really awesome so yeah we just picked piggyback on that okay i wanna i wanna ask the question actually so the full question was was was it easy to achieve by piggybacking on the jsts machinery or do you have anything special to snarky.js so the only special things are these like uh decorators basically which um you know are necessary to let the circuit know what's going on i don't know how else to say um but it's as you can see it's pretty natural right you just kind of like whatever property you have on your objects you just like say prop and then it makes it kind of uh possible to use okay what's a circuit value it's a value that can be used as a witness in a circuit okay