Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ default = ["std"]

rand = ["dep:rand", "crypto-bigint/rand_core"]
serde = ["dep:serde", "crypto-bigint/serde"]
zeroize = ["dep:zeroize"]
zeroize = ["dep:zeroize", "crypto-bigint/zeroize"]

std = ["num-traits/std", "ark-std/std", "ark-ff/std", "serde/std", "rand/std", "zeroize/std"]
ark_std = ["dep:ark-std"]
Expand Down
17 changes: 11 additions & 6 deletions src/field/ark_ff_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,17 @@ impl<F: ArkWrappedField> UniformRand for ArkField<F> {
}
}

//
// Zeroize
//

#[cfg(feature = "zeroize")]
impl<F: ArkWrappedField> zeroize::Zeroize for ArkField<F> {
fn zeroize(&mut self) {
self.0.zeroize()
}
}

//
// Traits from ark-ff
//
Expand Down Expand Up @@ -492,12 +503,6 @@ impl<F: ArkWrappedField> AdditiveGroup for ArkField<F> {
const ZERO: Self = <Self as ConstZero>::ZERO;
}

impl<F: ArkWrappedField> zeroize::Zeroize for ArkField<F> {
fn zeroize(&mut self) {
self.0.zeroize()
}
}

impl<F: ArkWrappedField> ArkWrappedField for ArkField<F> {
type BasePrimeField = F::BasePrimeField;

Expand Down
17 changes: 11 additions & 6 deletions src/field/ark_ff_fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,17 @@ impl<P: FpConfig<N>, const N: usize> UniformRand for Fp<P, N> {
}
}

//
// Zeroize
//

#[cfg(feature = "zeroize")]
impl<P: FpConfig<N>, const N: usize> zeroize::Zeroize for Fp<P, N> {
fn zeroize(&mut self) {
self.0.zeroize()
}
}

//
// Traits from ark-ff
//
Expand Down Expand Up @@ -578,12 +589,6 @@ impl<P: FpConfig<N>, const N: usize> AdditiveGroup for Fp<P, N> {
const ZERO: Self = <Self as ConstZero>::ZERO;
}

impl<P: FpConfig<N>, const N: usize> zeroize::Zeroize for Fp<P, N> {
fn zeroize(&mut self) {
self.0.zeroize()
}
}

impl<P: FpConfig<N>, const N: usize> ArkWrappedField for Fp<P, N> {
type BasePrimeField = Self;

Expand Down
11 changes: 11 additions & 0 deletions src/field/crypto_bigint_boxed_monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,17 @@ impl PrimeField for BoxedMontyField {
}
}

//
// Zeroize
//

#[cfg(feature = "zeroize")]
impl zeroize::Zeroize for BoxedMontyField {
fn zeroize(&mut self) {
self.0.zeroize()
}
}

#[allow(clippy::arithmetic_side_effects, clippy::cast_lossless)]
#[cfg(test)]
mod tests {
Expand Down
17 changes: 11 additions & 6 deletions src/field/crypto_bigint_const_monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,17 @@ where
}
}

//
// Zeroize
//

#[cfg(feature = "zeroize")]
impl<Mod: Params<LIMBS>, const LIMBS: usize> zeroize::Zeroize for ConstMontyField<Mod, LIMBS> {
fn zeroize(&mut self) {
self.0.zeroize()
}
}

//
// Traits from crypto_bigint
//
Expand Down Expand Up @@ -644,12 +655,6 @@ impl<Mod: Params<LIMBS>, const LIMBS: usize> Retrieve for ConstMontyField<Mod, L
}
}

#[cfg(feature = "zeroize")]
impl<Mod: Params<LIMBS>, const LIMBS: usize> zeroize::DefaultIsZeroes
for ConstMontyField<Mod, LIMBS>
{
}

//
// Predefined fields of various sizes for convenience
//
Expand Down
11 changes: 11 additions & 0 deletions src/field/crypto_bigint_monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,17 @@ impl<const LIMBS: usize> PrimeField for MontyField<LIMBS> {
}
}

//
// Zeroize
//

#[cfg(feature = "zeroize")]
impl<const LIMBS: usize> zeroize::Zeroize for MontyField<LIMBS> {
fn zeroize(&mut self) {
self.0.zeroize()
}
}

//
// Predefined fields of various sizes for convenience
//
Expand Down
8 changes: 8 additions & 0 deletions src/ring/crypto_bigint_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ impl<const LIMBS: usize, const LIMBS2: usize> TryFrom<&crypto_bigint::Uint<LIMBS
Ok(result.unwrap().into())
}
}

//
// Semiring and Ring
//
Expand Down Expand Up @@ -634,6 +635,13 @@ where
}
}

//
// Zeroize
//

#[cfg(feature = "zeroize")]
impl<const LIMBS: usize> zeroize::DefaultIsZeroes for Int<LIMBS> {}

//
// Traits from crypto_bigint
//
Expand Down
7 changes: 7 additions & 0 deletions src/semiring/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ impl Distribution<Boolean> for StandardUniform {
}
}

//
// Zeroize
//

#[cfg(feature = "zeroize")]
impl zeroize::DefaultIsZeroes for Boolean {}

//
// Tests
//
Expand Down
7 changes: 7 additions & 0 deletions src/semiring/crypto_bigint_uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,13 @@ where
}
}

//
// Zeroize
//

#[cfg(feature = "zeroize")]
impl<const LIMBS: usize> zeroize::DefaultIsZeroes for Uint<LIMBS> {}

//
// Traits from crypto_bigint
//
Expand Down