-
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
Allow non-pure provable types as inputs/outputs in zkprogram #1828
base: main
Are you sure you want to change the base?
Conversation
… ProvablePure to Provable
…m ProvablePure to Provable
…gram state for zk programs
…or clarity and consistency with its purpose
…e for better clarity and consistency in naming conventions
…r setting auxiliary output values
…ram function for future use and flexibility
…t for consistency and clarity
…r clarity and consistency
…to 'setAuxiliaryInput' for consistency
…f996b6ac35373dc27084ef
…putExists for clarity
…avoid unnecessary operations
…ure auxilary data was updated in-circuit
…ux data made in circuit
…e for additional input data support
…e auxData parameter for additional flexibility and reusability
…prove code readability and maintainability
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.
lmk when the PR is ready for a more thorough review!
await MyProgram.compile(); | ||
console.log('compile done'); | ||
|
||
let input = new MyStruct({ label: 'input', value: Field(5) }); |
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 missing the description
property
console.log('proof', proof); | ||
|
||
assert(ok, 'proof not valid!'); | ||
// assert(proof.publicOutput.label === 'inCircuit'); |
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.
once the PR is ready we should re-enable this check
src/lib/proof-system/zkprogram.ts
Outdated
@@ -161,12 +161,30 @@ const FeatureFlags = { | |||
}; | |||
|
|||
function createProgramState() { | |||
let nonPureDataCache: Map<string, any[]> = new Map(); |
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.
we could just reuse the method cache for this too, would make it a bit cleaner but we would have to differenciate between nonpure auxiliary data and the auxiliary output its currently keeping track. both are valid imo
src/lib/proof-system/zkprogram.ts
Outdated
result = (await func(input, ...finalArgs)) as any; | ||
} | ||
|
||
console.log('result input', result); | ||
if (result.publicOutput) { |
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 should probably be result?.publicOutput
since result
is unfornately typed
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.
(approved by accident, sorry)
…ld from MyStruct and add assertion to check for 'label' value in proof.publicOutput
…to use optional chaining for improved readability and null safety
…log statement for 'proof' variable
@ymekuria please rebase too |
…ean up code and improve readability
…NonPureOutput to improve code clarity and type safety
…input and output variables to be more descriptive and accurate
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 aIndexedMerkleMap
or aMerkleList
in aZkProgram
.