-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: unify bls types * ci * remove clone
- Loading branch information
Showing
7 changed files
with
86 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use milagro_bls::{AggregateSignature, PublicKey as MilagroPK}; | ||
use serde::{Deserialize, Serialize}; | ||
use ssz_derive::{Decode, Encode}; | ||
use tree_hash_derive::TreeHash; | ||
|
||
use super::bytes::ByteVector; | ||
|
||
#[derive(Debug, Clone, Default, Serialize, Deserialize, Encode, Decode, TreeHash)] | ||
#[ssz(struct_behaviour = "transparent")] | ||
#[serde(transparent)] | ||
pub struct PublicKey { | ||
inner: ByteVector<typenum::U48>, | ||
} | ||
|
||
#[derive(Debug, Clone, Default, Serialize, Deserialize, Encode, Decode, TreeHash)] | ||
#[ssz(struct_behaviour = "transparent")] | ||
#[serde(transparent)] | ||
pub struct Signature { | ||
inner: ByteVector<typenum::U96>, | ||
} | ||
|
||
impl Signature { | ||
pub fn verify(&self, msg: &[u8], pks: &[PublicKey]) -> bool { | ||
if let Ok(agg) = AggregateSignature::from_bytes(&self.inner.inner) { | ||
let pks_res = pks | ||
.iter() | ||
.map(|pk| MilagroPK::from_bytes(&pk.inner.inner)) | ||
.collect::<Result<Vec<_>, _>>(); | ||
|
||
if let Ok(pks) = pks_res { | ||
let pks = pks.iter().collect::<Vec<_>>(); | ||
agg.fast_aggregate_verify(msg, &pks) | ||
} else { | ||
false | ||
} | ||
} else { | ||
false | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters