Repository navigation
Conversation
…rity contract Signed-off-by: somasoil <somasoil@outlook.com>
Author
|
@microsoft-github-policy-service agree |
Author
|
Srinath Setty (@srinathsetty) Could you please take a look when you have a chance? Thanks! |
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.
Summary
DirectSNARKswallowed every error raised while synthesizing the step circuit, and neverchecked that the circuit honors the arity it declares.
setup/provenow return a properNovaErrorin all of those cases.Changes
src/spartan/direct.rsDirectCircuitno longer discards the twoinputizeresults; they are propagated with?.DirectCircuit::synthesize_inner, which returnsNovaErrorand enforces theStepCircuitarity contract:arity()elements, otherwiseNovaError::InvalidInputLength;arity()outputs, otherwiseNovaError::InvalidStepOutputLength.DirectSNARK::setupandDirectSNARK::provecallsynthesize_inner(&mut cs)?instead oflet _ = circuit.synthesize(&mut cs);, so synthesis failures are surfaced asNovaError::SynthesisError { .. }through the existingFrom<SynthesisError>impl.Circuitimpl is kept and is now a thin wrapper oversynthesize_inner, so there are nopublic API changes and the existing call sites in
src/neutron/{nifs,relation}.rskeep working.Why a private
synthesize_innerCircuit::synthesizemust returnSynthesisError, so a check placed inside it cannot surface theexisting typed
NovaError::InvalidInputLength/NovaError::InvalidStepOutputLength.synthesize_innerreturnsNovaErrorand is whatsetup/provecall, which makes each failuremode directly assertable in tests (same style as the existing
assert_eq!(pp.err(), Some(NovaError::InvalidStepCircuitIO))in src/nova/mod.rs).Tests
Added to
src/spartan/direct.rs:FailingCircuit— a step circuit whosesynthesizealways returnsErr(SynthesisError::Unsatisfiable(..)). Bothsetupandprovenow returnErr(NovaError::SynthesisError { .. }).WrongOutputArityCircuit— declaresarity() == 2but returns a single output.setupreturnsErr(NovaError::InvalidStepOutputLength).provewith an input that is too long (2 elements forarity() == 1) returnsErr(NovaError::InvalidInputLength); with an empty input it returns the same error instead ofpanicking (previously an index-out-of-bounds panic).
Verified:
cargo test --release --lib spartan::direct— 3 passedcargo test --release --features experimental neutron— 10 passed (DirectCircuitis also used there)cargo clippy --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanChecklist
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test --release