mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-03 17:40:34 +00:00
Use a BatchVerifier in reserialize_chain
This commit is contained in:
parent
6d5851a9ee
commit
101da0a641
1 changed files with 16 additions and 2 deletions
|
@ -5,6 +5,8 @@ use curve25519_dalek::{
|
||||||
edwards::{CompressedEdwardsY, EdwardsPoint},
|
edwards::{CompressedEdwardsY, EdwardsPoint},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use multiexp::BatchVerifier;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
|
@ -92,6 +94,7 @@ async fn check_block(rpc: Arc<Rpc<HttpRpc>>, block_i: usize) {
|
||||||
all_txs.extend(txs.txs);
|
all_txs.extend(txs.txs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut batch = BatchVerifier::new(block.txs.len());
|
||||||
for (tx_hash, tx_res) in block.txs.into_iter().zip(all_txs.into_iter()) {
|
for (tx_hash, tx_res) in block.txs.into_iter().zip(all_txs.into_iter()) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tx_res.tx_hash,
|
tx_res.tx_hash,
|
||||||
|
@ -126,10 +129,20 @@ async fn check_block(rpc: Arc<Rpc<HttpRpc>>, block_i: usize) {
|
||||||
match tx.rct_signatures.prunable {
|
match tx.rct_signatures.prunable {
|
||||||
RctPrunable::Null | RctPrunable::MlsagBorromean { .. } => {}
|
RctPrunable::Null | RctPrunable::MlsagBorromean { .. } => {}
|
||||||
RctPrunable::MlsagBulletproofs { bulletproofs, .. } => {
|
RctPrunable::MlsagBulletproofs { bulletproofs, .. } => {
|
||||||
assert!(bulletproofs.verify(&mut rand_core::OsRng, &tx.rct_signatures.base.commitments));
|
assert!(bulletproofs.batch_verify(
|
||||||
|
&mut rand_core::OsRng,
|
||||||
|
&mut batch,
|
||||||
|
(),
|
||||||
|
&tx.rct_signatures.base.commitments
|
||||||
|
));
|
||||||
}
|
}
|
||||||
RctPrunable::Clsag { bulletproofs, clsags, pseudo_outs } => {
|
RctPrunable::Clsag { bulletproofs, clsags, pseudo_outs } => {
|
||||||
assert!(bulletproofs.verify(&mut rand_core::OsRng, &tx.rct_signatures.base.commitments));
|
assert!(bulletproofs.batch_verify(
|
||||||
|
&mut rand_core::OsRng,
|
||||||
|
&mut batch,
|
||||||
|
(),
|
||||||
|
&tx.rct_signatures.base.commitments
|
||||||
|
));
|
||||||
|
|
||||||
for (i, clsag) in clsags.into_iter().enumerate() {
|
for (i, clsag) in clsags.into_iter().enumerate() {
|
||||||
let (amount, key_offsets, image) = match &tx.prefix.inputs[i] {
|
let (amount, key_offsets, image) = match &tx.prefix.inputs[i] {
|
||||||
|
@ -219,6 +232,7 @@ async fn check_block(rpc: Arc<Rpc<HttpRpc>>, block_i: usize) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert!(batch.verify_vartime());
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Deserialized, hashed, and reserialized {block_i} with {} TXs", txs_len);
|
println!("Deserialized, hashed, and reserialized {block_i} with {} TXs", txs_len);
|
||||||
|
|
Loading…
Reference in a new issue