Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #232

Merged
merged 1 commit into from
Oct 11, 2023
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Update `dusk-bls12_381` to 0.12
- Update `dusk-jubjub` to 0.13
- Update `dusk-plonk` to 0.16
- Update `dusk-hades` to 0.22

## [0.30.1] - 2023-06-28

### Fixed
Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@ edition = "2021"
license = "MPL-2.0"

[dependencies]
dusk-bls12_381 = { version = "0.11", default-features = false }
dusk-jubjub = { version = "0.12", default-features = false }
dusk-bls12_381 = { version = "0.12", default-features = false }
dusk-jubjub = { version = "0.13", default-features = false }
dusk-bytes = "0.1"
dusk-hades = "0.21"
dusk-plonk = { version = "0.14", default-features = false, features = ["alloc"] }
dusk-hades = "0.22"
dusk-plonk = { version = "0.16", default-features = false, features = ["alloc"] }
rkyv = { version = "0.7", optional = true, default-features = false }
bytecheck = { version = "0.6", optional = true, default-features = false }

[dev-dependencies]
criterion = "0.3"
rand = { version = "0.8", default-features = false, features = ["getrandom", "std_rng"] }
ff = { version = "0.13", default-features = false }

[features]
default = [
"dusk-plonk/std",
"dusk-jubjub/std",
"dusk-jubjub/default",
"dusk-bls12_381/default",
"alloc",
]
Expand Down
14 changes: 8 additions & 6 deletions benches/cipher_decrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use dusk_poseidon::cipher::{self, PoseidonCipher};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dusk_jubjub::GENERATOR;
use dusk_plonk::prelude::*;
use ff::Field;
use rand::rngs::StdRng;
use rand::SeedableRng;

