use super::*; use crate::case_result::compare_result; use bls::{AggregatePublicKey, PublicKey}; use serde_derive::Deserialize; #[derive(Debug, Clone, Deserialize)] pub struct BlsAggregatePubkeys { pub input: Vec, pub output: String, } impl YamlDecode for BlsAggregatePubkeys { fn yaml_decode(yaml: &str) -> Result { Ok(serde_yaml::from_str(yaml).unwrap()) } } impl Case for BlsAggregatePubkeys { fn result(&self, _case_index: usize) -> Result<(), Error> { let mut aggregate_pubkey = AggregatePublicKey::new(); for key_str in &self.input { let key = hex::decode(&key_str[2..]) .map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?; let key = PublicKey::from_bytes(&key) .map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?; aggregate_pubkey.add(&key); } let output_bytes = Some( hex::decode(&self.output[2..]) .map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?, ); let aggregate_pubkey = Ok(aggregate_pubkey.as_raw().as_bytes()); compare_result::, Vec>(&aggregate_pubkey, &output_bytes) } }