Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

zkvm: implement and, or, verify instructions #147

Merged
merged 8 commits into from
Feb 28, 2019
Merged

Conversation

cathieyun
Copy link
Contributor

@cathieyun cathieyun commented Feb 27, 2019

  • change Constraint::{And, Or} to be a tuple of two boxed constraints, instead of a vector (since they'll only ever be created from two constraints anyways, and we can do the flattening in the verify function
  • implement and, or using the new Constraint type
  • implement verify: enter 2nd phase of 2-phase challenge API, in order to get z challenge. Then recursively "flatten" the constraint, until the base case Expression type, and combine the Expressions according to the rules until you have one Expression that represents the whole constraint. Then push that constraint onto the constraint system.

Question: I implemented the From<R1CSError> for VMError trait, but in verify it does not automatically convert R1CSError to VMError, so I have to do it explicitly. I thought this would be implicit because of the From trait?
Update: What I'd want is TryFrom, which is nightly-only. So I'll just do explicit conversion for now!

zkvm/src/constraints.rs Outdated Show resolved Hide resolved
zkvm/src/constraints.rs Outdated Show resolved Hide resolved
zkvm/src/constraints.rs Outdated Show resolved Hide resolved
zkvm/src/constraints.rs Outdated Show resolved Hide resolved
zkvm/src/constraints.rs Outdated Show resolved Hide resolved
zkvm/src/constraints.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@oleganza oleganza left a comment

Choose a reason for hiding this comment

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

LGTM!

@cathieyun cathieyun merged commit 171ed82 into main Feb 28, 2019
@cathieyun cathieyun deleted the cathie/opcodes branch February 28, 2019 00:09
@oleganza oleganza mentioned this pull request Feb 28, 2019
27 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants