Skip to content
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

Merged
merged 25 commits into from
Jun 27, 2022
Merged

Recursion, Pt 2 #250

merged 25 commits into from
Jun 27, 2022

Conversation

mitschabaude
Copy link
Member

@mitschabaude mitschabaude commented Jun 20, 2022

  • Follow-up to Recursion Pt 1 #245
  • RFC: Recursion / proof composition RFC #89
  • Adds new Program function to create a custom "proof system"
  • Most of the logic for Program shares its implementation with SmartContract, even though SmartContract does not (yet?) use Program directly; common functionality was moved from zkapp.ts to proof_system.ts, and smart-contract-specific stuff was split out
  • adds new example src/examples/program.ts which serves as rudimentary documentation for Program

Copy link
Member Author

@mitschabaude mitschabaude left a 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.
Copy link
Member Author

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

@@ -41,3 +53,321 @@ let CompiledTag = {
compiledTags.set(tag, compiledTag);
},
};

function Program<
Copy link
Member Author

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 = [];
Copy link
Member Author

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) {
Copy link
Member Author

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> = {
Copy link
Member Author

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>(
Copy link
Member Author

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[] = [];
Copy link
Member Author

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) =>
Copy link
Member Author

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>) {
Copy link
Member Author

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;
Copy link
Member Author

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

This was referenced Jun 22, 2022
@mitschabaude mitschabaude changed the base branch from feature/recursion to main June 27, 2022 11:03
@mitschabaude mitschabaude merged commit bad9ec5 into main Jun 27, 2022
@mitschabaude mitschabaude deleted the feature/recursion-2 branch June 27, 2022 11:23
@mitschabaude mitschabaude mentioned this pull request Jun 27, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants