Session 5 - ZK App architecture & Intro to Circom
ZK & Privacy Bootcamp · 1:29:28
Milica introduces Circom signals, constraints, templates, and rank-one constraint systems through hands-on exercises in zkREPL. Participants build a three-input multiplier and a number-guessing circuit using circomlib comparators and Poseidon commitments, then discuss proof generation and choosing a ZK language.
Speakers
Topics
From ZK & Privacy Bootcamp, published by dev3pack; community: dev3pack.
Transcript
Okay perfect. Okay, Ma, you can start whenever you want. Okay cool. Uh, let me let me share my screen. >> Guys, do we have the screen shared? Yep. Do we see it? Because sometimes when I when I share it, I don't see what's shared.
>> I I uh I need to employ another monitor for that. >> Yeah. >> Able to see. >> Okay. Super cool. Hello everyone. ZKGM or KZGM for the KZGs that we had um last time. Uh my name is Milita for everyone new who's joining. I'm developer relations engineer at ZK verify what do we do we are verifying proofs zero knowledge proofs and I'm also doing my PhD in ZK.
Um so I'm glad that I see so many people here uh you know interested in ZK throughout this like what is this like third week for us that we're having this and like what did we have like four classes two last week and two in the first week and I'm so glad that I see so many survivors right people who did not you know just give up on on it and Um, and I think where today we're coming to the worthy part like let's see some practice like come on like all the maths and stuff. Um but the thing is like it's important to know all of that before you
start writing um ZK circuits because then we're going to have hashes or rank one constraint systems or um GR 16 and and u and plunk you know that uh that can be an output of this workshop that you know you should know what's behind it and why do we have it and why did we have the KZG and like how everything looked like. Uh first of all, who tried KZG at home? I'm very curious. Wow, we some have some hands up.
Nice. Was it difficult? Yeah, I needed to check for something and go back to our video, but after that, yeah, I I figure out. >> Okay. Okay. I mean, it's um it's a playful thing to do, so why not? Today, we're going to have code. Yes. Yes. Yes. All right. Um thing with circum is it's not as any um any language that you might tried before. So, you know, maybe I will ask you guys, have you tried programming before? Does anyone in the group have
tried programming before? You have your own GitHubs etc. Okay. Um so what did uh uh what did people tried programming in? So what languages did you try? Can you tell us? >> I have done Python programming the basics TCP and Python. >> Mhm. >> For me Solidity and TypeScript. >> Perfect. I started with >> for me. >> Yeah. Go. >> Um, for me, TypeScript also, Solidity, Go and Python.
>> Bravo. I started >> myself as well, Rust and TypeScript. >> Super cool. I started with C family. Then I learned JavaScript, TypeScript, a bit sold and yeah. >> Oh my god, I have someone who started with C programming language. >> Yeah, >> like I did years ago. >> Yeah, my school is so strict about it. We need to learn C. I actually can code assembly, too. So, it's just terrible.
>> Yeah. Um, my teacher in high school, we started with Pascal. >> Oh, really? Yeah. Yeah, it was fun. But you know it just the basics. So I see that predominantly we see um high level languages such as Python or TypeScript um Rust etc. So it's it's it's important you tried something before you see circum because circum is a bit um it's a bit strange when you're coming from um the regular let's call them the regular um languages for programming that we use because it's it's not really a programming language per se and we'll see why.
Okay. So what is circum right it's not a programming language but what is it then it's a hardware description language okay it might sound a bit confusing but um it's it looks like a bit like electronics on a board if someone have ever seen like all these wires you know when usually something. It's like a green board with a bunch of wires and and and a lot of uh uh details and components. You know, that's how I sometimes see circum
um I started my career in electronics. So, it was very, you know, for me it was more intuitive than maybe for for people who just had a programming uh on their unis or they started with software development. But for me, I started with wires like with with and also with um the digital electronics where you have zeros and ones. So that's um maybe the analogy that we can have here. Um yeah, circum works with wires and gates.
And so similarly to what you have on um on one electronic board is that you have wires that like they're they're kind of like a signals like the the electricity or or the voltage as we call it, right? Um it depends like you can have the the currency the the current and you can have um also the the voltage that can come and like trigger something in um in the specific circuit. Um and you know since um circum is describing zero knowledge circuits um we will have this wires that are kind of inputs signals and gates. It's similar to not that
something is happening at that point in that let's say electronic circuit that uh that you know either you will have um let's say the amplification of signal or you will have a a gate that would open something that would signal that something is opening um after it some some other circuit. So yeah, let's um let's see how it looks like. I I uh I promise it's less complicated than electronics and and all the amplification circuits that we had. I promise it's it's uh it's less complicated and um instead of
having uh the voltage and the ampers will have um zeros and ones which is more predominant in digital electronics. So yeah um to have um uh right to work with circuits we need to have certain set of rules. So for us we need to have a rule that we're working with within rank one constraint system that we're going to see later and finite fields. We had talked about finite fields. Uh but we didn't talk before about rank one constraint systems and we'll see uh what that is and why does circum work only
with rank one constraint systems. Basically um what you can uh think of um as an R1 CS I've written some analogy that it could be like it's um a set of IKEA instructions. I I suppose that most of the people have seen the the IKEA and like assembled something from it. So uh circum is you describing let's say a wardrobe. Um let's say like I want uh um mirror wardrobe uh with um some glass shells and you know uh there is everything that you want to describe
with some hangers etc. But the R1CS or risk one uh rank one constraint system is the exact stepbystep instruction um booklet or whatever like instruction manual that we got that would say like um attach this nail to this to this shelf and to and then you will get like laid out shelf. So, so like a + one uh a + b equals to c. It gives it gives out some some output.
as well as um let's say the snark that you have had I if I'm not mistake last week on on Wednesday snark systems that would be like the factory that can actually verify um right quickly through the booklet or through the instructions set be without even building a wardrobe. Um so it's some kind of um cartoonified explanation of how can you think about R1 CS but yeah we're going to see examples as well just not to petrify you in the beginning.
Ah yeah to speak a language this this time uh uh it's not a natural it's it's kind of a programming harder description language we need to know the words we need to know about signals um those are our variables in in programming um uh in software engineering you would see them as variables so you're working with some values right or some intermediary values or input or output values. So for a circum we would have input output and we can have intermediary signals as well and um they're usually not specified.
They do not have intermediary to next to their name while to be something to be considered input or output. They need to have uh those uh uh words described next to them. Also, we're going to have um operators, right? So, we have like it's like I see like signals as the words while you know operators as the verbs because it tells you like okay uh do the assignment between values where make a constraint. So these are the the two verbs as I saw uh that
uh we will use later. So these are the the assignments uh these are the all the operators that we have and you will see like how do they look like um there is value assignment and value assignment plus a constraint generation. uh they make difference between um how does this arrow look like? One will have like one dash uh like like one one dash in a level one the other one will have two equal signs.
Um so it's the difference in what can we think of as in um programming languages that you guys already had is that value assignment would be seen as um copying the value while uh value assignment plus a constraint generation would be referencing. Hatton, you must know this from C language, right? The the referencing and and the the coping difference. But there is uh also in in other uh languages the same thing. Um but that is like the crucial difference
is that when you enforce a constraint uh you are making sure that if something changes in the circuit you will see the output of it and it will actually be bonded. It will be tight and uh if someone is trying to to change something um you know maybe the evaluation will not be there anymore. Um so that's for you to ensure that everything is played by the rule of the circuit that you wrote.
Uh then we'll have um there is a constant expression the the linear and quadratic uh meaning that you will you can have uh multiple uh values as well. So yeah, constraint and the two operators. Yeah. Um I don't know have um have you ever seen like I think we all did in physics right in elementary school the first Khov's law. So what does that guy say? It says it says that um he says that the sum of all the currents leaving a node in any electrical circuit is
always equal to zero because circum is a hardware describing language. we will have the same rules and you can always write um you can always write constraints uh based on that because everything that comes to to one node um minus everything that leaves will be equal to zero and uh let's say you want to multiply two values and you will have the output. If you multiply two values minus the output you want to sub subtract the output that you had you will end up with zero and that's um that's that's a law that persists in
circum too. So how do we also like uh when we talk about circum um we can say that with normal programming we'll have um okay like um take two numbers add them and return the result but with circum we will have I want to enforce that output one out I mean the output in general let's say it's outputs called only that is input one plus input two and any assignment that does not satisfy this will be uh uh incorrect. It will be invalid. Okay.
Okay. So uh yeah like this is one of the the circuits not a circum circuit but uh actually you can see that you know this is how it presist like the the kirk house law and what we're going to see in in circum is that you know value of every of these knots or or nodes electrical or electronical nodes it needs to be zero. Um, and so we're going to have um less complicated now than these ones, but yeah, this is um this is maybe how it was based on when someone was designing circum I'm I'm sure of it.
Yeah. So zero some game persist here too. Um so not or not um they look like this. Um so let's say that our um input is x1 and our other input is x2 and we will have a constant as well. Um this is how we are building a circuit. So like you can do it with other polomials. Now we know what polomials are right and how to work with them. But also what's needed is also a flattening of the polomial before we go because we're working with
a uh air1 constraint system. Uh we need to do the flattening of the polomial. So let's say we cannot do x1 to the power three our input signal power to the power of three just like that and make a constraint because it wouldn't work in circum and we'll see why. Uh but basically you need to simplify it to um let's say like inputs of um to say so for level one even with constants if you're adding constants before uh a certain input you need to add them in this manner as well. So how do we do it?
So it says like x1 we see a plus sign. So x1 is a input signal. X2 is an input signal. So in first iteration you would say like okay so our um intermediate signal that we have um after this um first plus it will be x1 + x2 right. Uh the other one would be x2 + 1 right and then we can multiply two signals that we got as intermediary.
Okay. So questions so far. So is this called as a merkel tree or this is how a merkel tree is made or this is something else? Um you can think of it as um as a sort of an arithmetic tree uh because Yeah. Yeah. Yeah. because um I want to simplify it as much as we can. So it's um I took some examples that uh could be you know uh familiar with everyone so far with uh you know just just uh the notes and stuff but yeah.
Yeah. It's not um immediately related to Merkel trees. Other questions? No. Yeah. Okay. That means that it's understandable. Okay. Uh yeah, let's um let's try out something. Uh let's try out the flattening of the polomial.
Um so if everyone has notebooks and and pens and paper, right? I mean let's let's try it out like like we we had here with zero sum game. Uh we can have it we can have it here like three uh 3x to the^ 2 + 2x + 5. So we want to ensure that we can prepare something um that can um satisfy let's say the branches and the nodes as we have in in the before example and and I would like you to show us how
does your tree look like. I'm reading the comments.
Someone asked, we don't have to worry about the constant here, right? We can add it. We can add it. Yes. Always two inputs for an operator. My tree looks ugly. It was not really pretty as in the pre previous example. >> Show us Show us how to >> It is not so >> Well, it's it's it's pretty, >> but yours were like a really triangle one.
>> Ah, well, it's it's called a balanced tree. Yeah, mine is not really balanced. It's like >> Mine is worse. [Music] >> Only the idea and readable >> kind of similar I think. Yeah, like this. >> It reminds me of um searching the tree and then like you have balance tree and uh >> oh algorithm classes. It was like a I loved it. I loved it. I I really hate algorithm classes because it was so hard and you know like like it's my you know right now I'm experiencing the trauma
again right now. I have posted last week's um photo with one of my colleagues from Milan. We uh we visited Poly Techchnico de Milano and people commented th this this building gives me chills. >> Yeah, probably if you share my university too, it would be so traumatizing to me too. >> I agree. Especially when they ask like something like that but implemented in C language. Nice.
Uh we are writing assembly on paper so nothing be >> I I I had exams on paper. Yeah. Yeah. Yeah. I remember those days when they would just like take a picture and do the optical character recognition and if you forgot some bracket somewhere like you just failed. They don't even look at it. >> Exactly the same. I always says that it's come from you know Soviet Union idea in Turkey. So >> yeah, when they especially when they give you the the math books and then you have to learn another language like fine, make it make it like double hard.
Yeah. So someone else wants to show their tree. Okay. Yeah. Uh hot in the tree that you shown is um is actually correct tree because it cannot be uh balanced. Let's see. Oh, someone shared a paper. Nice.
Okay. Uh let's see. Okay. So most of you guys have figured out how to do flattening and uh that um you know you cannot just like give it the the polomial but you have to do operations bit by bit. Um good that we do not have uh bitwise operations here. It would it would uh last. Okay. So this is this is you know how it would look like um in in in circum this with what we had um here is like uh what what circum needs to go through to come
to that point. Um this is uh how it uh can work out. So we need to have the intermediary signal and then we can work out with the output. Okay. Uh let me see like is someone excited for the programming part. We can actually go now to zkrapple.dev because thanks to Xerox spark team we do have zkrapple.
So we don't know how to install the entire rust tool chain and compile everything. Uh so just to just to write some zero knowledge programs um in in circum so um yeah um uh one of the other things that I want to um emphasize here that with um zero knowledge proof you're not writing just like a code to be executed like Python you're writing constraints that must hold true like equations between variables. So it's like math but
programming math. Okay. Uh all right. Um shall we go to ckrepple.dev? Let me see if I have it. Yeah, let's try it out. Um, so what I can do is um I can write some examples with you guys. I'm not sure if everyone has their own computer right now, but I want all of you to be able to write it out. Let me check.
Uh, I can share output from the remarkable this time. Oh, I could have last time. Oopsie. Let me share the remarkable output then. Let me check.
Perfect. Okay, back to Zoom. Okay, stop sharing this one. Share another one. Okay, everyone sees my remarkable input. Super cool. People see it. Very nice. Just give it a bit more border lines.
Okay, you should be able to see the remarkable input. Right now uh I have prepared some um some easier examples than you can do with uh we can do with some you know go with some examples like uh with commitments as well. Uh so let me check let me check what can we have we have here. So first of all we should open zkrapple.deaf.
So it's looks like this. Okay. Is everyone able to to see it? Okay, the majority says yes. Let me check chat.
Why don't we have to do the intermediate? Why can't we use uh x time x directly? Is um it's because of the rank one constraint system. So um Oh, thank you Rosio. Thank you. very kind of you to to uh add the link to the chat. Um so why don't we use um just x * x directly uh because for writing the arithmetic circuits that um later get compiled into rank one constraint systems um we'll we'll need to use uh um uh we need to use uh for for proving
systems R1 R1 CS uh to generate zero knowledge proofs and um rank one constraint systems they uh they work with only um you can you can think of it like like that tree that we had that we can work only with two inputs at a time. So even if it's like uh let's say like um we can work with um you can work with polomials of higher order as well. Uh but uh you need to flatten out the polomial. Um it's in a way you can think of it um as not having an interface to work with higher order polomials.
Let's say you know it's doesn't understand anything uh more than uh than uh than our flattened out polomial. Okay. Okay. So this is the link that we want to open. I want you guys to try it out yourself. uh and um you know try sharing your screens to see what you got from your result. Um that's why I want to use pen and paper on my side so that you
want to try it out yourself and see how it goes, right? Uh so we're not uh putting everything on a silver plate, but today is a bronze plate and you have to work it out yourself a bit. So uh let's try out um an example of u multiplying three inputs. Let's try that one out. So once you open uh um zkir.dev, you would have like you need to delete the example that we have there. Uh but um it's usually inputs five and 77 I think. Um so we want to
have our own example. So let's say it's uh you need to write like pragma circum is it 2.12 six I think and then uh we're going to h we're going to call it the template template multi3 Okay.
Uh, we're going to have our input signals. This is usually what we have for comments this sign. So, we're going to have it just for explanations. Signal input N1. Signal N2 signal input N3.
One output signal signal signal output out so far everyone following. Okay? Let's use helper signal. signal let's call it okay out out one
and we're making assignment and constraint n1 times n2 and then out signal the real output signal will be output one times in three. It's the end of our template. This is the multilinear comment uh seen in in many uh languages.
says input is in one. Let's say it's um three. So it's the the JSON format that we have here. Input two is four. Okay. just like a normal column.
Input three is five and it's the end of input star. So should we write this in the ZA report? >> Yes. Yes. Yes. Yes. So we have seen that here we have
templates and uh we're going to have components for example and um you can think of them sort of something we had like a class in object-oriented programming that might help you but Yeah, I want I would like to see guys your outputs with us have a question in the
so I'll put this out and then in helper signal we put signal out one. >> Mhm. >> What is the one or is that like is there a space or it's just out one? >> Um it's just like out one. We can call it helper or whatever. It's intermediary. >> Okay. Um it's not considered an output um no but um yeah it helps us and rename it to something. What would you like us to rename it to?
>> Okay. Mhm.
Okay. Someone shared checka shared um the outputs. Perfect. check. Now, how do we run the the code?
Uh, >> command plus enter. That's how we run it. Oh, we have uh dropped something out. That's why uh you see the input output like that. Uh let me uh put it in. Yeah, I don't know how I skipped it but uh it's uh we need to have the the main component as well. So after
I don't know if you see it after here right we should have after this uh cur bracket we should have component main is multi three try it out now how to Please. Mhm.
Ariel, you need to have um input uh signals. You need to have values so that you can calculate it. Mhm. U M asks why do we have um the the arrow um constraint instead of
just um two um equal um two equal signs. So why don't we have that uh when we have the assignment because we need to if we just had um comparison we would just like check in in that point like if the two values are equal but here we're using the assignments so uh where they had it with the the outputs um and this immediately signal we're connecting them um that's why we have it yeah better. Um, okay. Hatton, did you try adding the
this one line that we dropped? Does it work? >> Everything works, right? >> Okay. You got the same output other people got. Perfect. Well, congrats guys. You have written your first zero knowledge circuit. Super cool. Um, I'm so proud of you guys. Uh, we have come to this point where after all the mads and all the you know hashes and games that we had like now you're actually um entering the the field of writing circuits and
understanding them. So what did we show here is the multiplication of um of three inputs. So let's say that we had this uh um this three inputs. We cannot just make the constraint just like that. But we needed to have actually some intermediary signal, some helper signal that we can we can call it like um I don't know who wants to give a name to the helper signal. Maybe we can change it. Ah, no one anyone.
>> Okay. >> In the comments people said and >> which one >> in the comments uh I could say T. We can use T or said M. Um O. I don't know how to read this one. Uh X. So, I don't know. >> Ox. Sorry. >> Oh, >> I don't know. What's that mean? I'm sorry. >> Yeah. Yeah. Yeah. Yeah. It's It's a helper. Yeah. Let's call it That's called temp. It's It's It's a good one.
Okay. >> Um Yeah. Maybe I Why Why can't we put directly in one times in two instead of temp? Like I didn't get it. >> Uhhuh. because of the rank one constraint system. So rank one constraint system says that you can work um um up to um quadratic but you cannot work with um let's say x to the^ 3 or um x the^ 4 or anything above um the the the quadratic. That's why what's the difference between the helper
signal and war? So the initials example has war. We we can use that as well. There's no issue. Okay. Uh guys, any questions so far? Okay. Do you guys want uh another example? Yes. S.
>> Yeah. In the uh link which I opened, I could also find OIN mention. So can you put some light on this? >> Mhm. Yeah, I think it's Yeah, it's used for for hashing. Um I do have uh I happen to have an example with hashing as well and if you if you guys want we can uh we can help. Yeah. Do you guys want we can use another example with that with Poseidon hash where we can see let's say some guessing or whatever that uh that will
work with Poseidon hash. Okay. Check if I can move this more. Okay. Uh let's say because uh uh this startup uh initial example has uh posidon right? >> Yeah. Uh the the link which opened first, right? You see?
>> Okay. >> Like >> okay, let me check. Um maybe we can have something with commitments then. Okay, let's um let's try out the the templates with uh with the hash. So let's try it out. know which one would be feasible to do within the time that we have.
Okay. Okay. Let's check it out. Okay. Oops. So, so, so okay. Um, let's try um guessing uh but with commitment and see how it works out in example of um circuits.
Let's try it out. Okay. So this should be a new example. So that means that uh once once we uh run it again uh I mean like before you save it, you need to run it again. Uh otherwise you will have the output of the previous one. Okay. We're going to we're going to use for this we're going to use two libraries. One will be comparators. The other ones, the other one will be Poseidon. This is how it should look like.
Pragma sir 2.1.6 for this example. Okay, everyone sees this. Check for it. We'll need to include two libraries. circle lip dot circle. Okay.
And another one. Let's try guessing some numbers.
Let's see. So what was the problem with the previous uh the previous example? Yeah, you can you can use um you can use signal for intermediary signals. So that's uh that way uh yeah whenever something changes um it will not be a constant value. So it should have um let's say that in our example we had input one input two. So that intermediary signal will change based on input.
So yeah definitely we can use signals for that. Okay. Um in this example that I want to show you guys is uh this is where we want to have okay we want to guess a number. We're going to have um three inputs here. We're going to have one for our guests, the other one for commitment and the other one for solution commitment. And um yeah, let's let's try it out. This would be like one um one example that's uh closer to um real life to say so um circuit
examples. So, let's write that one down. Signal input. Yes. Another one. Signal input solution. Third one. Signal. Okay. and put solution commitment
and signal opposite answer. Okay, everyone following so far. Okay. Okay. Um, so we're going to use this component.
The call is correct. Guess and we're going to use is equal. This is something we're using from these comparators that you see on the screen. this library.
Then we're going to have inputs because um the comparators library are using their own functions to compare whether two inputs are uh truly equal. And to do that we need to um assign it to uh that function in a way um let's say like um this um this function will have two inputs and we will assign it as in um the class that has um its own variables uh within it. So we're going to assign two values um and uh have an input to that class.
Um you can see it the the library is called um Iden 3. It's like this. This is the library that you can look for all of these um uh all of these uh um um child child libraries that uh that you can see like comparators etc. that you can see how do they have two inputs and um and now you don't have to I mean like you can write uh is correct guess like is equal function you can write it in your own um in your own circuit but why are you doing that when we already have ready um circuits for that so we don't
have to do that but you can always check it and get inspired from what um what their uh engineers have made for us that we can use it off the shelf. Okay. So to do the assignment we're going to say is correct guess dot in. And now we see that this this looks like uh an array in most the languages.
So in the first um the first index of the array and it's and it's zero because we're programmers right engineers. Uh we're going to assign gas our signal input from here. Okay. Or the other one. We're going to use solution.
Then uh we will have um component solution hash that we took from Poseidon library and say you're going to be The side hash
and yeah guys uh sometimes you will see dot uh in sometimes you'll see inputs It depends on who created the library. So you always need to check how does it look like. It's not consistent throughout um the circum. So we're assigning solution because we want to get the hash out of it.
And then we're going to compare it solution hash.out. So it's output. We want to make a constraint and check the equality with solution commitments. The answer. What would be the answer here?
>> I have no idea. I'm a bit lost. >> Um, should maybe Um maybe is correct guess can be the answer. No. >> Yes. We need an output out of that because we have uh put gas and solution both to is equal function and we need to get uh an output based on that. So, so far we are uh we are checking if the two if the two hashes to solution are uh um
are the same are they equal and we need to see if then the guess and solution are are comparatively equal so yeah it is correct guess dot output I mean out that we have and with that our template is done. Uh uh um for it.
>> Yes sir. Yeah. I have a question with component solution hash is equal to posidon one. So what exactly this this is comparing two hashes like the solution hash and the posidon one. It's the permutation of combination. we are checking if this hash is right or wrong. So this line is doing the same here or is it something else? >> Um so in this case um when you have components which has where component is correct guess it means is equal that means that is correct guess um is inheriting everything from is equal uh library. So it's uh there's some noises.
Uh so it's in a way uh like um instantiating a class in uh regular uh programming languages. So your pose is already a function or a class library that is already provided with uh this rep. >> Yes, we don't have to build it. It's uh it's built for us. >> Okay. Uh wrap up something.
We'll have here number America also one question the signal input solution commitment. Now solution commitment is one word or do we have a space between solution and commitment because while compiling there might
errors or warning should pop up. I'm just trying to confirm whether solution commitment is one word or two different. >> Yeah. Yeah. Yeah. It's it's one word. Yeah. It's one word. Yes. Mhm. Super cool. And we're going to have input which ones that uh Okay, I'll try scrolling a bit since all of you can see.
going to guess. Was it four? Let's say it's four. Solution four. And then we're going to have solution commitment as one word. I'll give you a website where we can use Poseidon for
uh calculating the the commitment to four but it should end up with something like 0 sorry 9904 etc. But you need to write that down. Let me check which one is it? The website that we can use for this one. It should be Poseidon dot something.
It crysts. Right. I'll share it with you. What should be the hash part? Yeah, that's it. Yeah, that's it. Hatum, uh, this is the tool you can use for it.
Yes, Kelly, that's it. That's the item tree library that we using here. Yes perfect. Can you show a bit up the file to see the import? >> Thanks. >> I hope nothing changed while I created this example. But um yeah, I can share with you how does Poseidon look like from within. Let me share it.
Check. Okay. Solution commitment. Hatton. I think you got it right. Yeah, looks like so you can um um you can calculate it uh as well. You got like all of the artifacts and you can use GRO 16 for that and then um you will have um you will end up with some uh with one HTML page. You will end up with the yeah with the the other artifacts that can be used later for ZK verify.
Okay. Okay. Let me share something else. Okay. So do you see Poseidon circum circuits here in circum lab uh hatton do you see Poseidon circum my screen okay I got the okay as in diving like yes everything's it
super cool. Okay, let's try to see uh let's find comparators. Okay, so this is what we used here. So these comparators are like some basic functions that we are using in our for example um is equal uh that uh that we used uh but there are there are multiple others as well. Um there are less than uh or less equal than so you don't have to write all of that out by yourself. But let's say if you wanted
uh you c you could have used this one but also you can uh you can use s0 as a function. So you see you remember when we were um talking about how all the nodes need to be equal zero right this is how it works like so we got two inputs n1 and n2 in our case and how the circum work it's it says like okay what I will do is subtract one from the other and if the result is zero I'll Um, I'll deem it as equal.
And that's um that's how it's uh it works with uh with uh uh with zeros and uh the zero sum game. We have it here. Okay, let's go to the Poseidon one. There are like different ones that you can um that you can visit here like uh uh where was the other one that I wanted to show you. Okay, it's not here. Uh but let's say this one. Uh this is what uh we have used for Poseidon. Let me show
you the exact uh function. Let me check. Okay, this is the one. Why did we have like Poseidon one? because it asks here for the number of inputs and uh and it will give you uh an output. So once you see like um when we had like okay this uh what we have solution hash right so we used solution hash out and that's what we got later for comparison Okay.
Bravo, Hatton. This is a perfect demo that you got. So, we got our gas or solution and solution commitment. We generated the proof. Yeah. Okay. Had had anyone everyone tried um what we had here with this uh input with guessing the number with this example? Anyone had any trouble?
>> I tried but yeah I have um trouble to make it work. I didn't really understand how we get the solution commitment hash. >> Uh solution commitment hash. >> Yes, like Hatum paste it in the in the chat. But no, I know you paste in chat. So you send it. We don't have to to generate it. >> Yeah. Let's say that you are like trying out a lottery and you want like what the solution is to to certain guessing because you want to make sure
that you are taking part in in a fair game uh that the the person who's running the game they need to uh to make a commitment to it. So that's that's why. >> Okay. And how did you get that number? is the random one. >> No, no, no. It's not a random number. Um, that's why we used uh Poseidon um hash library. So, it's a hash of a solution calculated using Poseidon.
Circum library that we have that we that we have here. So, we used this one uh this uh this function here. Um so the this template is what we used for and uh that's for our internal calculations within the the circuit but how we got it is that uh uh let me check. So we have um you can you can calculate posiden hash of a certain number online. I have posted a link in the chat and then you can uh put it in as the the input.
>> Okay. >> Okay. Let me check. So, so yeah, Q&A time and let's stay in touch. I will be off for two weeks. Uh but once I come back uh one of the next lessons that uh we're gonna have with um with us ZK verify uh I think it will be held by Arman the one which will be um teaching what ZK verify um looks like um what do we have architecture wise and then another one that will look
uh like that will you know we're going to dive into practice on how to verify these zero knowledge proofs. One of the things that we're also using is uh in our examples is um this zkrapple.dev libraries um that were generously created by Zerax Park team. Um so you know you didn't have to install the whole Rust tool chain and everything that comes with it. Um so if you want you can try it out and um generate some I think we also have some Poseidon. Uh yeah, we do have some boson examples there. Um so it's um docs.zkverify.io.
I'll share the link with you guys. Uh okay that's where we have the the examples and uh you can also verify the proofs not only create them because to actually make sure that your proof is valid you don't want to um you don't want it to be right forged and the other part it needs to verify then you need to either write the smart contract every time or you can use solutions like ZQ verify to verify it.
So you said that Arman is going to do ZK verify session. So is this our last session with you? >> Uh I don't think so. Uh I will have like the second one the second of the two sessions I think. >> Yeah. So, we're gonna see you one more time. I I was a bit emotional like, "Oh my god, is this the last one?" But yeah. Okay. >> I hope not. And we'll see you guys in Argentina as well, but my colleague will be uh there for one session with you guys uh because I'm going on vacation.
>> Perfect. You really deserve one. >> Thank you so much. I'm so happy for it. >> Do we have any questions, guys? All right. Um, so please, when I downloaded the HTML, that's the GR 16. The input isn't appear. Why I'm facing this challenge if it's only me? Let me put a screenshot so you have a view of what I'm trying to achieve.
Are you sharing this screenshot in Telegram group or the chat? this chat or uh Zoom chat. >> Thank you guys for the supporting words and messages here in chat. >> I'm posting it in the chat. >> Okay, >> let's check it. >> Yeah. Also guys, you can um you can uh try and play with like um different uh let's say like different uh uh guesses
and like still the same commitment and you can see like either like change the gas or change the solution or like slightly change the hash and you know check you know how does it look like. So what are we trying to do here John? >> All right. What I'm trying to achieve is um that that was the second example that we solved, right? >> Mhm.
>> Receive three inputs. So I tried to make mine five to receive five input and check if it the same. >> Okay. Uh can you show us your uh >> this is a >> yeah this is the HTML page that was generated I guess with uh growth 16. Can you go back to the example then to see like how did you change the inputs?
Okay. So this >> example um so I edit to receive temporar. >> Oh this is the first example. >> Yeah >> right. >> Yeah is what I did. [Music] Okay. So, I created an array,
right, which is going to receive an input of five digits. >> Okay, nice. you're starting to play with it with different number of inputs. >> Yeah. >> Okay. >> But I didn't understand why um the input. You see when Hatun downloaded his hertm file, she got the chance to input some digits. That's 44, right? To verify that. Of course, >> but I'm not >> maybe >> Yeah, I'm not at my end.
I use plon by the way. Maybe it it's something different. Yeah. And maybe you don't have the input signal in the uh band but no you have. I'm sorry. >> Yeah. John, if you want you can write me on telegram. >> All right. All right. Okay. So, if you use plum then that means I need to try plum because I used growth 16. I guess that's the reason why I'm not getting that.
>> I think it's just um the different um example but um I can look into it later. Yeah, just make sure like tag me and >> you can verify. >> Sure. >> No worries. Then if we don't have any question maybe we can finish the session. >> I I have a question. >> Yeah. >> Yeah. Uh so Melika this is more on the practical terms for developing basically why would we choose com for uh developing over no or something basically like can you give the uh the process why you how it is like what
benefits com has and why it it is better than other ZKDSL uh I'm I'm asking for personally right now because my team we are building a game gaming collective. So we're going to use it as you're aware. So uh I wanted to get an idea because we always have the dilemma where my developers ask me like should we go with circum or should we go with no or some other zkd. So yeah. >> Mhm. Yeah. Well, uh we're using a circum because um I like to show in this example at least um I like to show um how things work on on the low level um so that you can see you know you will
receive some errors uh like um you know if you try guessing with different number or you try to do commitment on on a false uh false commitment to to put it like to solution commitment in in um in our example. So it just like you don't need to use um any of um the preferred uh languages of mine. uh for me it's usually like um what is you know the the structure of the team let's say if the team has really good knowledge of rust language then I would definitely advise you to go with noir
because it's um rust based language but um for me like um it's um it's always per preference to the team circum is a bit more um let's say raw a bit more complicated uh but yeah like I think um noir is a bit more friendly for developers >> benefits like uh both are like it's about personal choice right it's not that one is has more advantage like sama has more advantage than because that's the route we are going with no um so just uh uh so from what you said I understand that it's more on the team
basis right you need to choose not it can be anything so come or online >> um and also like uh depends on your code base what you have like it's you know depending if you're starting a project or you already have uh some code base depends on the seniority of your of your devs and practically you know like basically about it's about the team decision >> and the team Makes sense. >> Yeah. >> Yeah, makes sense. Thanks. Thanks, Mika.
If any questions, I'll get in touch with you. >> Sure. Sure. >> Thank you. Thank you. >> IDMs are open too. >> I believe there's no other question. Uh thank you very much for everyone that come here and give their time. Thank you very much for effort, Melissa. Uh it was my first time with Cir and it was really fun. And yeah, let's uh finish this session. >> Thank you very much uh for for inviting me and also for entrusting me with this um very important ZK concepts.
>> Thank you very much for your time. I mean a lot of hearts. >> Yeah. Thank you. >> Thanks. Thanks Malik. >> Have good holidays. >> Thank you so much. Enjoy your vacation. >> Bye >> bye all of you. >> Thank you for your time. >> You bye-bye. >> Bye. >> See you. fiber.