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 Bulletproof rewind functionality #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions benches/r1cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn bench_kshuffle_prove(c: &mut Criterion) {
let mut rng = rand::thread_rng();
let (min, max) = (0u64, std::u64::MAX);
let input: Vec<Scalar> = (0..*k)
.map(|_| Scalar::from(rng.gen_range(min, max)))
.map(|_| Scalar::from(rng.gen_range(min..max)))
.collect();
let mut output = input.clone();
output.shuffle(&mut rand::thread_rng());
Expand Down Expand Up @@ -217,7 +217,7 @@ fn bench_kshuffle_verify(c: &mut Criterion) {
let mut rng = rand::thread_rng();
let (min, max) = (0u64, std::u64::MAX);
let input: Vec<Scalar> = (0..*k)
.map(|_| Scalar::from(rng.gen_range(min, max)))
.map(|_| Scalar::from(rng.gen_range(min..max)))
.collect();
let mut output = input.clone();
output.shuffle(&mut rand::thread_rng());
Expand Down
4 changes: 2 additions & 2 deletions benches/range_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn create_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {
let mut rng = rand::thread_rng();

let (min, max) = (0u64, ((1u128 << n) - 1) as u64);
let values: Vec<u64> = (0..m).map(|_| rng.gen_range(min, max)).collect();
let values: Vec<u64> = (0..m).map(|_| rng.gen_range(min..max)).collect();
let blindings: Vec<Scalar> = (0..m).map(|_| Scalar::random(&mut rng)).collect();

b.iter(|| {
Expand Down Expand Up @@ -74,7 +74,7 @@ fn verify_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {
let mut rng = rand::thread_rng();

let (min, max) = (0u64, ((1u128 << n) - 1) as u64);
let values: Vec<u64> = (0..m).map(|_| rng.gen_range(min, max)).collect();
let values: Vec<u64> = (0..m).map(|_| rng.gen_range(min..max)).collect();
let blindings: Vec<Scalar> = (0..m).map(|_| Scalar::random(&mut rng)).collect();

let mut transcript = Transcript::new(b"AggregateRangeProofBenchmark");
Expand Down
12 changes: 12 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ pub enum ProofError {
/// consider its errors to be internal errors.
#[cfg_attr(feature = "std", error("Internal error during proof creation: {0}"))]
ProvingError(MPCError),
/// This error results from trying to rewind a proof with the wrong rewind nonce
#[cfg_attr(
feature = "std",
error("Rewinding the proof failed, invalid commitment extracted")
)]
InvalidCommitmentExtracted,
/// This error results from trying to rewind a proof with an invalid rewind key separator
#[cfg_attr(
feature = "std",
error("Trying to rewind a proof with the wrong rewind key separator")
)]
InvalidRewindKeySeparator,
}

impl From<MPCError> for ProofError {
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ mod notes {
mod errors;
mod generators;
mod inner_product_proof;
mod range_proof;
// TODO: Do not expose `range_proof` publicly
pub mod range_proof;
mod transcript;

pub use crate::errors::ProofError;
Expand Down
Loading