mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-17 09:27:36 +00:00
Test bulletproof creation and verification
This commit is contained in:
parent
10ab467160
commit
f25bd88030
2 changed files with 22 additions and 0 deletions
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 hash_to_point;
|
||||||
mod clsag;
|
mod clsag;
|
||||||
|
mod bulletproofs;
|
||||||
mod address;
|
mod address;
|
||||||
|
|
Loading…
Reference in a new issue