Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Set MSRV to 1.85, Rust edition 2024, and switch to stable toolchain [#274]
- Update `dusk-plonk` to `0.22.0-rc.0`

## [0.41.0] - 2025-02-06

### Changed
Expand Down Expand Up @@ -522,6 +527,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Variants of sponge for `Scalar` & `Gadget(Variable/LC)`.

<!-- ISSUES -->
[#274]: https://github.com/dusk-network/poseidon252/issues/274
[#260]: https://github.com/dusk-network/poseidon252/issues/260
[#259]: https://github.com/dusk-network/poseidon252/issues/259
[#251]: https://github.com/dusk-network/poseidon252/issues/251
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ categories = ["algorithms", "cryptography", "no-std", "wasm"]
keywords = ["cryptography", "zero-knowledge", "crypto"]

repository = "https://github.com/dusk-network/poseidon252"
edition = "2021"
edition = "2024"
rust-version = "1.85"
license = "MPL-2.0"

[dependencies]
dusk-bls12_381 = { version = "0.14", default-features = false, features = ["zeroize"] }
dusk-jubjub = { version = "0.15", default-features = false }
dusk-plonk = { version = "0.21", default-features = false, features = ["alloc", "zeroize"], optional = true }
dusk-plonk = { version = "0.22.0-rc.0", default-features = false, features = ["alloc", "zeroize"], optional = true }
dusk-safe = "0.3"

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions benches/decrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use dusk_bls12_381::BlsScalar;
use dusk_jubjub::{JubJubAffine, JubJubScalar, GENERATOR_EXTENDED};
use dusk_jubjub::{GENERATOR_EXTENDED, JubJubAffine, JubJubScalar};
use dusk_plonk::prelude::Error as PlonkError;
use dusk_plonk::prelude::*;
use dusk_poseidon::{decrypt, decrypt_gadget, encrypt};
use ff::Field;
use once_cell::sync::Lazy;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand::rngs::StdRng;

const MESSAGE_LEN: usize = 2;

Expand Down
6 changes: 3 additions & 3 deletions benches/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use dusk_bls12_381::BlsScalar;
use dusk_jubjub::{JubJubAffine, JubJubScalar, GENERATOR_EXTENDED};
use dusk_jubjub::{GENERATOR_EXTENDED, JubJubAffine, JubJubScalar};
use dusk_plonk::prelude::Error as PlonkError;
use dusk_plonk::prelude::*;
use dusk_poseidon::{encrypt, encrypt_gadget};
use ff::Field;
use once_cell::sync::Lazy;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand::rngs::StdRng;

const MESSAGE_LEN: usize = 2;

Expand Down
6 changes: 3 additions & 3 deletions benches/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use dusk_plonk::prelude::*;
use dusk_poseidon::{Domain, Hash, HashGadget, HADES_WIDTH};
use dusk_poseidon::{Domain, HADES_WIDTH, Hash, HashGadget};
use ff::Field;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand::rngs::StdRng;

const CAPACITY: usize = 11;

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-11-10"
channel = "stable"
components = ["rustfmt", "clippy"]
1 change: 0 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
wrap_comments = true
max_width = 80
36 changes: 18 additions & 18 deletions src/hades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,33 +133,33 @@ mod tests {
.collect();

assert_eq!(
"0x26abf2d0476f154e69bf19740092fe36265680c294462b8e759ad73a99567dd5",
format!("{:?}", create_poseidon_hash(&test_inputs[..3]))
);
"0x26abf2d0476f154e69bf19740092fe36265680c294462b8e759ad73a99567dd5",
format!("{:?}", create_poseidon_hash(&test_inputs[..3]))
);

assert_eq!(
"0x1cc40219c7ec92919d6db7a41cd41953333a2ed544606daca182e4eaa6c7db2d",
format!("{:?}", create_poseidon_hash(&test_inputs[..4]))
);
"0x1cc40219c7ec92919d6db7a41cd41953333a2ed544606daca182e4eaa6c7db2d",
format!("{:?}", create_poseidon_hash(&test_inputs[..4]))
);

assert_eq!(
"0x707c98a0e9a6e4832ac33ee08811bce122017a58dbbbf66a2f6fcdc69d45462d",
format!("{:?}", create_poseidon_hash(&test_inputs[..5]))
);
"0x707c98a0e9a6e4832ac33ee08811bce122017a58dbbbf66a2f6fcdc69d45462d",
format!("{:?}", create_poseidon_hash(&test_inputs[..5]))
);

assert_eq!(
"0x26905a794d3d2fb0c3ed2276abc696c27a5bfdea7f106e596cbeedd86891c461",
format!("{:?}", create_poseidon_hash(&test_inputs[..6]))
);
"0x26905a794d3d2fb0c3ed2276abc696c27a5bfdea7f106e596cbeedd86891c461",
format!("{:?}", create_poseidon_hash(&test_inputs[..6]))
);

assert_eq!(
"0x1b98a2c5f1fe54d21b5ce9bf0dcc99ea8784a64f3c544fa06d3f73569741006e",
format!("{:?}", create_poseidon_hash(&test_inputs[..8]))
);
"0x1b98a2c5f1fe54d21b5ce9bf0dcc99ea8784a64f3c544fa06d3f73569741006e",
format!("{:?}", create_poseidon_hash(&test_inputs[..8]))
);

assert_eq!(
"0x211b7ea21c9afca93dabdfbda8b2d5275b2dd802fed87bb431e98557c61667d2",
format!("{:?}", create_poseidon_hash(&test_inputs[..10]))
);
"0x211b7ea21c9afca93dabdfbda8b2d5275b2dd802fed87bb431e98557c61667d2",
format!("{:?}", create_poseidon_hash(&test_inputs[..10]))
);
}
}
4 changes: 2 additions & 2 deletions src/hades/permutation/gadget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<'a> Safe<Witness, WIDTH> for GadgetPermutation<'a> {
}

