mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Test bulletproof creation and verification
This commit is contained in:
21
coins/monero/src/tests/bulletproofs.rs
Normal file
21
coins/monero/src/tests/bulletproofs.rs
Normal 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()
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
mod hash_to_point;
|
||||
mod clsag;
|
||||
mod bulletproofs;
|
||||
mod address;
|
||||
|
||||
Reference in New Issue
Block a user