refactor: clean up witness package, introduces clean witness.Witness interface#450
Merged
refactor: clean up witness package, introduces clean witness.Witness interface#450
witness.Witness interface#450Conversation
…uple schema.Schema
ivokub
approved these changes
Jan 31, 2023
Collaborator
ivokub
left a comment
There was a problem hiding this comment.
Looks all good. A few minor comments but otherwise good to go. I think this change makes a lot of sense and makes the whole binary representation of witness so much more clear and practical to use.
I don't understand why the tests are failing though. May it due to double filling in FromJSON?
internal/generator/backend/template/zkpschemes/plonk/plonk.prove.go.tmpl
Outdated
Show resolved
Hide resolved
internal/generator/backend/template/zkpschemes/plonk/plonk.verify.go.tmpl
Outdated
Show resolved
Hide resolved
internal/generator/backend/template/zkpschemes/plonkfri/plonk.prove.go.tmpl
Outdated
Show resolved
Hide resolved
internal/generator/backend/template/zkpschemes/plonkfri/plonk.verify.go.tmpl
Outdated
Show resolved
Hide resolved
internal/generator/backend/template/zkpschemes/groth16/groth16.prove.go.tmpl
Outdated
Show resolved
Hide resolved
internal/generator/backend/template/zkpschemes/groth16/groth16.verify.go.tmpl
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation for this PR
#445 and #442 . + decouple *schema.Schema from witness data structure; we only need a
schema.Schemawhen doingJSON(un)marshaling, which happens for pretty printing or in the playground. This had a significant cost in cpu + in storage, and in 99% of cases we didn't use it.See
witness.ExampleWitnessfor usage andwitness.Witnessinterface for the gist of the PR.Additionally,
groth16plonkandconstraintpackages now directly reason with[]fr.Element(as they should).Breaking changes;
[uint32(nbPublic)|uint32(nbSecret)|uint32(nbElements)|elements...]instead of[uint32(nbElements)|elements...].fr.Vectormanage its serialization (in gnark-crypto), but a witness needs these 2 extra uint32 to ensure consistency when serializing / deserializing.