fn tag(&mut self, input: &[u8]) -> Witness {
let tag = BlsScalar::hash_to_scalar(input.as_ref());
let tag = BlsScalar::hash_to_scalar(input);
// append the tag as a constant
self.composer.append_constant(tag)
}
Expand Down Expand Up @@ -159,8 +159,8 @@ mod tests {

use core::result::Result;
use ff::Field;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand::rngs::StdRng;

#[derive(Default)]
struct TestCircuit {
Expand Down
2 changes: 1 addition & 1 deletion src/hades/permutation/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Safe<BlsScalar, WIDTH> for ScalarPermutation {
}

fn tag(&mut self, input: &[u8]) -> BlsScalar {
BlsScalar::hash_to_scalar(input.as_ref())
BlsScalar::hash_to_scalar(input)
}

fn add(&mut self, right: &BlsScalar, left: &BlsScalar) -> BlsScalar {
Expand Down
4 changes: 3 additions & 1 deletion src/hades/round_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ pub const ROUND_CONSTANTS: [[BlsScalar; WIDTH]; ROUNDS] = {
// make sure that there are enough bytes for (WIDTH * ROUNDS) BlsScalar
// stored under 'assets/arc.bin'
if bytes.len() < WIDTH * ROUNDS * 32 {
panic!("There are not enough round constants stored in 'assets/arc.bin', have a look at the HOWTO to generate enough constants.");
panic!(
"There are not enough round constants stored in 'assets/arc.bin', have a look at the HOWTO to generate enough constants."
);
}

let mut cnst = [[BlsScalar::zero(); WIDTH]; ROUNDS];
Expand Down
2 changes: 1 addition & 1 deletion src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use dusk_bls12_381::BlsScalar;
use dusk_jubjub::JubJubScalar;
use dusk_safe::{Call, Sponge};

use crate::hades::ScalarPermutation;
use crate::Error;
use crate::hades::ScalarPermutation;

#[cfg(feature = "zk")]
pub(crate) mod gadget;
Expand Down
2 changes: 1 addition & 1 deletion src/hash/gadget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use alloc::vec::Vec;
use dusk_plonk::prelude::{Composer, Witness};
use dusk_safe::Sponge;

use crate::hades::GadgetPermutation;
use crate::Domain;
use crate::hades::GadgetPermutation;

use super::io_pattern;

Expand Down
6 changes: 3 additions & 3 deletions tests/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#![cfg(feature = "encryption")]

use dusk_bls12_381::BlsScalar;
use dusk_jubjub::{JubJubAffine, JubJubScalar, GENERATOR_EXTENDED};
use dusk_poseidon::{decrypt, encrypt, Error};
use dusk_jubjub::{GENERATOR_EXTENDED, JubJubAffine, JubJubScalar};
use dusk_poseidon::{Error, decrypt, encrypt};
use ff::Field;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand::rngs::StdRng;

fn encryption_variables(
rng: &mut StdRng,
Expand Down
4 changes: 2 additions & 2 deletions tests/encryption_gadget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#![cfg(feature = "zk")]

use dusk_bls12_381::BlsScalar;
use dusk_jubjub::{JubJubAffine, JubJubScalar, GENERATOR_EXTENDED};
use dusk_jubjub::{GENERATOR_EXTENDED, JubJubAffine, JubJubScalar};
use dusk_plonk::prelude::Error as PlonkError;
use dusk_plonk::prelude::*;
use dusk_poseidon::{decrypt_gadget, encrypt, encrypt_gadget};
use ff::Field;
use once_cell::sync::Lazy;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand::rngs::StdRng;

static PUB_PARAMS: Lazy<PublicParameters> = Lazy::new(|| {
let mut rng = StdRng::seed_from_u64(0xfab);
Expand Down
2 changes: 1 addition & 1 deletion tests/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#![cfg(feature = "zk")]

use once_cell::sync::Lazy;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand::rngs::StdRng;

use dusk_plonk::prelude::Error as PlonkError;
use dusk_plonk::prelude::*;
Expand Down