Skip to content

Commit d5e8340

Browse files
authored
Couple rand core and zeroize (#171)
## What? 1) Couple `rand_core` and `zeroize` versions with re-exports from `elliptic_curve` (and re-export them). 2) Move `sha2` to private dependencies. ## Why? * Re-exporting `rand_core` and `zeroize` crates makes them more accessible for users of the library (so user of `elastic_elgamal` doesn't need to check which version of `rand_core`/`zeroize` is compatible). * This ensures that `elastic_elgamal` uses the same version of `rand_core` and `zeroize` as `elliptic-curve` crate. * Should decrease maintenance burden.
1 parent f6a7a03 commit d5e8340

28 files changed

+73
-40
lines changed

Cargo.lock

Lines changed: 21 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ rustdoc-args = ["--cfg", "docsrs"]
2626

2727
[dependencies]
2828
# Public dependencies (present in public API of the crate).
29-
elliptic-curve = { version = "=0.14.0-rc.16", features = ["sec1"] }
30-
rand_core = { version = "0.9.3", default-features = false }
31-
zeroize = { version = "1.8.2", default-features = false, features = ["alloc"] }
32-
sha2 = { version = "=0.11.0-rc.2", default-features = false }
29+
elliptic-curve = { version = "=0.14.0-rc.16", features = ["alloc", "sec1"] }
3330

3431
# Enables `Serialize` / `Deserialize` implementation for most types in the crate.
3532
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"], optional = true }
@@ -39,6 +36,7 @@ base64ct = { version = "1.8", default-features = false, features = ["alloc"] }
3936
hashbrown = { version = "0.16.0", optional = true }
4037
merlin = { version = "3.0.0", default-features = false }
4138
rand_chacha = { version = "0.9.0", default-features = false }
39+
sha2 = { version = "=0.11.0-rc.2", default-features = false }
4240
subtle = { version = "2.6.1", default-features = false }
4341

4442
# Crypto backend to support Curve25519 prime subgroup and Ristretto255 group;

benches/sharing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use elastic_elgamal::{
66
Keypair, ProofOfPossession,
77
group::{Curve25519Subgroup, Generic, Group, Ristretto},
88
};
9+
use elliptic_curve::rand_core::SeedableRng;
910
use merlin::Transcript;
1011
use rand_chacha::ChaChaRng;
11-
use rand_core::SeedableRng;
1212

1313
type K256 = Generic<k256::Secp256k1>;
1414

examples/equivalence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn upgrade_point(x: bulletproofs_curve::RistrettoPoint) -> curve25519_dalek::Ris
3131
#[derive(Debug)]
3232
struct CompatRng<R>(R);
3333

34-
impl<R: rand_core::RngCore> bulletproofs_rand_core::RngCore for CompatRng<R> {
34+
impl<R: elliptic_curve::rand_core::RngCore> bulletproofs_rand_core::RngCore for CompatRng<R> {
3535
fn next_u32(&mut self) -> u32 {
3636
self.0.next_u32()
3737
}
@@ -50,7 +50,7 @@ impl<R: rand_core::RngCore> bulletproofs_rand_core::RngCore for CompatRng<R> {
5050
}
5151
}
5252

53-
impl<R: rand_core::CryptoRng> bulletproofs_rand_core::CryptoRng for CompatRng<R> {}
53+
impl<R: elliptic_curve::rand_core::CryptoRng> bulletproofs_rand_core::CryptoRng for CompatRng<R> {}
5454

5555
fn main() {
5656
let mut rng = rand::rng();

examples/voting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ use elastic_elgamal::{
1515
group::{Generic, Group, Ristretto},
1616
sharing::{ActiveParticipant, Dealer, Params, PublicKeySet},
1717
};
18+
use elliptic_curve::rand_core::{CryptoRng, RngCore};
1819
use rand::{
1920
Rng,
2021
seq::{IndexedMutRandom, IteratorRandom},
2122
};
22-
use rand_core::{CryptoRng, RngCore};
2323

2424
type K256 = Generic<k256::Secp256k1>;
2525

src/app/choice.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
33
use core::{fmt, iter, ops};
44

5+
use elliptic_curve::{
6+
rand_core::{CryptoRng, RngCore},
7+
zeroize::Zeroizing,
8+
};
59
use merlin::Transcript;
6-
use rand_core::{CryptoRng, RngCore};
710
#[cfg(feature = "serde")]
811
use serde::{Deserialize, Serialize, de::DeserializeOwned};
9-
use zeroize::Zeroizing;
1012

1113
use crate::{
1214
Ciphertext, CiphertextWithValue, LogEqualityProof, PublicKey, RingProof, RingProofBuilder,

src/app/quadratic_voting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use core::fmt;
44

5+
use elliptic_curve::rand_core::{CryptoRng, RngCore};
56
use merlin::Transcript;
6-
use rand_core::{CryptoRng, RngCore};
77
#[cfg(feature = "serde")]
88
use serde::{Deserialize, Serialize};
99

src/decryption.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Verifiable decryption.
22
3+
use elliptic_curve::rand_core::{CryptoRng, RngCore};
34
use merlin::Transcript;
4-
use rand_core::{CryptoRng, RngCore};
55
#[cfg(feature = "serde")]
66
use serde::{Deserialize, Serialize};
77

src/dkg.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@
9898
9999
use core::fmt;
100100

101-
use rand_core::{CryptoRng, RngCore};
101+
use elliptic_curve::{
102+
rand_core::{CryptoRng, RngCore},
103+
zeroize::Zeroizing,
104+
};
102105
#[cfg(feature = "serde")]
103106
use serde::{Deserialize, Serialize};
104107
use sha2::{Digest, Sha256};
105-
use zeroize::Zeroizing;
106108

107109
#[cfg(feature = "serde")]
108110
use crate::serde::{ElementHelper, VecHelper};

src/encryption.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
33
use core::{fmt, marker::PhantomData, ops};
44

5-
use rand_core::{CryptoRng, RngCore};
5+
use elliptic_curve::{
6+
rand_core::{CryptoRng, RngCore},
7+
zeroize::{Zeroize, Zeroizing},
8+
};
69
#[cfg(feature = "serde")]
710
use serde::{Deserialize, Serialize};
8-
use zeroize::{Zeroize, Zeroizing};
911

1012
#[cfg(feature = "serde")]
1113
use crate::serde::ElementHelper;

0 commit comments

Comments
 (0)