Skip to content

Commit

Permalink
Optimistic verification passes but verifying aggregation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnusv committed Jul 24, 2024
1 parent da3af4f commit 6dc3355
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion ferveo/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use std::{
};

use hex::FromHex;
use crate::api::{PublicKey, Transcript};
use crate::api::{PublicKey, Transcript, AggregatedTranscript};
use ferveo_common::FromBytes;
use crate::EthereumAddress;
use crate::pvss::aggregate;

#[derive(Debug)]
struct ValidatorTranscript{
Expand Down Expand Up @@ -81,6 +82,8 @@ fn parse_file(file_path: &PathBuf) -> io::Result<Vec<ValidatorTranscript>> {

#[cfg(test)]
mod test {
use crate::{api::AggregatedTranscript, Validator};

use super::*;

#[test]
Expand All @@ -90,5 +93,25 @@ mod test {
std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(filename);
let records = parse_file(&file_path).unwrap();
assert_eq!(records.len(), 30);

let mut transcripts = Vec::new();
let mut vmessages = Vec::new();

// verify_optimistic
for (i, record) in records.iter().enumerate(){
assert!(record.transcript.verify_optimistic());

transcripts.push(record.transcript.clone());

let validator = Validator::new(record.validator_address.to_string(), record.validator_pk, i as u32).unwrap();
vmessages.push((validator.clone(), record.transcript.clone()));
}

// Aggregate
let agg = aggregate(&transcripts).unwrap();
assert!(agg.verify_optimistic());

let at = AggregatedTranscript::new(&vmessages).unwrap();
assert!(at.verify(30, &vmessages).unwrap());
}
}

0 comments on commit 6dc3355

Please sign in to comment.