Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: Add serde for BLSAggregateSignature #340

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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