Skip to content

Commit

Permalink
Merge pull request #77 from dusk-network/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies and changelog
  • Loading branch information
miloszm committed Oct 12, 2023
2 parents 53137b5 + 831f946 commit 6232a22
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 28 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- update `dusk-bls12_381` dependency to "0.12"
- update `dusk-jubjub` dependency to "0.13"
- update `dusk-pki` dependency to "0.13"
- update `dusk-schnorr` dependency to "0.14"
- update `dusk-poseidon` dependency to "0.31"
- update `poseidon-merkle` dependency to "0.3"
- update `dusk-plonk` dependency to "0.14"
- Removed pos field from the license struct
- Refactored utils to accept external license and opening

### Added

- Add `ff` dependency

## [0.4.1] - 2023-08-09

### Added
Expand Down
15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ license = "MPL-2.0"

[dependencies]
dusk-bytes = "0.1"
dusk-poseidon = { version = "0.30", default-features = false, features = ["rkyv-impl", "alloc"] }
poseidon-merkle = { version = "0.2", features = ["rkyv-impl", "zk", "size_32"] }
dusk-plonk = { version = "0.14", default-features = false, features = ["rkyv-impl", "alloc"] }
dusk-bls12_381 = { version = "0.11", default-features = false }
dusk-jubjub = { version = "0.12", default-features = false }
dusk-pki = { version = "0.12", default-features = false, features = ["rkyv-impl"] }
dusk-schnorr = { version = "0.13", features = ["rkyv-impl", "alloc"] }
dusk-poseidon = { version = "0.31", default-features = false, features = ["rkyv-impl", "alloc", "size_32", "merkle"] }
poseidon-merkle = { version = "0.3", features = ["rkyv-impl", "zk", "size_32"] }
dusk-plonk = { version = "0.16", default-features = false, features = ["rkyv-impl", "alloc"] }
dusk-bls12_381 = { version = "0.12", default-features = false, features = ["rkyv-impl", "alloc"] }
dusk-jubjub = { version = "0.13", default-features = false, features = ["rkyv-impl", "alloc"] }
ff = { version = "0.13", default-features = false }
dusk-pki = { version = "0.13", default-features = false, features = ["rkyv-impl"] }
dusk-schnorr = { version = "0.14", features = ["rkyv-impl", "alloc"] }
rand_core = { version = "0.6", default-features=false, features = ["getrandom"] }
nstack = { version = "0.16" }
rkyv = { version = "0.7", default-features = false }
Expand Down
41 changes: 21 additions & 20 deletions src/license.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use dusk_pki::{PublicKey, PublicSpendKey, SecretKey, SecretSpendKey, StealthAddr
use dusk_poseidon::cipher::PoseidonCipher;
use dusk_poseidon::sponge;
use dusk_schnorr::Signature;
use ff::Field;
use poseidon_merkle::{Item, Opening, Tree};
use rand_core::{CryptoRng, RngCore};

Expand Down Expand Up @@ -40,11 +41,11 @@ impl Request {
psk_lp: &PublicSpendKey,
lsa: &StealthAddress,
k_lic: &JubJubAffine,
rng: &mut R,
mut rng: &mut R,
) -> Self {
let nonce_1 = BlsScalar::random(rng);
let nonce_2 = BlsScalar::random(rng);
let nonce_3 = BlsScalar::random(rng);
let nonce_1 = BlsScalar::random(&mut rng);
let nonce_2 = BlsScalar::random(&mut rng);
let nonce_3 = BlsScalar::random(&mut rng);

let lpk = JubJubAffine::from(*lsa.pk_r().as_ref());
let r = JubJubAffine::from(*lsa.R());
Expand All @@ -53,11 +54,11 @@ impl Request {
let rsa = psk_lp.gen_stealth_address(&r_dh);
let k_dh = dhke(&r_dh, psk_lp.A());

let enc_1 = PoseidonCipher::encrypt(&[lpk.get_x(), lpk.get_y()], &k_dh, &nonce_1);
let enc_1 = PoseidonCipher::encrypt(&[lpk.get_u(), lpk.get_v()], &k_dh, &nonce_1);

let enc_2 = PoseidonCipher::encrypt(&[r.get_x(), r.get_y()], &k_dh, &nonce_2);
let enc_2 = PoseidonCipher::encrypt(&[r.get_u(), r.get_v()], &k_dh, &nonce_2);

let enc_3 = PoseidonCipher::encrypt(&[k_lic.get_x(), k_lic.get_y()], &k_dh, &nonce_3);
let enc_3 = PoseidonCipher::encrypt(&[k_lic.get_u(), k_lic.get_v()], &k_dh, &nonce_3);

Self {
rsa,
Expand Down Expand Up @@ -115,10 +116,10 @@ impl Session {
pub fn verify(&self, sc: SessionCookie, pk_lp: JubJubAffine) {
assert_eq!(pk_lp, sc.pk_lp);

let session_hash = sponge::hash(&[sc.pk_sp.get_x(), sc.pk_sp.get_y(), sc.r]);
let session_hash = sponge::hash(&[sc.pk_sp.get_u(), sc.pk_sp.get_v(), sc.r]);
assert_eq!(session_hash, self.session_hash);

let com_0 = sponge::hash(&[pk_lp.get_x(), pk_lp.get_y(), sc.s_0]);
let com_0 = sponge::hash(&[pk_lp.get_u(), pk_lp.get_v(), sc.s_0]);
assert_eq!(com_0, self.com_0);

let com_1 = (GENERATOR_EXTENDED * sc.attr) + (GENERATOR_NUMS_EXTENDED * sc.s_1);
Expand Down Expand Up @@ -168,7 +169,7 @@ impl License {
attr: &JubJubScalar,
ssk_lp: &SecretSpendKey,
req: &Request,
rng: &mut R,
mut rng: &mut R,
) -> Self {
let k_dh = dhke(ssk_lp.a(), req.rsa.R());

Expand All @@ -191,13 +192,13 @@ impl License {
let r = JubJubAffine::from_raw_unchecked(dec_2[0], dec_2[1]);
let k_lic = JubJubAffine::from_raw_unchecked(dec_3[0], dec_3[1]);

let message = sponge::hash(&[lpk.get_x(), lpk.get_y(), BlsScalar::from(*attr)]);
let message = sponge::hash(&[lpk.get_u(), lpk.get_v(), BlsScalar::from(*attr)]);

let sig_lic = Signature::new(&SecretKey::from(ssk_lp.a()), rng, message);
let sig_lic_r = JubJubAffine::from(sig_lic.R());

let nonce_1 = BlsScalar::random(rng);
let nonce_2 = BlsScalar::random(rng);
let nonce_1 = BlsScalar::random(&mut rng);
let nonce_2 = BlsScalar::random(&mut rng);

let enc_1 = PoseidonCipher::encrypt(
&[BlsScalar::from(*sig_lic.u()), BlsScalar::from(*attr)],
Expand All @@ -206,7 +207,7 @@ impl License {
);

let enc_2 =
PoseidonCipher::encrypt(&[sig_lic_r.get_x(), sig_lic_r.get_y()], &k_lic, &nonce_2);
PoseidonCipher::encrypt(&[sig_lic_r.get_u(), sig_lic_r.get_v()], &k_lic, &nonce_2);

Self {
lsa: StealthAddress::from_raw_unchecked(
Expand Down Expand Up @@ -274,7 +275,7 @@ impl<const DEPTH: usize, const ARITY: usize> CitadelProverParameters<DEPTH, ARIT
psk_lp: &PublicSpendKey,
psk_sp: &PublicSpendKey,
c: &JubJubScalar,
rng: &mut R,
mut rng: &mut R,
merkle_proof: Opening<(), DEPTH, ARITY>,
) -> (Self, SessionCookie) {
let lsk = ssk.sk_r(&lic.lsa);
Expand Down Expand Up @@ -309,22 +310,22 @@ impl<const DEPTH: usize, const ARITY: usize> CitadelProverParameters<DEPTH, ARIT
let lsk = ssk.sk_r(&lic.lsa);
let lpk_p = JubJubAffine::from(GENERATOR_NUMS_EXTENDED * lsk.as_ref());

let s_0 = BlsScalar::random(rng);
let s_0 = BlsScalar::random(&mut rng);
let s_1 = JubJubScalar::random(rng);
let s_2 = JubJubScalar::random(rng);

let pk_sp = JubJubAffine::from(*psk_sp.A());
let r = BlsScalar::random(rng);
let r = BlsScalar::random(&mut rng);

let session_hash = sponge::hash(&[pk_sp.get_x(), pk_sp.get_y(), r]);
let session_hash = sponge::hash(&[pk_sp.get_u(), pk_sp.get_v(), r]);

let sig_session_hash = dusk_schnorr::Proof::new(&lsk, rng, session_hash);

let session_id = sponge::hash(&[lpk_p.get_x(), lpk_p.get_y(), BlsScalar::from(*c)]);
let session_id = sponge::hash(&[lpk_p.get_u(), lpk_p.get_v(), BlsScalar::from(*c)]);

let pk_lp = JubJubAffine::from(*psk_lp.A());

let com_0 = sponge::hash(&[pk_lp.get_x(), pk_lp.get_y(), s_0]);
let com_0 = sponge::hash(&[pk_lp.get_u(), pk_lp.get_v(), s_0]);
let com_1 = (GENERATOR_EXTENDED * attr) + (GENERATOR_NUMS_EXTENDED * s_1);
let com_2 = (GENERATOR_EXTENDED * c) + (GENERATOR_NUMS_EXTENDED * s_2);

Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl CitadelUtils {
let lpk = JubJubAffine::from(lic.lsa.pk_r().as_ref());

let item = Item {
hash: sponge::hash(&[lpk.get_x(), lpk.get_y()]),
hash: sponge::hash(&[lpk.get_u(), lpk.get_v()]),
data: (),
};

Expand Down
1 change: 1 addition & 0 deletions tests/citadel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use dusk_pki::{PublicSpendKey, SecretSpendKey};
use dusk_plonk::prelude::*;
use ff::Field;

static LABEL: &[u8; 12] = b"dusk-network";

Expand Down

0 comments on commit 6232a22

Please sign in to comment.