From fee532dfe04fd54c35b482ab3879f16864aa8145 Mon Sep 17 00:00:00 2001 From: Milosz Muszynski Date: Thu, 12 Oct 2023 15:46:46 +0200 Subject: [PATCH 1/2] Update dependencies and changelog --- CHANGELOG.md | 8 ++++++++ Cargo.toml | 15 ++++++++------- src/license.rs | 41 +++++++++++++++++++++-------------------- src/utils.rs | 2 +- tests/citadel.rs | 1 + 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ac4ea6..78f2f73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ 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 @@ -16,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Add `ff` dependency - Add Utils implementation ## [0.4.0] - 2023-06-28 diff --git a/Cargo.toml b/Cargo.toml index 025247f..c503ae7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/license.rs b/src/license.rs index 29d7bb6..4ed80b1 100644 --- a/src/license.rs +++ b/src/license.rs @@ -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}; @@ -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()); @@ -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, @@ -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); @@ -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()); @@ -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)], @@ -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( @@ -274,7 +275,7 @@ impl CitadelProverParameters, ) -> (Self, SessionCookie) { let lsk = ssk.sk_r(&lic.lsa); @@ -309,22 +310,22 @@ impl CitadelProverParameters Date: Thu, 12 Oct 2023 15:52:35 +0200 Subject: [PATCH 2/2] Corrected CHANGELOG --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78f2f73..3269d0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,11 +19,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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 -- Add `ff` dependency - Add Utils implementation ## [0.4.0] - 2023-06-28