Skip to content

Commit

Permalink
Merge pull request #1091 from dusk-network/mocello/update-dep
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
moCello authored Oct 23, 2023
2 parents c1df7f9 + 259e249 commit a10a42c
Show file tree
Hide file tree
Showing 42 changed files with 272 additions and 240 deletions.
18 changes: 9 additions & 9 deletions circuits/license/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ edition = "2021"
[dependencies]
rand_core = "0.6"

dusk-bls12_381 = { version = "0.11", default-features = false, features = ["rkyv-impl"] }
dusk-bls12_381 = { version = "0.12", default-features = false, features = ["rkyv-impl"] }
dusk-bytes = "0.1"
dusk-jubjub = { version = "0.12", default-features = false, features = ["rkyv-impl"] }
dusk-pki = { version = "0.12", default-features = false, features = ["rkyv-impl"] }
dusk-poseidon = { version = "0.30", default-features = false, features = ["alloc"] }
dusk-plonk = { version = "0.14", default-features = false, features = ["rkyv-impl", "alloc"] }
dusk-schnorr = { version = "0.13", default-features = false, features = ["rkyv-impl"] }
phoenix-core = { version = "0.20.0-rc.0", features = ["alloc"] }
poseidon-merkle = { version = "0.2.1-rc.0", features = ["rkyv-impl"] }
zk-citadel = "0.4"
dusk-jubjub = { version = "0.13", default-features = false, features = ["rkyv-impl"] }
dusk-pki = { version = "0.13", default-features = false, features = ["rkyv-impl"] }
dusk-poseidon = { version = "0.31", default-features = false, features = ["alloc"] }
dusk-plonk = { version = "0.16", default-features = false, features = ["rkyv-impl", "alloc"] }
dusk-schnorr = { version = "0.14", default-features = false, features = ["rkyv-impl"] }
phoenix-core = { version = "0.21", features = ["alloc"] }
poseidon-merkle = { version = "0.3", features = ["rkyv-impl"] }
zk-citadel = "0.5"
hex = "0.4"

