Skip to content

Commit

Permalink
Revert updates to other packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaker committed Dec 16, 2024
1 parent 13f992f commit 66534f1
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 39 deletions.
8 changes: 4 additions & 4 deletions nimue-anemoi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions nimue-anemoi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions nimue-poseidon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -21,4 +21,4 @@ solinas = []

[[example]]
name = "schnorr_algebraic_hash"
required-features = ["ark", "ark-bls112-381"]
required-features = ["ark", "ark-bls112-381"]
7 changes: 3 additions & 4 deletions nimue-poseidon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ impl<const NAME: u32, F: PrimeField, const R: usize, const N: usize> 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]);
}
}

Expand All @@ -69,7 +69,6 @@ impl<const NAME: u32, F: PrimeField, const R: usize, const N: usize> 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 {
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions nimue-pow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nimue-pow"
version = "0.1.1"
version = "0.1.0"
edition = "2021"
authors = [
"Giacomo Fenzi <[email protected]>",
Expand All @@ -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"]
7 changes: 3 additions & 4 deletions nimue-pow/src/blake3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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::<DefaultHash>::new("the proof of work lottery 🎰")
let iopattern = IOPattern::new("the proof of work lottery 🎰")
.add_bytes(1, "something")
.challenge_pow("rolling dices");

Expand Down
5 changes: 2 additions & 3 deletions nimue-pow/src/keccak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<DefaultHash>::new("the proof of work lottery 🎰")
let iopattern = IOPattern::new("the proof of work lottery 🎰")
.add_bytes(1, "something")
.challenge_pow("rolling dices");

Expand Down
22 changes: 7 additions & 15 deletions nimue-pow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -21,10 +21,7 @@ pub trait PoWIOPattern {
fn challenge_pow(self, label: &str) -> Self;
}

impl<IOPattern> 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")
Expand All @@ -36,12 +33,9 @@ pub trait PoWChallenge {
fn challenge_pow<S: PowStrategy>(&mut self, bits: f64) -> ProofResult<()>;
}

impl<H, U, R> PoWChallenge for Merlin<H, U, R>
impl PoWChallenge for Merlin
where
U: Unit,
H: DuplexHash<U>,
R: rand::CryptoRng + rand::RngCore,
Merlin<H, U, R>: ByteWriter + ByteChallenges,
Merlin: ByteWriter,
{
fn challenge_pow<S: PowStrategy>(&mut self, bits: f64) -> ProofResult<()> {
let challenge = self.challenge_bytes()?;
Expand All @@ -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<U>,
Arthur<'a, H, U>: ByteReader + ByteChallenges,
Arthur<'a>: ByteReader,
{
fn challenge_pow<S: PowStrategy>(&mut self, bits: f64) -> ProofResult<()> {
let challenge = self.challenge_bytes()?;
Expand Down

0 comments on commit 66534f1

Please sign in to comment.