Expand All @@ -29,8 +30,9 @@ impl CipherDecrypt {
pub fn random(rng: &mut StdRng) -> Self {
let shared =
GENERATOR.to_niels().mul(&JubJubScalar::random(rng)).into();
let nonce = BlsScalar::random(rng);
let message = [BlsScalar::random(rng), BlsScalar::random(rng)];
let nonce = BlsScalar::random(&mut *rng);
let message =
[BlsScalar::random(&mut *rng), BlsScalar::random(&mut *rng)];
let cipher = PoseidonCipher::encrypt(&message, &shared, &nonce);

Self {
Expand Down Expand Up @@ -68,13 +70,13 @@ impl Circuit for CipherDecrypt {
fn bench_cipher_decryption(c: &mut Criterion) {
// Prepare benchmarks and initialize variables
let label = b"cipher decryption benchmark";
let rng = &mut StdRng::seed_from_u64(0xc001);
let pp = PublicParameters::setup(1 << CAPACITY, rng).unwrap();
let mut rng = StdRng::seed_from_u64(0xc001);
let pp = PublicParameters::setup(1 << CAPACITY, &mut rng).unwrap();
let (prover, verifier) = Compiler::compile::<CipherDecrypt>(&pp, label)
.expect("Circuit should compile successfully");
let mut proof = Proof::default();
let public_inputs = Vec::new();
let circuit = CipherDecrypt::random(rng);
let circuit = CipherDecrypt::random(&mut rng);

// Benchmark native cipher decryption
c.bench_function("cipher decryption native", |b| {
Expand All @@ -91,7 +93,7 @@ fn bench_cipher_decryption(c: &mut Criterion) {
c.bench_function("cipher decryption proof generation", |b| {
b.iter(|| {
(proof, _) = prover
.prove(rng, black_box(&circuit))
.prove(&mut rng, black_box(&circuit))
.expect("Proof generation should succeed");
})
});
Expand Down
14 changes: 8 additions & 6 deletions benches/cipher_encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use dusk_poseidon::cipher::{self, PoseidonCipher};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dusk_jubjub::GENERATOR;
use dusk_plonk::prelude::*;
use ff::Field;
use rand::rngs::StdRng;
use rand::SeedableRng;

Expand All @@ -28,8 +29,9 @@ impl CipherEncrypt {
pub fn random(rng: &mut StdRng) -> Self {
let shared =
GENERATOR.to_niels().mul(&JubJubScalar::random(rng)).into();
let nonce = BlsScalar::random(rng);
let message = [BlsScalar::random(rng), BlsScalar::random(rng)];
let nonce = BlsScalar::random(&mut *rng);
let message =
[BlsScalar::random(&mut *rng), BlsScalar::random(&mut *rng)];

Self {
shared,
Expand Down Expand Up @@ -65,13 +67,13 @@ impl Circuit for CipherEncrypt {
fn bench_cipher_encryption(c: &mut Criterion) {
// Prepare benchmarks and initialize variables
let label = b"cipher encryption benchmark";
let rng = &mut StdRng::seed_from_u64(0xc001);
let pp = PublicParameters::setup(1 << CAPACITY, rng).unwrap();
let mut rng = StdRng::seed_from_u64(0xc001);
let pp = PublicParameters::setup(1 << CAPACITY, &mut rng).unwrap();
let (prover, verifier) = Compiler::compile::<CipherEncrypt>(&pp, label)
.expect("Circuit should compile successfully");
let mut proof = Proof::default();
let public_inputs = Vec::new();
let circuit = CipherEncrypt::random(rng);
let circuit = CipherEncrypt::random(&mut rng);

// Benchmark native cipher encryption
c.bench_function("cipher encryption native", |b| {
Expand All @@ -88,7 +90,7 @@ fn bench_cipher_encryption(c: &mut Criterion) {
c.bench_function("cipher encryption proof generation", |b| {
b.iter(|| {
(proof, _) = prover
.prove(rng, black_box(&circuit))
.prove(&mut rng, black_box(&circuit))
.expect("Proof generation should succeed");
})
});
Expand Down
17 changes: 9 additions & 8 deletions benches/sponge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use dusk_hades::WIDTH;
use dusk_plonk::prelude::*;
use ff::Field;
use rand::rngs::StdRng;
use rand::SeedableRng;

Expand Down Expand Up @@ -46,18 +47,18 @@ impl Circuit for SpongeCircuit {
fn bench_sponge(c: &mut Criterion) {
// Prepare benchmarks and initialize variables
let label = b"sponge benchmark";
let rng = &mut StdRng::seed_from_u64(0xc10d);
let pp = PublicParameters::setup(1 << CAPACITY, rng).unwrap();
let mut rng = StdRng::seed_from_u64(0xc10d);
let pp = PublicParameters::setup(1 << CAPACITY, &mut rng).unwrap();
let (prover, verifier) = Compiler::compile::<SpongeCircuit>(&pp, label)
.expect("Circuit should compile successfully");
let mut proof = Proof::default();
let public_inputs = Vec::new();
let message = [
BlsScalar::random(rng),
BlsScalar::random(rng),
BlsScalar::random(rng),
BlsScalar::random(rng),
BlsScalar::random(rng),
BlsScalar::random(&mut rng),
BlsScalar::random(&mut rng),
BlsScalar::random(&mut rng),
BlsScalar::random(&mut rng),
BlsScalar::random(&mut rng),
];
let circuit = SpongeCircuit::new(message);

Expand All @@ -72,7 +73,7 @@ fn bench_sponge(c: &mut Criterion) {
c.bench_function("sponge proof generation", |b| {
b.iter(|| {
(proof, _) = prover
.prove(rng, black_box(&circuit))
.prove(&mut rng, black_box(&circuit))
.expect("Proof generation should succeed");
})
});
Expand Down
5 changes: 3 additions & 2 deletions src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
//! use dusk_jubjub::{dhke, JubJubExtended, JubJubScalar, GENERATOR};
//! use dusk_poseidon::cipher::PoseidonCipher;
//! use rand::rngs::OsRng;
//! use ff::Field;
//!
//! fn sender(
//! sender_secret: &JubJubScalar,
Expand Down Expand Up @@ -173,8 +174,8 @@ impl PoseidonCipher {
// The size of the message is constant because any absent input is
// replaced by zero
BlsScalar::from_raw([MESSAGE_CAPACITY as u64, 0, 0, 0]),
secret.get_x(),
secret.get_y(),
secret.get_u(),
secret.get_v(),
nonce,
]
}
Expand Down
1 change: 1 addition & 0 deletions src/perm_uses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub fn two_outputs(message: BlsScalar) -> [BlsScalar; 2] {
#[cfg(test)]
mod tests {
use super::*;
use ff::Field;
use rand::rngs::OsRng;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/sponge/truncated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ where
let h = sponge::gadget(composer, message);

// Truncate to 250 bits
composer.append_logic_xor(h, C::ZERO, 250)
composer.append_logic_xor::<125>(h, C::ZERO)
}
1 change: 1 addition & 0 deletions tests/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use dusk_jubjub::{
};
use dusk_plonk::error::Error as PlonkError;
use dusk_poseidon::cipher::{self, PoseidonCipher};
use ff::Field;
use rand::rngs::{OsRng, StdRng};
use rand::{RngCore, SeedableRng};

Expand Down
7 changes: 4 additions & 3 deletions tests/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use dusk_plonk::error::Error as PlonkError;
use dusk_plonk::prelude::*;
use dusk_poseidon::sponge;
use ff::Field;
use rand::rngs::StdRng;
use rand::SeedableRng;

Expand Down Expand Up @@ -51,15 +52,15 @@ impl Circuit for MerkleCircuit {

#[test]
fn merkle_sponge() -> Result<(), PlonkError> {
let mut rng = &mut StdRng::seed_from_u64(0xbeef);
let mut rng = StdRng::seed_from_u64(0xbeef);
let label = b"merkle-sponge-tester";
let pp = PublicParameters::setup(1 << MERKLE_CAPACITY, rng)?;
let pp = PublicParameters::setup(1 << MERKLE_CAPACITY, &mut rng)?;
let (prover, verifier) = Compiler::compile::<MerkleCircuit>(&pp, label)
.expect("Circuit should compile");

let mut input = [BlsScalar::zero(); A];
for scalar in input.iter_mut() {
*scalar = BlsScalar::random(rng);
*scalar = BlsScalar::random(&mut rng);
}
let expected_output = sponge::merkle::hash(&input);

Expand Down
25 changes: 13 additions & 12 deletions tests/sponge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use dusk_bls12_381::BlsScalar;
use dusk_bytes::ParseHexStr;
use dusk_plonk::error::Error as PlonkError;
use dusk_poseidon::sponge;
use ff::Field;
use rand::rngs::{OsRng, StdRng};
use rand::SeedableRng;

Expand Down Expand Up @@ -127,33 +128,33 @@ fn sponge_hash_test() {
.collect();

assert_eq!(
"0xe36f4ea9b858d5c85b02770823c7c5d8253c28787d17f283ca348b906dca8528",
format!("{:#x}", sponge::hash(&test_inputs[..3]))
"0x2885ca6d908b34ca83f2177d78283c25d8c5c7230877025bc8d558b8a94e6fe3",
format!("{:?}", sponge::hash(&test_inputs[..3]))
);

assert_eq!(
"0x75ea3265c80d07e608c1f363ea0b4394ff1fa1cbf50b43b14c880a5755f7f755",
format!("{:#x}", sponge::hash(&test_inputs[..4]))
"0x55f7f755570a884cb1430bf5cba11fff94430bea63f3c108e6070dc86532ea75",
format!("{:?}", sponge::hash(&test_inputs[..4]))
);

assert_eq!(
"0x533106a0980eff5b01f5ce63a6b0dd87328b318ac6aa600fc28b9a2ab9f88842",
format!("{:#x}", sponge::hash(&test_inputs[..5]))
"0x4288f8b92a9a8bc20f60aac68a318b3287ddb0a663cef5015bff0e98a0063153",
format!("{:?}", sponge::hash(&test_inputs[..5]))
);

assert_eq!(
"0x1a815864684fff47c4d279ee4c31ad964c9dc232734e08188554fa27d33e6731",
format!("{:#x}", sponge::hash(&test_inputs[..6]))
"0x31673ed327fa548518084e7332c29d4c96ad314cee79d2c447ff4f686458811a",
format!("{:?}", sponge::hash(&test_inputs[..6]))
);

assert_eq!(
"0xa8b936d057df818048e634254719d13970df22926c51e5190c916fcf13dfa25a",
format!("{:#x}", sponge::hash(&test_inputs[..8]))
"0x5aa2df13cf6f910c19e5516c9222df7039d119472534e6488081df57d036b9a8",
format!("{:?}", sponge::hash(&test_inputs[..8]))
);

assert_eq!(
"0x982934231a0410c86f9ed1daa46863a5ddae6d250670d27cb21d10739088e30b",
format!("{:#x}", sponge::hash(&test_inputs[..10]))
"0x0be3889073101db27cd27006256daedda56368a4dad19e6fc810041a23342998",
format!("{:?}", sponge::hash(&test_inputs[..10]))
);
}

Expand Down
Loading