From 66534f1f4c2115f259eb65f137d06f1d79e8e4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michele=20Orr=C3=B9?= Date: Mon, 16 Dec 2024 21:39:56 +0100 Subject: [PATCH] Revert updates to other packages. --- nimue-anemoi/Cargo.toml | 8 ++++---- nimue-anemoi/src/lib.rs | 1 + nimue-poseidon/Cargo.toml | 12 ++++++------ nimue-poseidon/src/lib.rs | 7 +++---- nimue-pow/Cargo.toml | 5 ++--- nimue-pow/src/blake3.rs | 7 +++---- nimue-pow/src/keccak.rs | 5 ++--- nimue-pow/src/lib.rs | 22 +++++++--------------- 8 files changed, 28 insertions(+), 39 deletions(-) diff --git a/nimue-anemoi/Cargo.toml b/nimue-anemoi/Cargo.toml index d010e0a..200a671 100644 --- a/nimue-anemoi/Cargo.toml +++ b/nimue-anemoi/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "nimue-anemoi" -version = "0.1.1" +version = "0.1.0" edition = "2021" license = "MIT/Apache-2.0" [dependencies] -ark-ff = "^0.4" +ark-ff = "^0.5" nimue = { path = "../nimue", features = ["ark"] } zeroize = "1.8.1" -anemoi = { git = "https://github.com/mmaker/anemoi", features=["bls12_381"], rev = "647c921c38f56ef7dbc0a3463f2cb1631873cebe"} -ark-bls12-381 = "^0.4" +anemoi = {git = "https://github.com/mmaker/anemoi", features=["bls12_381"]} +ark-bls12-381 = "^0.5" arrayvec = "0.7.6" diff --git a/nimue-anemoi/src/lib.rs b/nimue-anemoi/src/lib.rs index 07819be..3707711 100644 --- a/nimue-anemoi/src/lib.rs +++ b/nimue-anemoi/src/lib.rs @@ -2,6 +2,7 @@ //! //! The main reason for this code not being deployed is that [anemoi](https://anemoi-hash.github.io/)'s Rust implementation //! is not published as a crate and thus `nimue` cannot publish it along with a new release. +use anemoi; use ark_ff::{Field, PrimeField}; use zeroize::Zeroize; diff --git a/nimue-poseidon/Cargo.toml b/nimue-poseidon/Cargo.toml index fcd3b0d..8642ab2 100644 --- a/nimue-poseidon/Cargo.toml +++ b/nimue-poseidon/Cargo.toml @@ -1,18 +1,18 @@ [package] name = "nimue-poseidon" -version = "0.1.1" +version = "0.1.0" edition = "2021" license = "MIT/Apache-2.0" [dependencies] nimue = { path = "../nimue", features = ["ark"]} -ark-ff = "0.4.0" +ark-ff = "0.5.0" zeroize = "1.8.1" -ark-bls12-381 = {version = "^0.4", optional = true} -ark-bn254 = {version = "^0.4", optional = true} +ark-bls12-381 = {version = "^0.5", optional = true} +ark-bn254 = {version = "^0.5", optional = true} [dev-dependencies] -ark-bls12-381 = "0.4.0" +ark-bls12-381 = "0.5.0" [features] bls12-381 = ["ark-bls12-381"] @@ -21,4 +21,4 @@ solinas = [] [[example]] name = "schnorr_algebraic_hash" -required-features = ["ark", "ark-bls112-381"] +required-features = ["ark", "ark-bls112-381"] \ No newline at end of file diff --git a/nimue-poseidon/src/lib.rs b/nimue-poseidon/src/lib.rs index 3e356e0..fd1553e 100644 --- a/nimue-poseidon/src/lib.rs +++ b/nimue-poseidon/src/lib.rs @@ -53,12 +53,12 @@ impl PoseidonSpo // Full rounds apply the S Box (x^alpha) to every element of state if is_full_round { for elem in state { - *elem = elem.pow([self.alpha]); + *elem = elem.pow(&[self.alpha]); } } // Partial rounds apply the S Box (x^alpha) to just the first element of state else { - state[0] = state[0].pow([self.alpha]); + state[0] = state[0].pow(&[self.alpha]); } } @@ -69,7 +69,6 @@ impl PoseidonSpo }); } - #[allow(clippy::needless_range_loop)] fn apply_mds(&self, state: &mut [F]) { let mut new_state = [F::ZERO; N]; for i in 0..N { @@ -109,7 +108,7 @@ where fn permute(&mut self) { let full_rounds_over_2 = self.full_rounds / 2; - let mut state = self.state; + let mut state = self.state.clone(); for i in 0..full_rounds_over_2 { self.apply_ark(&mut state, i); self.apply_s_box(&mut state, true); diff --git a/nimue-pow/Cargo.toml b/nimue-pow/Cargo.toml index 5cd5b5a..550898a 100644 --- a/nimue-pow/Cargo.toml +++ b/nimue-pow/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nimue-pow" -version = "0.1.1" +version = "0.1.0" edition = "2021" authors = [ "Giacomo Fenzi ", @@ -14,8 +14,7 @@ blake3 = "1.5.4" keccak = { version = "0.1.4"} bytemuck = "1.17.1" rayon = { version = "1.10.0", optional = true } -rand = "0.8.5" [features] default = ["parallel"] -parallel = ["dep:rayon"] +parallel = ["dep:rayon"] \ No newline at end of file diff --git a/nimue-pow/src/blake3.rs b/nimue-pow/src/blake3.rs index fa448de..455abe0 100644 --- a/nimue-pow/src/blake3.rs +++ b/nimue-pow/src/blake3.rs @@ -74,7 +74,7 @@ impl PowStrategy for Blake3PoW { // Use atomics to find the unique deterministic lowest satisfying nonce. let global_min = AtomicU64::new(u64::MAX); let _ = broadcast(|ctx| { - let mut worker = *self; + let mut worker = self.clone(); let nonces = ((MAX_SIMD_DEGREE * ctx.index()) as u64..) .step_by(MAX_SIMD_DEGREE * ctx.num_threads()); for nonce in nonces { @@ -144,12 +144,11 @@ impl Blake3PoW { #[test] fn test_pow_blake3() { - use crate::{ByteIOPattern, ByteReader, ByteWriter, PoWChallenge, PoWIOPattern}; - use nimue::{DefaultHash, IOPattern}; + use crate::{ByteIOPattern, ByteReader, ByteWriter, IOPattern, PoWChallenge, PoWIOPattern}; const BITS: f64 = 10.0; - let iopattern = IOPattern::::new("the proof of work lottery 🎰") + let iopattern = IOPattern::new("the proof of work lottery 🎰") .add_bytes(1, "something") .challenge_pow("rolling dices"); diff --git a/nimue-pow/src/keccak.rs b/nimue-pow/src/keccak.rs index b5c37d4..29a010f 100644 --- a/nimue-pow/src/keccak.rs +++ b/nimue-pow/src/keccak.rs @@ -30,12 +30,11 @@ impl PowStrategy for KeccakPoW { #[test] fn test_pow_keccak() { - use crate::{ByteIOPattern, ByteReader, ByteWriter, PoWChallenge, PoWIOPattern}; - use nimue::{DefaultHash, IOPattern}; + use crate::{ByteIOPattern, ByteReader, ByteWriter, IOPattern, PoWChallenge, PoWIOPattern}; const BITS: f64 = 10.0; - let iopattern = IOPattern::::new("the proof of work lottery 🎰") + let iopattern = IOPattern::new("the proof of work lottery 🎰") .add_bytes(1, "something") .challenge_pow("rolling dices"); diff --git a/nimue-pow/src/lib.rs b/nimue-pow/src/lib.rs index 5b0c3a5..df26924 100644 --- a/nimue-pow/src/lib.rs +++ b/nimue-pow/src/lib.rs @@ -2,8 +2,8 @@ pub mod blake3; pub mod keccak; use nimue::{ - Arthur, ByteChallenges, ByteIOPattern, ByteReader, ByteWriter, DuplexHash, Merlin, ProofError, - ProofResult, Unit, + Arthur, ByteChallenges, ByteIOPattern, ByteReader, ByteWriter, IOPattern, Merlin, ProofError, + ProofResult, }; /// [`IOPattern`] for proof-of-work challenges. @@ -21,10 +21,7 @@ pub trait PoWIOPattern { fn challenge_pow(self, label: &str) -> Self; } -impl PoWIOPattern for IOPattern -where - IOPattern: ByteIOPattern, -{ +impl PoWIOPattern for IOPattern { fn challenge_pow(self, label: &str) -> Self { // 16 bytes challenge and 16 bytes nonce (that will be written) self.challenge_bytes(32, label).add_bytes(8, "pow-nonce") @@ -36,12 +33,9 @@ pub trait PoWChallenge { fn challenge_pow(&mut self, bits: f64) -> ProofResult<()>; } -impl PoWChallenge for Merlin +impl PoWChallenge for Merlin where - U: Unit, - H: DuplexHash, - R: rand::CryptoRng + rand::RngCore, - Merlin: ByteWriter + ByteChallenges, + Merlin: ByteWriter, { fn challenge_pow(&mut self, bits: f64) -> ProofResult<()> { let challenge = self.challenge_bytes()?; @@ -53,11 +47,9 @@ where } } -impl<'a, H, U> PoWChallenge for Arthur<'a, H, U> +impl<'a> PoWChallenge for Arthur<'a> where - U: Unit, - H: DuplexHash, - Arthur<'a, H, U>: ByteReader + ByteChallenges, + Arthur<'a>: ByteReader, { fn challenge_pow(&mut self, bits: f64) -> ProofResult<()> { let challenge = self.challenge_bytes()?;