From f49bb89f9fddb4d8a133c413dbf1245dcbe13d6d Mon Sep 17 00:00:00 2001 From: Milosz Muszynski Date: Wed, 18 Oct 2023 15:57:58 +0200 Subject: [PATCH] license-contract: upgraded use_license_get_session test and fixed pp --- contracts/license/Cargo.toml | 1 + contracts/license/tests/license.rs | 35 +++++------------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/contracts/license/Cargo.toml b/contracts/license/Cargo.toml index 3df483bb80..fd319071a1 100644 --- a/contracts/license/Cargo.toml +++ b/contracts/license/Cargo.toml @@ -24,6 +24,7 @@ rusk-abi = { version = "0.11", path = "../../rusk-abi" } [dev-dependencies] rusk-abi = { version = "0.11", path = "../../rusk-abi", default-features = false, features = ["host"] } +rusk-profile = { path = "../../rusk-profile" } license-circuits = { version = "0.1", path = "../../circuits/license" } rkyv = { version = "0.7", default-features = false } hex = "0.4" diff --git a/contracts/license/tests/license.rs b/contracts/license/tests/license.rs index fec8f8e075..695849082f 100644 --- a/contracts/license/tests/license.rs +++ b/contracts/license/tests/license.rs @@ -26,9 +26,9 @@ use license_types::*; use license_circuits::LicenseCircuit; use rusk_abi::{ContractData, ContractId, Session}; -use zk_citadel::license::{ - CitadelProverParameters, License, Request, SessionCookie, -}; +use rusk_profile::get_common_reference_string; +use zk_citadel::license::{License, Request}; +use zk_citadel::utils::CitadelUtils; const LICENSE_CONTRACT_ID: ContractId = { let mut bytes = [0u8; 32]; @@ -41,7 +41,6 @@ const TEST_OWNER: [u8; 32] = [0; 32]; const USER_ATTRIBUTES: u64 = 545072475273; static LABEL: &[u8] = b"dusk-network"; -const CAPACITY: usize = 17; // capacity required for the setup const DEPTH: usize = 17; // depth of the Merkle tree const ARITY: usize = 4; // arity of the Merkle tree @@ -103,29 +102,6 @@ fn find_owned_license( None } -/// Computes prover parameters and a session cookie -/// This function should be moved to CitadelUtils -fn compute_citadel_parameters( - rng: &mut StdRng, - ssk: SecretSpendKey, - psk_lp: PublicSpendKey, - lic: &License, - merkle_proof: Opening<(), DEPTH, ARITY>, -) -> (CitadelProverParameters, SessionCookie) { - const CHALLENGE: u64 = 20221126u64; - let c = JubJubScalar::from(CHALLENGE); - let (cpp, sc) = CitadelProverParameters::compute_parameters( - &ssk, - &lic, - &psk_lp, - &psk_lp, - &c, - rng, - merkle_proof, - ); - (cpp, sc) -} - /// Creates the Citadel request object /// This function should be moved to CitadelUtils fn create_request( @@ -326,7 +302,8 @@ fn use_license_get_session() { // PUB_PARAMS initialization code let rng = &mut StdRng::seed_from_u64(0xbeef); - let pp = PublicParameters::setup(1 << CAPACITY, rng).unwrap(); + let crs = get_common_reference_string().expect("getting CRS file works"); + let pp = unsafe { PublicParameters::from_slice_unchecked(crs.as_slice()) }; let (prover, verifier) = Compiler::compile::(&pp, LABEL) .expect("Compiling circuit should succeed"); @@ -397,7 +374,7 @@ fn use_license_get_session() { .expect("Querying the merkle opening should succeed") .data; - let (cpp, sc) = compute_citadel_parameters( + let (cpp, sc) = CitadelUtils::compute_citadel_parameters( rng, ssk_user, psk_lp,