Skip to content

Commit a685602

Browse files
committed
move code from the catalyst-voting crate to jorm-vote-tx
1 parent 8f8862c commit a685602

File tree

20 files changed

+540
-529
lines changed

20 files changed

+540
-529
lines changed

rust/catalyst-voting/benches/vote_protocol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)]
1313

1414
use catalyst_voting::{
15-
crypto::default_rng,
15+
crypto::rng::default_rng,
1616
vote_protocol::{
1717
committee::{ElectionPublicKey, ElectionSecretKey},
1818
tally::{

rust/catalyst-voting/src/crypto/ed25519/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ mod decoding;
55
use ed25519_dalek::{
66
ed25519::signature::Signer, Signature as Ed25519Signature, SigningKey, VerifyingKey,
77
};
8-
use rand_core::CryptoRngCore;
8+
9+
use crate::crypto::rng::rand_core::CryptoRngCore;
910

1011
/// `Ed25519` private key struct.
1112
#[must_use]

rust/catalyst-voting/src/crypto/group/ristretto255/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ use curve25519_dalek::{
1515
traits::Identity,
1616
RistrettoPoint,
1717
};
18-
use rand_core::CryptoRngCore;
1918

20-
use crate::crypto::hash::digest::{consts::U64, Digest};
19+
use crate::crypto::{
20+
hash::digest::{consts::U64, Digest},
21+
rng::rand_core::CryptoRngCore,
22+
};
2123

2224
/// Ristretto group scalar.
2325
#[derive(Debug, Clone, PartialEq, Eq)]
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
//! Crypto primitives which are used by voting protocol.
22
3-
// cspell: words Seedable
4-
5-
use rand_chacha::ChaCha8Rng;
6-
use rand_core::{CryptoRngCore, SeedableRng};
7-
83
pub mod babystep_giantstep;
94
pub mod ed25519;
105
pub mod elgamal;
116
pub mod group;
127
pub mod hash;
8+
pub mod rng;
139
pub mod zk_dl_equality;
1410
pub mod zk_unit_vector;
15-
16-
/// Default random number generator `rand_chacha::ChaCha8Rng`.
17-
#[must_use]
18-
pub fn default_rng() -> impl CryptoRngCore {
19-
ChaCha8Rng::from_entropy()
20-
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//! Random number generator objects.
2+
3+
// cspell: words Seedable
4+
5+
use rand_chacha::ChaCha8Rng;
6+
pub use rand_core;
7+
use rand_core::{CryptoRngCore, SeedableRng};
8+
9+
/// Default random number generator `rand_chacha::ChaCha8Rng`.
10+
#[must_use]
11+
#[allow(clippy::module_name_repetitions)]
12+
pub fn default_rng() -> impl CryptoRngCore {
13+
ChaCha8Rng::from_entropy()
14+
}

rust/catalyst-voting/src/crypto/zk_unit_vector/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ use std::ops::Mul;
1616

1717
use challenges::{calculate_first_challenge_hash, calculate_second_challenge_hash};
1818
use polynomial::{calculate_polynomial_val, generate_polynomial, Polynomial};
19-
use rand_core::CryptoRngCore;
2019
use randomness_announcements::{Announcement, BlindingRandomness, ResponseRandomness};
2120
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
2221
use utils::get_bit;
2322

2423
use crate::crypto::{
2524
elgamal::{encrypt, Ciphertext},
2625
group::{GroupElement, Scalar},
26+
rng::rand_core::CryptoRngCore,
2727
};
2828

2929
/// Unit vector proof struct

rust/catalyst-voting/src/crypto/zk_unit_vector/randomness_announcements.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
use std::ops::Mul;
66

7-
use rand_core::CryptoRngCore;
8-
9-
use crate::crypto::group::{GroupElement, Scalar};
7+
use crate::crypto::{
8+
group::{GroupElement, Scalar},
9+
rng::rand_core::CryptoRngCore,
10+
};
1011

1112
/// Randomness generated in the proof, used for the hiding property.
1213
#[derive(Clone, Debug, Eq, PartialEq)]

rust/catalyst-voting/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Voting primitives which are used among Catalyst ecosystem.
22
33
pub mod crypto;
4-
pub mod txs;
54
mod utils;
65
pub mod vote_protocol;

rust/catalyst-voting/src/txs/mod.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)