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 to latest #1262

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 8 additions & 9 deletions circuits/license/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ edition = "2021"
[dependencies]
rand_core = "0.6"

dusk-bls12_381 = { version = "0.12", default-features = false, features = ["rkyv-impl"] }
dusk-bls12_381 = { version = "0.13", default-features = false, features = ["rkyv-impl"] }
dusk-bytes = "0.1"
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"
dusk-jubjub = { version = "0.14", default-features = false, features = ["rkyv-impl"] }
dusk-poseidon = { version = "0.33", default-features = false, features = ["alloc"] }
dusk-plonk = { version = "0.19", default-features = false, features = ["rkyv-impl", "alloc"] }
jubjub-schnorr = { version = "0.1", default-features = false, features = ["rkyv-impl"] }
phoenix-core = { version = "0.25.0-rc.0", features = ["alloc"] }
poseidon-merkle = { version = "0.5", features = ["rkyv-impl"] }
zk-citadel = "0.8"
hex = "0.4"

rusk-profile = { version = "0.6", path = "../../rusk-profile", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion circuits/license/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use dusk_plonk::error::Error as PlonkError;
use dusk_plonk::prelude::Error as PlonkError;

use std::str::ParseBoolError;
use std::{error, fmt, io};
Expand Down
5 changes: 1 addition & 4 deletions circuits/license/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ impl LicenseCircuit {
}

impl Circuit for LicenseCircuit {
fn circuit<C>(&self, composer: &mut C) -> Result<(), PlonkError>
where
C: Composer,
{
fn circuit(&self, composer: &mut Composer) -> Result<(), PlonkError> {
gadgets::use_license_citadel(composer, &self.lpp, &self.sc)?;
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions circuits/license/tests/prove_verify_license_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use dusk_pki::SecretSpendKey;
use dusk_plonk::prelude::*;
use license_circuits::{Error, LicenseCircuit, ARITY, DEPTH};
use phoenix_core::{PublicKey as PublicSpendKey, SecretKey as SecretSpendKey};

use rand::rngs::StdRng;
use rand::SeedableRng;
Expand Down Expand Up @@ -39,11 +39,11 @@ fn prove_verify_license_circuit() {

// user
let ssk = SecretSpendKey::random(rng);
let psk = ssk.public_spend_key();
let psk = PublicSpendKey::from(&ssk);

// license provider
let ssk_lp = SecretSpendKey::random(rng);
let psk_lp = ssk_lp.public_spend_key();
let psk_lp = PublicSpendKey::from(&ssk_lp);

let (lic, merkle_proof) =
CitadelUtils::compute_random_license::<StdRng, DEPTH, ARITY>(
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.16"
dusk-plonk = "0.19"
rand = "0.8"
once_cell = "1.13"
rusk-profile = { version = "0.6", path = "../../rusk-profile" }
Expand Down
4 changes: 2 additions & 2 deletions circuits/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use cargo_toml::{Dependency, Manifest};
use dusk_plonk::prelude::{Circuit, Compiler};
use dusk_plonk::prelude::Circuit;
use rusk_profile::{Circuit as CircuitProfile, Theme};
use std::io::{self, ErrorKind};
use tracing::info;
Expand Down Expand Up @@ -38,7 +38,7 @@ where
};

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

dusk-bytes = "0.1"
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-bls12_381 = "0.13"
dusk-jubjub = "0.14"
dusk-plonk = "0.19"
dusk-poseidon = "0.33"
poseidon-merkle = { version = "0.5", features = ["zk"] }
dusk-merkle = "0.5"
dusk-pki ="0.13"
dusk-schnorr = "0.14"
phoenix-core = { version = "0.21", features = ["alloc"] }
jubjub-schnorr = { version = "0.1", features = ["double"] }
phoenix-core = { version = "0.25.0-rc.0", 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 }
rusk-profile = { version = "0.6", path = "../../rusk-profile" }

[features]
store = ["rusk-profile", "storage"]
Expand Down
2 changes: 1 addition & 1 deletion circuits/transfer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use dusk_bytes::Error as BytesError;
use dusk_plonk::error::Error as PlonkError;
use dusk_plonk::prelude::Error as PlonkError;
use phoenix_core::Error as PhoenixError;

use std::str::ParseBoolError;
Expand Down
129 changes: 67 additions & 62 deletions circuits/transfer/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ use crate::{error::Error, gadgets};

use dusk_jubjub::{GENERATOR_EXTENDED, GENERATOR_NUMS_EXTENDED};
use dusk_merkle::Aggregate;
use dusk_pki::{Ownable, SecretSpendKey, ViewKey};
use dusk_poseidon::sponge;
use phoenix_core::{Crossover, Fee, Note};
use phoenix_core::{
Crossover, Fee, Note, Ownable, SecretKey as SecretSpendKey, ViewKey,
};
use poseidon_merkle::{Opening, Tree};
use rand_core::{CryptoRng, RngCore};

use dusk_plonk::error::Error as PlonkError;
use dusk_plonk::prelude::Error as PlonkError;
use dusk_plonk::prelude::*;

mod crossover;
Expand Down Expand Up @@ -104,7 +105,7 @@ impl<const I: usize, T, const H: usize, const A: usize>
let pk_r_p = GENERATOR_NUMS_EXTENDED * sk_r.as_ref();
let pk_r_p = pk_r_p.into();

let vk = ssk.view_key();
let vk = ViewKey::from(ssk);
let (value, blinding_factor) = Self::input_commitment(&vk, &note)?;

let pos = *note.pos();
Expand Down Expand Up @@ -296,10 +297,7 @@ impl<const I: usize, T, const H: usize, const A: usize>
where
T: Default + Clone + Aggregate<A>,
{
pub fn circuit<C: Composer>(
&self,
composer: &mut C,
) -> Result<(), PlonkError> {
pub fn circuit(&self, composer: &mut Composer) -> Result<(), PlonkError> {
if self.inputs.len() != I {
// TODO: change into InvalidCircuitSize error once plonk v0.15 is
// merged across the stack
Expand All @@ -317,55 +315,62 @@ where
let inputs = self
.inputs()
.iter()
.try_fold::<_, _, Result<Witness, Error>>(C::ZERO, |sum, input| {
let witness = input.to_witness(composer)?;

// 1.a opening(io,A,ih)
gadgets::merkle_opening(
composer,
input.branch(),
anchor,
witness.note_hash,
);

// 1.b ih == H(it,ic,in,ik,ir,ip,iψ)
let hash = witness.to_hash_inputs();
let hash = sponge::gadget(composer, &hash);
composer.assert_equal(witness.note_hash, hash);

// 1.c doubleSchnorrVerify(iσ,ik,T)
gadgets::schnorr_double_key_verify(
composer,
witness.schnorr_u,
witness.schnorr_r,
witness.schnorr_r_p,
witness.pk_r,
witness.pk_r_p,
tx_hash,
)?;

// 1.d n == H(ik',ip)
let n = [*witness.pk_r_p.x(), *witness.pk_r_p.y(), witness.pos];
let n = sponge::gadget(composer, &n);
composer.assert_equal_constant(
n,
BlsScalar::zero(),
Some(witness.nullifier),
);

// 1.e commitment(ic,iv,ib,64)
gadgets::commitment(
composer,
witness.value_commitment,
witness.value,
witness.blinding_factor,
)?;

let constraint =
Constraint::new().left(1).a(sum).right(1).b(witness.value);

Ok(composer.gate_add(constraint))
})
.try_fold::<_, _, Result<Witness, Error>>(
Composer::ZERO,
|sum, input| {
let witness = input.to_witness(composer)?;

// 1.a opening(io,A,ih)
gadgets::merkle_opening(
composer,
input.branch(),
anchor,
witness.note_hash,
);

// 1.b ih == H(it,ic,in,ik,ir,ip,iψ)
let hash = witness.to_hash_inputs();
let hash = sponge::gadget(composer, &hash);
composer.assert_equal(witness.note_hash, hash);

// 1.c doubleSchnorrVerify(iσ,ik,T)
gadgets::schnorr_double_key_verify(
composer,
witness.schnorr_u,
witness.schnorr_r,
witness.schnorr_r_p,
witness.pk_r,
witness.pk_r_p,
tx_hash,
)?;

// 1.d n == H(ik',ip)
let n =
[*witness.pk_r_p.x(), *witness.pk_r_p.y(), witness.pos];
let n = sponge::gadget(composer, &n);
composer.assert_equal_constant(
n,
BlsScalar::zero(),
Some(witness.nullifier),
);

// 1.e commitment(ic,iv,ib,64)
gadgets::commitment(
composer,
witness.value_commitment,
witness.value,
witness.blinding_factor,
)?;

let constraint = Constraint::new()
.left(1)
.a(sum)
.right(1)
.b(witness.value);

Ok(composer.gate_add(constraint))
},
)
.or(Err(PlonkError::CircuitInputsNotFound))?;

// 2. commitment(Cc,cv,cb,64)
Expand All @@ -387,7 +392,7 @@ where
);

// 3. ∀(o,v) ∈ O × V | O → V
let mut outputs = C::ZERO;
let mut outputs = Composer::ZERO;
for o in self.outputs.as_ref() {
let padded_output = CircuitOutput::pad();
let output: &CircuitOutput = o.as_ref().unwrap_or(&padded_output);
Expand Down Expand Up @@ -429,22 +434,22 @@ where
}

impl Circuit for ExecuteCircuitOneTwo {
fn circuit<C: Composer>(&self, composer: &mut C) -> Result<(), PlonkError> {
fn circuit(&self, composer: &mut Composer) -> Result<(), PlonkError> {
self.circuit(composer)
}
}
impl Circuit for ExecuteCircuitTwoTwo {
fn circuit<C: Composer>(&self, composer: &mut C) -> Result<(), PlonkError> {
fn circuit(&self, composer: &mut Composer) -> Result<(), PlonkError> {
self.circuit(composer)
}
}
impl Circuit for ExecuteCircuitThreeTwo {
fn circuit<C: Composer>(&self, composer: &mut C) -> Result<(), PlonkError> {
fn circuit(&self, composer: &mut Composer) -> Result<(), PlonkError> {
self.circuit(composer)
}
}
impl Circuit for ExecuteCircuitFourTwo {
fn circuit<C: Composer>(&self, composer: &mut C) -> Result<(), PlonkError> {
fn circuit(&self, composer: &mut Composer) -> Result<(), PlonkError> {
self.circuit(composer)
}
}
5 changes: 1 addition & 4 deletions circuits/transfer/src/execute/crossover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ impl CircuitCrossover {
&self.value_commitment
}

pub fn to_witness<C: Composer>(
&self,
composer: &mut C,
) -> WitnessCrossover {
pub fn to_witness(&self, composer: &mut Composer) -> WitnessCrossover {
let value_commitment = self.value_commitment;

let fee_value = BlsScalar::from(self.fee);
Expand Down
7 changes: 3 additions & 4 deletions circuits/transfer/src/execute/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// Copyright (c) DUSK NETWORK. All rights reserved.

use dusk_merkle::Aggregate;
use dusk_pki::{Ownable, PublicSpendKey};
use phoenix_core::{Note, NoteType};
use phoenix_core::{Note, NoteType, Ownable, PublicKey as PublicSpendKey};
use poseidon_merkle::{Item, Opening, Tree};

use dusk_plonk::prelude::*;
Expand Down Expand Up @@ -69,9 +68,9 @@ impl<T, const H: usize, const A: usize> CircuitInput<T, H, A> {
&self.nullifier
}

pub fn to_witness<C: Composer>(
pub fn to_witness(
&self,
composer: &mut C,
composer: &mut Composer,
) -> Result<WitnessInput, Error> {
let nullifier = self.nullifier;

Expand Down
12 changes: 5 additions & 7 deletions circuits/transfer/src/execute/input/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use dusk_pki::{Ownable, SecretKey, SecretSpendKey};
use dusk_schnorr::Proof as SchnorrProof;
use phoenix_core::Note;
use jubjub_schnorr::{SecretKey, SignatureDouble as SchnorrProof};
use phoenix_core::{Note, Ownable, SecretKey as SecretSpendKey};
use rand_core::{CryptoRng, RngCore};

use dusk_plonk::prelude::*;
Expand All @@ -27,8 +26,8 @@ impl From<SchnorrProof> for CircuitInputSignature {
impl From<&SchnorrProof> for CircuitInputSignature {
fn from(p: &SchnorrProof) -> Self {
let u = *p.u();
let r = p.keys().R().as_ref().into();
let r_p = p.keys().R_prime().as_ref().into();
let r = p.R().into();
let r_p = p.R_prime().into();

Self { u, r, r_p }
}
Expand All @@ -51,8 +50,7 @@ impl CircuitInputSignature {
) -> Self {
let sk_r = *ssk.sk_r(note.stealth_address()).as_ref();
let sk_r = SecretKey::from(&sk_r);

let proof = SchnorrProof::new(&sk_r, rng, tx_hash);
let proof = sk_r.sign_double(rng, tx_hash);

Self::from(proof)
}
Expand Down
Loading
Loading