diff --git a/rs/crypto/prng/src/lib.rs b/rs/crypto/prng/src/lib.rs index a2828dbfb34..251682e73a8 100644 --- a/rs/crypto/prng/src/lib.rs +++ b/rs/crypto/prng/src/lib.rs @@ -1,6 +1,6 @@ //! Offers cryptographically secure pseudorandom number generation (CSPRNG). use ic_crypto_sha2::{DomainSeparationContext, Sha256}; -use ic_types::consensus::{RandomBeacon, RandomTape}; +use ic_types::consensus::RandomBeacon; use ic_types::crypto::CryptoHashable; use ic_types::Randomness; use rand::{CryptoRng, Error, RngCore, SeedableRng}; @@ -54,14 +54,6 @@ impl Csprng { } } - /// Creates a CSPRNG seed from the given random tape. - /// - /// The returned seed can be used to create a CSPRNG with - /// `Csprng::from_seed_and_purpose`. - pub fn seed_from_random_tape(random_tape: &RandomTape) -> Randomness { - Csprng::seed_from_crypto_hashable(random_tape) - } - /// Creates a CSPRNG seed from the given crypto hashable. fn seed_from_crypto_hashable(crypto_hashable: &T) -> Randomness { let mut hasher = diff --git a/rs/crypto/prng/tests/tests.rs b/rs/crypto/prng/tests/tests.rs index a78aa91b2bc..9dd7c53ed9d 100644 --- a/rs/crypto/prng/tests/tests.rs +++ b/rs/crypto/prng/tests/tests.rs @@ -2,8 +2,8 @@ use ic_crypto_prng::RandomnessPurpose::{ BlockmakerRanking, CommitteeSampling, DkgCommitteeSampling, ExecutionThread, }; use ic_crypto_prng::{Csprng, RandomnessPurpose}; -use ic_types::consensus::{RandomBeacon, RandomTape}; -use ic_types::consensus::{RandomBeaconContent, RandomTapeContent}; +use ic_types::consensus::RandomBeacon; +use ic_types::consensus::RandomBeaconContent; use ic_types::crypto::{ CombinedThresholdSig, CombinedThresholdSigOf, CryptoHash, CryptoHashOf, Signed, }; @@ -62,23 +62,6 @@ fn should_produce_deterministic_randomness_from_seed_and_purpose() { assert_eq!(rng.next_u32(), 196_996_056); } -#[test] -fn should_produce_deterministic_randomness_from_seed_from_random_tape() { - fix_replica_version(); - - let random_tape = fake_random_tape(1); - - let randomness = Csprng::seed_from_random_tape(&random_tape); - - assert_eq!( - randomness.get(), - [ - 109, 145, 169, 77, 62, 78, 152, 146, 147, 81, 94, 181, 213, 81, 105, 131, 60, 109, 217, - 138, 33, 26, 94, 209, 110, 76, 228, 189, 126, 119, 13, 2 - ] - ); -} - #[test] fn should_offer_methods_of_rng_trait() { use rand::Rng; @@ -181,19 +164,6 @@ fn should_produce_different_randomness_for_different_execution_threads_for_rando assert_ne!(csprng1.next_u32(), csprng2.next_u32()); } -#[test] -fn should_produce_different_seeds_for_different_random_tapes() { - fix_replica_version(); - - let (tape_1, tape_2) = (random_tape(), random_tape_2()); - assert_ne!(tape_1, tape_2); - - let seed_1 = Csprng::seed_from_random_tape(&tape_1); - let seed_2 = Csprng::seed_from_random_tape(&tape_2); - - assert_ne!(seed_1, seed_2); -} - fn fake_random_beacon(height: u64) -> RandomBeacon { Signed { content: RandomBeaconContent::new( @@ -215,14 +185,6 @@ fn random_beacon_2() -> RandomBeacon { fake_random_beacon(2) } -fn random_tape() -> RandomTape { - fake_random_tape(1) -} - -fn random_tape_2() -> RandomTape { - fake_random_tape(2) -} - fn seed() -> Randomness { Randomness::new([123; 32]) } @@ -239,13 +201,3 @@ fn fake_dkg_id(h: u64) -> NiDkgId { target_subnet: NiDkgTargetSubnet::Local, } } - -fn fake_random_tape(height: u64) -> RandomTape { - Signed { - content: RandomTapeContent::new(Height::from(height)), - signature: ThresholdSignature { - signer: fake_dkg_id(0), - signature: CombinedThresholdSigOf::new(CombinedThresholdSig(vec![])), - }, - } -}