-
Notifications
You must be signed in to change notification settings - Fork 107
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
Recursion, Pt 2 #250
Recursion, Pt 2 #250
Conversation
8e36315
to
b784561
Compare
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.
some comments:
@@ -879,6 +879,14 @@ type PartiesProved = { | |||
memo: string; | |||
}; | |||
|
|||
/** | |||
* The public input for zkApps consists of certain hashes of the transaction and of the proving Party which is constructed during method execution. |
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 comment was just moved over from zkapp.ts
where it made no sense anymore
src/lib/proof_system.ts
Outdated
@@ -41,3 +53,321 @@ let CompiledTag = { | |||
compiledTags.set(tag, compiledTag); | |||
}, | |||
}; | |||
|
|||
function Program< |
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 the new thing!
@@ -54,119 +53,69 @@ export function method<T extends SmartContract>( | |||
); | |||
} | |||
let paramTypes = Reflect.getMetadata('design:paramtypes', target, methodName); | |||
let witnessArgs = []; |
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 logic was moved to proof_system.ts
and reused here
// outside a transaction, just call the method | ||
return method.apply(this, actualArgs); | ||
return function wrappedMethod(this: SmartContract, ...actualArgs: any[]) { | ||
if (inCheckedComputation() || Mina.currentTransaction === undefined) { |
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 logic was moved here because it is smart-contract-specific
return wrappedMethod; | ||
} | ||
|
||
type methodEntry<T> = { |
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.
moved to proof_system.ts
to be reused
@@ -176,74 +125,6 @@ function checkPublicInput( | |||
transaction.assertEquals(otherInput.transaction); | |||
} | |||
|
|||
function picklesRuleFromFunction<T>( |
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.
moved to proof_system.ts
to be reused
} else { | ||
// in a transaction, also add a lazy proof to the self party | ||
// (if there's no other authorization set) | ||
let auth = this.self.authorization; | ||
if (!('kind' in auth || 'proof' in auth || 'signature' in auth)) { | ||
let previousProofs: Pickles.ProofWithPublicInput[] = []; |
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.
moved to proof_system.ts
to be reused
|
||
let rules = (this._methods ?? []).map((methodEntry) => |
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.
moved to proof_system.ts
to be reused
return typ.ofFields(Array(typ.sizeInFields()).fill(Field.zero)); | ||
} | ||
|
||
function emptyWitness<A>(typ: AsFieldElements<A>) { |
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.
moved to proof_system.ts
to be reused
@@ -15,7 +15,7 @@ export { | |||
let mainContext = undefined as | |||
| { | |||
witnesses?: unknown[]; | |||
self: Party; | |||
self?: Party; |
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 type was changed because there is no Party
in non-smart-contract proofs
Program
function to create a custom "proof system"Program
shares its implementation withSmartContract
, even thoughSmartContract
does not (yet?) useProgram
directly; common functionality was moved fromzkapp.ts
toproof_system.ts
, and smart-contract-specific stuff was split outsrc/examples/program.ts
which serves as rudimentary documentation forProgram