-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zkApps composability, pt 3: witness Party #294
Conversation
8262589
to
332961b
Compare
@@ -404,14 +430,9 @@ class Int64 extends CircuitValue implements BalanceChange { | |||
|
|||
// --- circuit-compatible operations below --- | |||
// the assumption here is that all Int64 values that appear in a circuit are already checked as valid | |||
// this is because Circuit.witness calls .check | |||
// this is because Circuit.witness calls .check, which calls .check on each prop, i.e. UInt64 and Sign | |||
// so we only have to do additional checks if an operation on valid inputs can have an invalid outcome (example: overflow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean to remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment? No. I did mean to remove the custom check method, because now the check method on the base class does what we need
return fields.pop()!; | ||
}, | ||
Bool(fields: Field[]) { | ||
return Bool.Unsafe.ofField(fields.pop()!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only invoked on generated code we control from the json layout right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! So it's safe because we know the field we're reading out was a Bool originally
This adds the capability to "witness a Party" -- i.e., doing something like
Circuit.witness(() => party)
. (Which isn't possible withCircuit.witness
directly).Motivation: This was the main hurdle to take for implementing zkApp composability. When calling another zkApp, we actually don't want to run its computation inside the caller's circuit. Instead, we want the callee to be its own party, with its own proof. In the caller's circuit we just want to pull the result of the call out of our hat (= witness it). That result is the callee's party, plus the input and output arguments of the call. We connect it to the actual computation & its proof by having the callee's party's hash as part of the public input in the caller circuit.
To create a party witness we want to leverage the auto-generated party structure from OCaml -- to avoid hard-coding the party structure again. So, this PR
Party implements Types.Party
. I.e., the Party class exactly conforms to the TS type that is generated. The changes needed wereSign
that's part ofInt64
, so that in the party we can have theBalance
be aUint64
+Sign
instead of anInt64
directlyauthorization
field which has to be compatible with the OCaml typeThe PR also significantly changes the generated
js-layout
, by changing the js deriver (see Mina companion), but this is actually an orthogonal change, only a small part of it was really needed here.