rusk-profile = { version = "0.6", path = "../../rusk-profile", optional = true }
Expand Down
11 changes: 9 additions & 2 deletions circuits/license/tests/prove_verify_license_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ fn prove_verify_license_circuit() {
let ssk_lp = SecretSpendKey::random(rng);
let psk_lp = ssk_lp.public_spend_key();

let (cpp, sc) =
CitadelUtils::compute_citadel_parameters::<StdRng, DEPTH, ARITY>(
let (lic, merkle_proof) =
CitadelUtils::compute_random_license::<StdRng, DEPTH, ARITY>(
rng, ssk, psk, ssk_lp, psk_lp,
);

let (cpp, sc) = CitadelUtils::compute_citadel_parameters::<
StdRng,
DEPTH,
ARITY,
>(rng, ssk, psk_lp, &lic, merkle_proof);

let circuit = LicenseCircuit::new(cpp, sc);

let (proof, public_inputs) = prover
Expand Down
2 changes: 1 addition & 1 deletion circuits/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
dusk-plonk = "0.14"
dusk-plonk = "0.16"
rand = "0.8"
once_cell = "1.13"
rusk-profile = { version = "0.6", path = "../../rusk-profile" }
Expand Down
37 changes: 3 additions & 34 deletions circuits/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,16 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use cargo_toml::{Dependency, Manifest};
use dusk_plonk::prelude::{Circuit, Compiler, PublicParameters};
use once_cell::sync::Lazy;
use rand::rngs::StdRng;
use rand::SeedableRng;
use dusk_plonk::prelude::{Circuit, Compiler};
use rusk_profile::{Circuit as CircuitProfile, Theme};
use std::io::{self, ErrorKind};
use tracing::{info, warn};
use tracing::info;
use tracing_subscriber::prelude::*;

pub static PUB_PARAMS: Lazy<PublicParameters> = Lazy::new(|| {
match rusk_profile::get_common_reference_string() {
Ok(buff) if rusk_profile::verify_common_reference_string(&buff) => unsafe {
PublicParameters::from_slice_unchecked(&buff[..])
},

_ => {
warn!(
"{} CRS due to cache miss",
Theme::default().warn("Building"),
);
let mut rng = StdRng::seed_from_u64(0xbeef);

let pp = PublicParameters::setup(1 << 17, &mut rng)
.expect("Cannot initialize Public Parameters");

rusk_profile::set_common_reference_string(pp.to_raw_var_bytes())
.expect("Unable to write the CRS");

pp
}
}
});

pub fn store_circuit<C>(name: Option<String>) -> io::Result<()>
where
C: Circuit,
{
// This force init is needed to check CRS and create it (if not available)
// See also: https://github.com/dusk-network/rusk/issues/767
Lazy::force(&PUB_PARAMS);

// enable tracing logs
let fmt_layer = tracing_subscriber::fmt::layer()
.without_time()
Expand All @@ -69,7 +38,7 @@ where
};

// compress circuit and prepare for storage
let compressed = Compiler::compress::<C>(&PUB_PARAMS).map_err(|e| {
let compressed = Compiler::compress::<C>().map_err(|e| {
io::Error::new(
ErrorKind::InvalidData,
format!("Plonk circuit couldn't be compressed: {e}"),
Expand Down
17 changes: 9 additions & 8 deletions circuits/transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ edition = "2021"
rand_core = "0.6"

dusk-bytes = "0.1"
dusk-bls12_381 = "0.11"
dusk-jubjub = "0.12"
dusk-plonk = "0.14"
dusk-poseidon = "0.30"
poseidon-merkle = { version = "0.2.1-rc.0", features = ["zk"] }
dusk-bls12_381 = "0.12"
dusk-jubjub = "0.13"
dusk-plonk = "0.16"
dusk-poseidon = "0.31"
poseidon-merkle = { version = "0.3", features = ["zk"] }
dusk-merkle = "0.5"
dusk-pki ="0.12"
dusk-schnorr = "0.13"
phoenix-core = { version = "0.20.0-rc.0", features = ["alloc"] }
dusk-pki ="0.13"
dusk-schnorr = "0.14"
phoenix-core = { version = "0.21", features = ["alloc"] }

rusk-profile = { version = "0.6", path = "../../rusk-profile", optional = true }
storage = { version = "0.1", path = "../storage", optional = true }

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

[features]
store = ["rusk-profile", "storage"]
Expand Down
7 changes: 2 additions & 5 deletions circuits/transfer/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<const I: usize, T, const H: usize, const A: usize>

// 2. commitment(Cc,cv,cb,64)
let crossover = JubJubAffine::from(self.crossover.value_commitment());
pi.extend([crossover.get_x(), crossover.get_y()]);
pi.extend([crossover.get_u(), crossover.get_v()]);

pi.push(BlsScalar::from(self.crossover.fee()));

Expand All @@ -252,7 +252,7 @@ impl<const I: usize, T, const H: usize, const A: usize>
for output in self.outputs().iter() {
let commitment =
JubJubAffine::from(output.note().value_commitment());
outputs.extend([commitment.get_x(), commitment.get_y()]);
outputs.extend([commitment.get_u(), commitment.get_v()]);
}

pi.extend(outputs);
Expand Down Expand Up @@ -359,7 +359,6 @@ where
witness.value_commitment,
witness.value,
witness.blinding_factor,
64,
)?;

let constraint =
Expand All @@ -379,7 +378,6 @@ where
commitment,
crossover.value,
crossover.blinding_factor,
64,
)?;

composer.assert_equal_constant(
Expand All @@ -403,7 +401,6 @@ where
commitment,
witness.value,
witness.blinding_factor,
64,
)?;

let constraint = Constraint::new()
Expand Down
4 changes: 2 additions & 2 deletions circuits/transfer/src/gadgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub fn commitment<C: Composer>(
p: WitnessPoint,
v: Witness,
b: Witness,
bits: usize,
) -> Result<(), Error> {
composer.component_range(v, bits);
const HALF_64: usize = 32;
composer.component_range::<HALF_64>(v);

let v = composer.component_mul_generator(v, GENERATOR_EXTENDED)?;
let b = composer.component_mul_generator(b, GENERATOR_NUMS_EXTENDED)?;
Expand Down
2 changes: 0 additions & 2 deletions circuits/transfer/src/send_to_contract_obfuscated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ impl Circuit for SendToContractObfuscatedCircuit {
crossover_commitment,
value,
crossover_blinder,
64,
)?;

// 2. commitment(Mc,Mv,Mb,64)
Expand All @@ -273,7 +272,6 @@ impl Circuit for SendToContractObfuscatedCircuit {
message_commitment,
value,
message_blinder,
64,
)?;

// 3. (pa,pb) := selectPair(Mx,I,Mp,Ms)
Expand Down
2 changes: 1 addition & 1 deletion circuits/transfer/src/send_to_contract_transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Circuit for SendToContractTransparentCircuit {
let _ = composer.append_public(self.message);

// 1. commitment(Cc,Cv,Cb,64)
gadgets::commitment(composer, commitment, value, blinder, 64)?;
gadgets::commitment(composer, commitment, value, blinder)?;

// 2. S == H(Cc,Cn,Cψ,Cv,A)
let mut s = [C::ZERO; MESSAGE_SIZE];
Expand Down
3 changes: 0 additions & 3 deletions circuits/transfer/src/withdraw_from_obfuscated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ impl Circuit for WithdrawFromObfuscatedCircuit {
input_commitment,
input_value,
input_blinder,
64,
)?;

// 2. commitment(Cc,Cv,Cb,64)
Expand All @@ -117,7 +116,6 @@ impl Circuit for WithdrawFromObfuscatedCircuit {
change_commitment,
change_value,
change_blinder,
64,
)?;

// 3. commitment(Oc,Ov,Ob,64)
Expand All @@ -126,7 +124,6 @@ impl Circuit for WithdrawFromObfuscatedCircuit {
output_commitment,
output_value,
output_blinder,
64,
)?;

// 4. (pa,pb) := selectPair(Cx,I,Cp,Cs)
Expand Down
2 changes: 1 addition & 1 deletion circuits/transfer/src/withdraw_from_transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Circuit for WithdrawFromTransparentCircuit {
// Circuit

// 1. commitment(Nc,Nv,Nb,64)
gadgets::commitment(composer, commitment, value, blinder, 64)?;
gadgets::commitment(composer, commitment, value, blinder)?;

Ok(())
}
Expand Down
33 changes: 17 additions & 16 deletions circuits/transfer/tests/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use transfer_circuits::{
ExecuteCircuitThreeTwo, ExecuteCircuitTwoTwo,
};

use ff::Field;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rand_core::{CryptoRng, RngCore};
Expand Down Expand Up @@ -147,18 +148,18 @@ pub fn create_test_circuit<const I: usize>(

#[test]
fn execute_1_2() {
let rng = &mut StdRng::seed_from_u64(424242u64);
let mut rng = StdRng::seed_from_u64(424242u64);

let tx_hash = BlsScalar::random(rng);
let tx_hash = BlsScalar::random(&mut rng);
for use_crossover in [true, false].iter() {
let circuit: ExecuteCircuitOneTwo =
create_test_circuit::<1>(rng, *use_crossover, tx_hash)
create_test_circuit::<1>(&mut rng, *use_crossover, tx_hash)
.expect("test circuit creation should pass");
let (prover, verifier) = load_keys("ExecuteCircuitOneTwo")
.expect("loading the keys should succeed");

let (proof, pi) = prover
.prove(rng, &circuit)
.prove(&mut rng, &circuit)
.expect("creating a proof should succeed");

verifier
Expand All @@ -169,18 +170,18 @@ fn execute_1_2() {

#[test]
fn execute_2_2() {
let rng = &mut StdRng::seed_from_u64(424242u64);
let mut rng = StdRng::seed_from_u64(424242u64);

let tx_hash = BlsScalar::random(rng);
let tx_hash = BlsScalar::random(&mut rng);
for use_crossover in [true, false].iter() {
let circuit: ExecuteCircuitTwoTwo =
create_test_circuit::<2>(rng, *use_crossover, tx_hash)
create_test_circuit::<2>(&mut rng, *use_crossover, tx_hash)
.expect("test circuit creation should pass");
let (prover, verifier) = load_keys("ExecuteCircuitTwoTwo")
.expect("loading the keys should succeed");

let (proof, pi) = prover
.prove(rng, &circuit)
.prove(&mut rng, &circuit)
.expect("creating a proof should succeed");

verifier
Expand All @@ -191,18 +192,18 @@ fn execute_2_2() {

#[test]
fn execute_3_2() {
let rng = &mut StdRng::seed_from_u64(424242u64);
let mut rng = StdRng::seed_from_u64(424242u64);

let tx_hash = BlsScalar::random(rng);
let tx_hash = BlsScalar::random(&mut rng);
for use_crossover in [true, false].iter() {
let circuit: ExecuteCircuitThreeTwo =
create_test_circuit::<3>(rng, *use_crossover, tx_hash)
create_test_circuit::<3>(&mut rng, *use_crossover, tx_hash)
.expect("test circuit creation should pass");
let (prover, verifier) = load_keys("ExecuteCircuitThreeTwo")
.expect("loading the keys should succeed");

let (proof, pi) = prover
.prove(rng, &circuit)
.prove(&mut rng, &circuit)
.expect("creating a proof should succeed");

verifier
Expand All @@ -213,18 +214,18 @@ fn execute_3_2() {

#[test]
fn execute_4_2() {
let rng = &mut StdRng::seed_from_u64(424242u64);
let mut rng = StdRng::seed_from_u64(424242u64);

let tx_hash = BlsScalar::random(rng);
let tx_hash = BlsScalar::random(&mut rng);
for use_crossover in [true, false].iter() {
let circuit: ExecuteCircuitFourTwo =
create_test_circuit::<4>(rng, *use_crossover, tx_hash)
create_test_circuit::<4>(&mut rng, *use_crossover, tx_hash)
.expect("test circuit creation should pass");
let (prover, verifier) = load_keys("ExecuteCircuitFourTwo")
.expect("loading the keys should succeed");

let (proof, pi) = prover
.prove(rng, &circuit)
.prove(&mut rng, &circuit)
.expect("creating a proof should succeed");

verifier
Expand Down
3 changes: 2 additions & 1 deletion circuits/transfer/tests/send_to_contract_obfuscated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use transfer_circuits::{
};

use dusk_pki::SecretSpendKey;
use ff::Field;
use phoenix_core::{Message, Note};
use rand::rngs::StdRng;
use rand::{CryptoRng, Rng, RngCore, SeedableRng};
Expand Down Expand Up @@ -43,7 +44,7 @@ fn create_random_circuit<R: RngCore + CryptoRng>(
let r = JubJubScalar::random(rng);
let message = Message::new(rng, &r, &m_psk, value);

let address = BlsScalar::random(rng);
let address = BlsScalar::random(&mut *rng);
let signature = SendToContractObfuscatedCircuit::sign(
rng, &c_ssk, &fee, &crossover, &message, &address,
);
Expand Down
3 changes: 2 additions & 1 deletion circuits/transfer/tests/send_to_contract_transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use transfer_circuits::SendToContractTransparentCircuit;

use dusk_pki::SecretSpendKey;
use ff::Field;
use phoenix_core::Note;
use rand::rngs::StdRng;
use rand::{CryptoRng, RngCore, SeedableRng};
Expand All @@ -19,7 +20,7 @@ use keys::load_keys;
fn create_random_circuit<R: RngCore + CryptoRng>(
rng: &mut R,
) -> SendToContractTransparentCircuit {
let address = BlsScalar::random(rng);
let address = BlsScalar::random(&mut *rng);
let value = rng.next_u64();

let ssk = SecretSpendKey::random(rng);
Expand Down
2 changes: 1 addition & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rand = { version = "0.8", default-features = false, features = ["std_rng"] }
tokio = { version = "1", features = ["full"] }
tracing-subscriber = "0.2"
tracing = "0.1"
dusk-bls12_381-sign = { version = "0.4" }
dusk-bls12_381-sign = { version = "0.5" }
sha3 = { version = "0.10" }
num-bigint = { version = "0.4.3", default-features = false }
hex = { version = "0.4.3" }
Expand Down
Loading

0 comments on commit a10a42c

Please sign in to comment.