Test bulletproof creation and verification

This commit is contained in:
Luke Parker 2022-07-24 09:00:55 -04:00
parent 10ab467160
commit f25bd88030
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,21 @@
use rand::rngs::OsRng;
use crate::{Commitment, random_scalar, ringct::bulletproofs::Bulletproofs};
#[test]
fn bulletproofs() {
// Create Bulletproofs for all possible output quantities
for i in 1 .. 17 {
let commitments =
(1 ..= i).map(|i| Commitment::new(random_scalar(&mut OsRng), i)).collect::<Vec<_>>();
assert!(Bulletproofs::new(&mut OsRng, &commitments)
.unwrap()
.verify(&mut OsRng, &commitments.iter().map(Commitment::calculate).collect::<Vec<_>>()));
}
// Check it errors if we try to create too many
assert!(
Bulletproofs::new(&mut OsRng, &[Commitment::new(random_scalar(&mut OsRng), 1); 17]).is_err()
);
}

View file

@ -1,3 +1,4 @@
mod hash_to_point;
mod clsag;
mod bulletproofs;
mod address;