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

Allow non-pure provable types as inputs/outputs in zkprogram #1828

Merged
merged 172 commits into from
Dec 2, 2024

Conversation

ymekuria
Copy link
Contributor

@ymekuria ymekuria commented Sep 18, 2024

Summary

This PR updates ZkProgram to allow non-pure provable types as inputs and outputs.

Addresses #1675

Impact

Currently only pure provable types can be used as inputs and outputs to a ZkProgram. This PR improves the DX with changes that allow a developer to update rich provable types like a IndexedMerkleMap or a MerkleList in a ZkProgram.

…e for better clarity and consistency in naming conventions
CHANGELOG.md Outdated Show resolved Hide resolved
ymekuria and others added 4 commits November 26, 2024 01:45
…rogram to clean up code and improve readability

docs(program-with-non-pure-input.ts): remove console logs related to NonPureInputProgram compilation for clarity and cleanliness
Copy link
Member

@Trivo25 Trivo25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! FYI I have reverted the mina and bindings commit

src/examples/zkprogram/program-with-non-pure-input.ts Outdated Show resolved Hide resolved
console.log('compile done');
let input = new MyStruct({ label: 'input', value: Field(5) });
let proof;
({ proof } = await NonPureIOprogram.baseCase(input));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i actually didn't know you could reassign a deconstructed value without redeclaring the variable! :D

src/examples/zkprogram/program-with-non-pure-input.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@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.

implementation-wise, looks good to me!

we just have a problem with converting proofs to/from JSON now: proofs are serialized by doing toFields() on publicInput and publicOutput and converting these fields to strings. this will work in toJSON(), but will fail in fromJSON() where the aux part in fromFields() will be missing.

to solve that we'd need a general way to serialize any provable type. I have some ideas on that that I might post in a separate issue

src/lib/proof-system/zkprogram.ts Outdated Show resolved Hide resolved
@mitschabaude
Copy link
Collaborator

huge simplification for so many zkprograms! 🥳

@ymekuria ymekuria merged commit eee5d2f into main Dec 2, 2024
28 checks passed
@ymekuria ymekuria deleted the feature/non-pure-zkprogram-inputs branch December 2, 2024 02:26
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.

4 participants