From f53860fad02f8e8d46dfebe9856a87fe088d0c60 Mon Sep 17 00:00:00 2001 From: Joy Wang <108701016+joyqvq@users.noreply.github.com> Date: Wed, 4 Jan 2023 15:24:46 +0800 Subject: [PATCH] crypto: Add serde for BLSAggregateSignature --- fastcrypto/src/bls12381/mod.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fastcrypto/src/bls12381/mod.rs b/fastcrypto/src/bls12381/mod.rs index ee7c9acc98..d1944b27f4 100644 --- a/fastcrypto/src/bls12381/mod.rs +++ b/fastcrypto/src/bls12381/mod.rs @@ -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")] pub sig: Option, - #[serde(skip)] pub bytes: OnceCell<[u8; $sig_length]>, } @@ -714,6 +711,8 @@ impl ToFromBytes for BLS12381AggregateSignature { } } +serialize_deserialize_with_to_from_bytes!(BLS12381AggregateSignature); + pub struct BlsSignature; impl SerializeAs for BlsSignature {