Skip to content

Commit bce39ee

Browse files
committed
refactor(stm): make prop tests work on concatenation proof
Instead of aggregate signature as tests are proof specific.
1 parent c3bc01d commit bce39ee

File tree

2 files changed

+25
-59
lines changed

2 files changed

+25
-59
lines changed

mithril-stm/src/aggregate_signature/mod.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub use signature::*;
1212

1313
#[cfg(test)]
1414
mod tests {
15+
use core::panic;
1516
use std::collections::{HashMap, HashSet};
1617

1718
use blake2::{Blake2b, digest::consts::U32};
@@ -461,28 +462,36 @@ mod tests {
461462
#[test]
462463
fn test_invalid_proof_index_unique(tc in arb_proof_setup(10)) {
463464
with_proof_mod(tc, |aggr, clerk, _msg| {
464-
for sig_reg in aggr.signatures().iter_mut() {
465-
for index in sig_reg.sig.indexes.iter_mut() {
466-
*index %= clerk.params.k - 1
465+
if let AggregateSignature::Concatenation(concatenation_proof) = aggr {
466+
for sig_reg in concatenation_proof.signatures.iter_mut() {
467+
for index in sig_reg.sig.indexes.iter_mut() {
468+
*index %= clerk.params.k - 1
469+
}
467470
}
471+
}else{
472+
panic!("Unexpected aggregate signature type");
468473
}
469474
})
470475
}
471476
#[test]
472477
fn test_invalid_proof_path(tc in arb_proof_setup(10)) {
473478
with_proof_mod(tc, |aggr, _, _msg| {
474-
let p = aggr.batch_proof().clone();
475-
let mut index_list = p.indices.clone();
476-
let values = p.values;
477-
let batch_proof = {
478-
index_list[0] += 1;
479-
MerkleBatchPath {
480-
values,
481-
indices: index_list,
482-
hasher: Default::default()
483-
}
484-
};
485-
aggr.set_batch_proof(batch_proof);
479+
if let AggregateSignature::Concatenation(concatenation_proof) = aggr {
480+
let p = concatenation_proof.batch_proof.clone();
481+
let mut index_list = p.indices.clone();
482+
let values = p.values;
483+
let batch_proof = {
484+
index_list[0] += 1;
485+
MerkleBatchPath {
486+
values,
487+
indices: index_list,
488+
hasher: Default::default()
489+
}
490+
};
491+
concatenation_proof.batch_proof = batch_proof;
492+
}else{
493+
panic!("Unexpected aggregate signature type");
494+
}
486495
})
487496
}
488497
}

mithril-stm/src/aggregate_signature/signature.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
77

88
use crate::error::StmAggregateSignatureError;
99
use crate::merkle_tree::MerkleBatchPath;
10-
use crate::{AggregateVerificationKey, Parameters, SingleSignatureWithRegisteredParty};
10+
use crate::{AggregateVerificationKey, Parameters};
1111

1212
use super::ConcatenationProof;
1313

@@ -208,49 +208,6 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
208208
)),
209209
}
210210
}
211-
212-
/// Extract the list of signatures.
213-
// TODO: transfer this function to the concatenation proof ? Some proofs might not fully carry this information
214-
pub fn signatures(&self) -> Vec<SingleSignatureWithRegisteredParty> {
215-
match self {
216-
AggregateSignature::Concatenation(concatenation_proof) => {
217-
concatenation_proof.signatures.clone()
218-
}
219-
#[cfg(feature = "future_proof_system")]
220-
AggregateSignature::Future(concatenation_proof) => {
221-
concatenation_proof.signatures.clone()
222-
}
223-
}
224-
}
225-
226-
/// Extract the list of unique merkle tree nodes that covers path for all signatures.
227-
// TODO: transfer this function to the concatenation proof
228-
pub fn batch_proof(&self) -> MerkleBatchPath<D> {
229-
match self {
230-
AggregateSignature::Concatenation(concatenation_proof) => {
231-
concatenation_proof.batch_proof.clone()
232-
}
233-
#[cfg(feature = "future_proof_system")]
234-
AggregateSignature::Future(concatenation_proof) => {
235-
concatenation_proof.batch_proof.clone()
236-
}
237-
}
238-
}
239-
240-
/// Extract the list of unique merkle tree nodes that covers path for all signatures. (test only)
241-
// TODO: transfer this function to the concatenation proof
242-
#[cfg(test)]
243-
pub(crate) fn set_batch_proof(&mut self, batch_proof: MerkleBatchPath<D>) {
244-
match self {
245-
AggregateSignature::Concatenation(concatenation_proof) => {
246-
concatenation_proof.batch_proof = batch_proof
247-
}
248-
#[cfg(feature = "future_proof_system")]
249-
AggregateSignature::Future(concatenation_proof) => {
250-
concatenation_proof.batch_proof = batch_proof
251-
}
252-
}
253-
}
254211
}
255212

256213
#[cfg(test)]

0 commit comments

Comments
 (0)