Skip to content

Commit

Permalink
crypto: Add serde for BLSAggregateSignature
Browse files Browse the repository at this point in the history
  • Loading branch information
joyqvq committed Jan 4, 2023
1 parent 4886087 commit f53860f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions fastcrypto/src/bls12381/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,19 @@ pub struct BLS12381KeyPair {
/// BLS 12-381 signature.
#[readonly::make]
#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone)]
pub struct BLS12381Signature {
#[serde_as(as = "BlsSignature")]
pub sig: blst::Signature,
#[serde(skip)]
pub bytes: OnceCell<[u8; $sig_length]>,
}

serialize_deserialize_with_to_from_bytes!(BLS12381Signature);

/// Aggregation of multiple BLS 12-381 signatures.
#[readonly::make]
#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone)]
pub struct BLS12381AggregateSignature {
#[serde_as(as = "Option<BlsSignature>")]
pub sig: Option<blst::Signature>,
#[serde(skip)]
pub bytes: OnceCell<[u8; $sig_length]>,
}

Expand Down Expand Up @@ -714,6 +711,8 @@ impl ToFromBytes for BLS12381AggregateSignature {
}
}

serialize_deserialize_with_to_from_bytes!(BLS12381AggregateSignature);

pub struct BlsSignature;

impl SerializeAs<blst::Signature> for BlsSignature {
Expand Down

0 comments on commit f53860f

Please sign in to comment.