Skip to content

Commit

Permalink
Derive zeroize::DefaultIsZeroes for all key types
Browse files Browse the repository at this point in the history
  • Loading branch information
moCello committed Feb 8, 2024
1 parent 02ebd03 commit 2950ede
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Change the implementation for hashing a slice of bytes into a BlsScalar to `BlsScalar::hash_to_scalar` [#3]
- Derive `zeroize::DefaultIsZeroes` for all key types [#5]

### Added

- Add `zeroize` depencency at version "1" [#5]

## [0.1.0] - 2024-01-08

Expand All @@ -18,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add initial commit, this package continues the development of [dusk-bls12_381-sign](https://github.com/dusk-network/bls12_381-sign/) at version `0.6.0` under the new name: `bls12_381-bls` and without the go related code.

<!-- ISSUES -->
[#5]: https://github.com/dusk-network/bls12_381-bls/issues/5
[#3]: https://github.com/dusk-network/bls12_381-bls/issues/3

<!-- VERSIONS -->
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ exclude = [
license = "MPL-2.0"

[dependencies]
dusk-bls12_381 = { version = "0.13", default-features = false, features = ["alloc", "pairings"] }
dusk-bls12_381 = { version = "0.13", default-features = false, features = ["alloc", "pairings", "zeroize"] }
dusk-bytes = "0.1"
rand_core = { version = "0.6", default-features = false }
rkyv = { version = "0.7", optional = true, default-features = false }
bytecheck = { version = "0.6", optional = true, default-features = false }
ff = { version = "0.13", default-features = false }
rayon = { version = "1.8", optional = true }
zeroize = "1"
zeroize = { version = "1", fetures = ["derive"] }

[dev-dependencies]
rand = { version = "0.8", default-features = false, features = ["std_rng"] }
Expand Down
3 changes: 2 additions & 1 deletion src/keys/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{Error, PublicKey, SecretKey};

use dusk_bls12_381::G2Projective;
use dusk_bytes::{Error as DuskBytesError, Serializable};
use zeroize::DefaultIsZeroes;

#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize, Serialize};
Expand All @@ -20,7 +21,7 @@ use rayon::prelude::*;
/// The public keys are aggregated in a rogue-key attack
/// resistant manner, by using the hash function defined
/// in the modified version of BLS.
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq, DefaultIsZeroes)]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Deserialize, Serialize),
Expand Down
3 changes: 2 additions & 1 deletion src/keys/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{Error, SecretKey, Signature};

use dusk_bls12_381::G2Affine;
use dusk_bytes::{Error as DuskBytesError, Serializable};
use zeroize::DefaultIsZeroes;

#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize, Serialize};
Expand All @@ -17,7 +18,7 @@ use rkyv::{Archive, Deserialize, Serialize};
/// The G2 element is constructed by multiplying a [`SecretKey`]
/// by `g2` (the base point of the G2 group).
/// Can be used for signature verification.
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq, DefaultIsZeroes)]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Deserialize, Serialize),
Expand Down
3 changes: 2 additions & 1 deletion src/keys/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ use dusk_bls12_381::BlsScalar;
use dusk_bytes::{Error as DuskBytesError, Serializable};
use ff::Field;
use rand_core::{CryptoRng, RngCore};
use zeroize::DefaultIsZeroes;

#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize, Serialize};

/// A BLS secret key, holding a BLS12-381 scalar inside.
/// Can be used for signing messages.
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq, DefaultIsZeroes)]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Deserialize, Serialize),
Expand Down
3 changes: 2 additions & 1 deletion src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ use crate::Error;

use dusk_bls12_381::{G1Affine, G1Projective};
use dusk_bytes::Serializable;
use zeroize::DefaultIsZeroes;

#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize, Serialize};

/// A BLS signature.
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq)]
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, DefaultIsZeroes)]
#[cfg_attr(
feature = "rkyv-impl",
derive(Archive, Deserialize, Serialize),
Expand Down

0 comments on commit 2950ede

Please sign in to comment.