Skip to content

Commit 1e16d17

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

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

@@ -193,49 +193,6 @@ impl<D: Clone + Digest + FixedOutput + Send + Sync> AggregateSignature<D> {
193193
AggregateSignature::Future => None,
194194
}
195195
}
196-
197-
/// Extract the list of signatures.
198-
// TODO: transfer this function to the concatenation proof ? Some proofs might not fully carry this information
199-
pub fn signatures(&self) -> Vec<SingleSignatureWithRegisteredParty> {
200-
match self {
201-
AggregateSignature::Concatenation(concatenation_proof) => {
202-
concatenation_proof.signatures.clone()
203-
}
204-
#[cfg(feature = "future_proof_system")]
205-
AggregateSignature::Future(concatenation_proof) => {
206-
concatenation_proof.signatures.clone()
207-
}
208-
}
209-
}
210-
211-
/// Extract the list of unique merkle tree nodes that covers path for all signatures.
212-
// TODO: transfer this function to the concatenation proof
213-
pub fn batch_proof(&self) -> MerkleBatchPath<D> {
214-
match self {
215-
AggregateSignature::Concatenation(concatenation_proof) => {
216-
concatenation_proof.batch_proof.clone()
217-
}
218-
#[cfg(feature = "future_proof_system")]
219-
AggregateSignature::Future(concatenation_proof) => {
220-
concatenation_proof.batch_proof.clone()
221-
}
222-
}
223-
}
224-
225-
/// Extract the list of unique merkle tree nodes that covers path for all signatures. (test only)
226-
// TODO: transfer this function to the concatenation proof
227-
#[cfg(test)]
228-
pub(crate) fn set_batch_proof(&mut self, batch_proof: MerkleBatchPath<D>) {
229-
match self {
230-
AggregateSignature::Concatenation(concatenation_proof) => {
231-
concatenation_proof.batch_proof = batch_proof
232-
}
233-
#[cfg(feature = "future_proof_system")]
234-
AggregateSignature::Future(concatenation_proof) => {
235-
concatenation_proof.batch_proof = batch_proof
236-
}
237-
}
238-
}
239196
}
240197

241198
#[cfg(test)]

0 commit comments

Comments
 (0)