Skip to content

Commit

Permalink
fix: put serde behind feature
Browse files Browse the repository at this point in the history
  • Loading branch information
shuklaayush committed Jan 22, 2024
1 parent 99a301c commit 5cc2b9a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/ed25519/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ use ff::{BatchInverter, Field, PrimeField};
use group::{self, Curve};
use group::{prime::PrimeCurveAffine, GroupEncoding};
use rand::RngCore;
use serde::{Deserialize, Serialize};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "derive_serde")]
use serde::{Deserialize, Serialize};

const ED25519_GENERATOR_X: Fq = Fq::from_raw([
0xc956_2d60_8f25_d51a,
0x692c_c760_9525_a7b2,
Expand Down Expand Up @@ -43,15 +45,17 @@ use crate::{
impl_binops_multiplicative, impl_binops_multiplicative_mixed, impl_sub_binop_specify_output,
};

#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "derive_serde", derive(Serialize, Deserialize))]
pub struct Ed25519 {
pub x: Fq,
pub y: Fq,
pub z: Fq,
pub t: Fq,
}

#[derive(Copy, Clone, Debug, PartialEq, Hash, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, PartialEq, Hash)]
#[cfg_attr(feature = "derive_serde", derive(Serialize, Deserialize))]
pub struct Ed25519Affine {
pub x: Fq,
pub y: Fq,
Expand Down
8 changes: 5 additions & 3 deletions src/ed25519/fq.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use core::convert::TryInto;
use core::fmt;
use core::ops::{Add, Mul, Neg, Sub};

use ff::{FromUniformBytes, PrimeField, WithSmallOrderMulGroup};
use rand::RngCore;
use serde::{Deserialize, Serialize};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "derive_serde")]
use serde::{Deserialize, Serialize};

use crate::arithmetic::{adc, mac, macx, sbb};

/// This represents an element of $\mathbb{F}_q$ where
Expand All @@ -17,7 +18,8 @@ use crate::arithmetic::{adc, mac, macx, sbb};
// The internal representation of this type is four 64-bit unsigned
// integers in little-endian order. `Fq` values are always in
// Montgomery form; i.e., Fq(a) = aR mod q, with R = 2^256.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "derive_serde", derive(Serialize, Deserialize))]
pub struct Fq(pub(crate) [u64; 4]);

/// Constant representing the modulus
Expand Down
8 changes: 5 additions & 3 deletions src/ed25519/fr.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use core::convert::TryInto;
use core::fmt;
use core::ops::{Add, Mul, Neg, Sub};

use ff::{FromUniformBytes, PrimeField, WithSmallOrderMulGroup};
use rand::RngCore;
use serde::{Deserialize, Serialize};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "derive_serde")]
use serde::{Deserialize, Serialize};

use crate::arithmetic::{adc, mac, macx, sbb};

/// This represents an element of $\mathbb{F}_q$ where
Expand All @@ -17,7 +18,8 @@ use crate::arithmetic::{adc, mac, macx, sbb};
// The internal representation of this type is four 64-bit unsigned
// integers in little-endian order. `Fr` values are always in
// Montgomery form; i.e., Fr(a) = aR mod r, with R = 2^256.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "derive_serde", derive(Serialize, Deserialize))]
pub struct Fr(pub(crate) [u64; 4]);

/// Constant representing the modulus
Expand Down

0 comments on commit 5cc2b9a

Please sign in to comment.