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

Add acceptable options argument to verification #219

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions examples/src/fibonacci/fib2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,23 @@ where
}

fn verify(&self, proof: StarkProof) -> Result<(), VerifierError> {
winterfell::verify::<FibAir, H, DefaultRandomCoin<H>>(proof, self.result)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);

winterfell::verify::<FibAir, H, DefaultRandomCoin<H>>(
proof,
self.result,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
winterfell::verify::<FibAir, H, DefaultRandomCoin<H>>(proof, self.result + BaseElement::ONE)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<FibAir, H, DefaultRandomCoin<H>>(
proof,
self.result + BaseElement::ONE,
&acceptable_options,
)
}
}
11 changes: 10 additions & 1 deletion examples/src/fibonacci/fib8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,22 @@ where
}

fn verify(&self, proof: StarkProof) -> Result<(), VerifierError> {
winterfell::verify::<Fib8Air, H, DefaultRandomCoin<H>>(proof, self.result)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<Fib8Air, H, DefaultRandomCoin<H>>(
proof,
self.result,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<Fib8Air, H, DefaultRandomCoin<H>>(
proof,
self.result + BaseElement::ONE,
&acceptable_options,
)
}
}
11 changes: 10 additions & 1 deletion examples/src/fibonacci/fib_small/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,22 @@ where
}

fn verify(&self, proof: StarkProof) -> Result<(), VerifierError> {
winterfell::verify::<FibSmall, H, DefaultRandomCoin<H>>(proof, self.result)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<FibSmall, H, DefaultRandomCoin<H>>(
proof,
self.result,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<FibSmall, H, DefaultRandomCoin<H>>(
proof,
self.result + BaseElement::ONE,
&acceptable_options,
)
}
}
11 changes: 10 additions & 1 deletion examples/src/fibonacci/mulfib2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,22 @@ where
}

fn verify(&self, proof: StarkProof) -> Result<(), VerifierError> {
winterfell::verify::<MulFib2Air, H, DefaultRandomCoin<H>>(proof, self.result)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<MulFib2Air, H, DefaultRandomCoin<H>>(
proof,
self.result,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<MulFib2Air, H, DefaultRandomCoin<H>>(
proof,
self.result + BaseElement::ONE,
&acceptable_options,
)
}
}
11 changes: 10 additions & 1 deletion examples/src/fibonacci/mulfib8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,22 @@ where
}

fn verify(&self, proof: StarkProof) -> Result<(), VerifierError> {
winterfell::verify::<MulFib8Air, H, DefaultRandomCoin<H>>(proof, self.result)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<MulFib8Air, H, DefaultRandomCoin<H>>(
proof,
self.result,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<MulFib8Air, H, DefaultRandomCoin<H>>(
proof,
self.result + BaseElement::ONE,
&acceptable_options,
)
}
}
16 changes: 14 additions & 2 deletions examples/src/lamport/aggregate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ where
pub_keys: self.pub_keys.clone(),
messages: self.messages.clone(),
};
winterfell::verify::<LamportAggregateAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<LamportAggregateAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
Expand All @@ -156,6 +162,12 @@ where
pub_keys,
messages: self.messages.clone(),
};
winterfell::verify::<LamportAggregateAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<LamportAggregateAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}
}
16 changes: 14 additions & 2 deletions examples/src/lamport/threshold/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ where
num_signatures: self.signatures.len(),
message: self.message,
};
winterfell::verify::<LamportThresholdAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<LamportThresholdAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
Expand All @@ -162,7 +168,13 @@ where
num_signatures: self.signatures.len() + 1,
message: self.message,
};
winterfell::verify::<LamportThresholdAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<LamportThresholdAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}
}

Expand Down
16 changes: 14 additions & 2 deletions examples/src/merkle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,27 @@ where
let pub_inputs = PublicInputs {
tree_root: self.tree_root.to_elements(),
};
winterfell::verify::<MerkleAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<MerkleAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let tree_root = self.tree_root.to_elements();
let pub_inputs = PublicInputs {
tree_root: [tree_root[1], tree_root[0]],
};
winterfell::verify::<MerkleAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<MerkleAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}
}

Expand Down
16 changes: 14 additions & 2 deletions examples/src/rescue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,27 @@ where
seed: self.seed,
result: self.result,
};
winterfell::verify::<RescueAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<RescueAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let pub_inputs = PublicInputs {
seed: self.seed,
result: [self.result[0], self.result[1] + BaseElement::ONE],
};
winterfell::verify::<RescueAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<RescueAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}
}

Expand Down
16 changes: 14 additions & 2 deletions examples/src/rescue_raps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,26 @@ where
let pub_inputs = PublicInputs {
result: self.result,
};
winterfell::verify::<RescueRapsAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<RescueRapsAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let pub_inputs = PublicInputs {
result: [self.result[1], self.result[0]],
};
winterfell::verify::<RescueRapsAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<RescueRapsAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}
}

Expand Down
16 changes: 14 additions & 2 deletions examples/src/vdf/exempt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,27 @@ where
seed: self.seed,
result: self.result,
};
winterfell::verify::<VdfAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<VdfAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let pub_inputs = VdfInputs {
seed: self.seed,
result: self.result + BaseElement::ONE,
};
winterfell::verify::<VdfAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<VdfAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}
}

Expand Down
16 changes: 14 additions & 2 deletions examples/src/vdf/regular/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,27 @@ where
seed: self.seed,
result: self.result,
};
winterfell::verify::<VdfAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<VdfAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}

fn verify_with_wrong_inputs(&self, proof: StarkProof) -> Result<(), VerifierError> {
let pub_inputs = VdfInputs {
seed: self.seed,
result: self.result + BaseElement::ONE,
};
winterfell::verify::<VdfAir, H, DefaultRandomCoin<H>>(proof, pub_inputs)
let acceptable_options =
winterfell::AcceptableOptions::OptionSet(vec![proof.options().clone()]);
winterfell::verify::<VdfAir, H, DefaultRandomCoin<H>>(
proof,
pub_inputs,
&acceptable_options,
)
}
}

Expand Down
18 changes: 18 additions & 0 deletions verifier/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ pub enum VerifierError {
/// constraint evaluation queries do not represent a polynomial of the degree expected by the
/// verifier.
FriVerificationFailed(fri::VerifierError),
/// This error occurs when the parameters, that were used to generate the proof, do not provide
/// a conjectured security level greater than or equal to the conjectured security level
/// expected by the verifier.
InsufficientConjecturedSecurity(u32, u32),
/// This error occurs when the parameters, that were used to generate the proof, do not provide
/// a proven security level greater than or equal to the proven security level expected by
/// the verifier.
InsufficientProvenSecurity(u32, u32),
/// This error occurs when the parameters, that were used to generate the proof, do not match
/// any of the set of parameters expected by the verifier.
UnacceptableProofOptions,
}

impl fmt::Display for VerifierError {
Expand Down Expand Up @@ -74,6 +85,13 @@ impl fmt::Display for VerifierError {
Self::FriVerificationFailed(err) => {
write!(f, "verification of low-degree proof failed: {err}")
}
Self::InsufficientConjecturedSecurity(minimal_security, proof_security)=> {
write!(f, "insufficient proof security level: expected at least {minimal_security} bits of conjectured security, but was {proof_security} bits")
}
Self::InsufficientProvenSecurity(minimal_security, proof_security)=> {
write!(f, "insufficient proof security level: expected at least {minimal_security} bits of proven security, but was {proof_security} bits")
}
Self::UnacceptableProofOptions => {write!(f, "invalid proof options: security parameters do not match the acceptable parameter set")}
}
}
}
Loading
Loading