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

License contract test upgrade to zk_citadel 0.5.0 #1096

Merged
merged 1 commit into from
Oct 18, 2023
Merged
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
1 change: 1 addition & 0 deletions contracts/license/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
35 changes: 6 additions & 29 deletions contracts/license/tests/license.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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

Expand Down Expand Up @@ -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<DEPTH, ARITY>, 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<R: RngCore + CryptoRng>(
Expand Down Expand Up @@ -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::<LicenseCircuit>(&pp, LABEL)
.expect("Compiling circuit should succeed");
Expand Down Expand Up @@ -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,
Expand Down
Loading