fix build issues

This commit is contained in:
Jędrzej Stuczyński
2024-07-25 17:50:19 +01:00
parent 06fca9bd1f
commit 68b61bfa84
8 changed files with 43 additions and 17 deletions
@@ -4,7 +4,6 @@
use criterion::{criterion_group, criterion_main, Criterion};
use itertools::izip;
use nym_compact_ecash::identify::{identify, IdentifyResult};
use nym_compact_ecash::scheme::expiration_date_signatures::date_scalar;
use nym_compact_ecash::scheme::keygen::SecretKeyAuth;
use nym_compact_ecash::setup::Parameters;
use nym_compact_ecash::tests::helpers::{
@@ -15,6 +14,7 @@ use nym_compact_ecash::{
ttp_keygen, withdrawal_request, PartialWallet, PayInfo, PublicKeyUser, SecretKeyUser,
VerificationKeyAuth,
};
use nym_network_defaults::TicketTypeRepr;
use rand::seq::SliceRandom;
struct BenchCase {
@@ -30,13 +30,14 @@ fn bench_compact_ecash(c: &mut Criterion) {
// group.sample_size(300);
// group.measurement_time(Duration::from_secs(1500));
let expiration_date = 1703721600; // Dec 28 2023
let spend_date = 1701907200; // Dec 07 2023
let spend_date = 1701907200; // Dec 07 2023 00:00:00
let expiration_date = 1702166400; // Dec 10 2023 00:00:00
let encoded_ticket_type = TicketTypeRepr::default() as u8;
let case = BenchCase {
num_authorities: 100,
threshold_p: 0.7,
ll: 1000,
ll: 50,
spend_vv: 1,
case_nr_pub_keys: 99,
};
@@ -83,7 +84,12 @@ fn bench_compact_ecash(c: &mut Criterion) {
.unwrap();
// ISSUANCE PHASE
let (req, req_info) = withdrawal_request(user_keypair.secret_key(), expiration_date).unwrap();
let (req, req_info) = withdrawal_request(
user_keypair.secret_key(),
expiration_date,
encoded_ticket_type,
)
.unwrap();
// CLIENT BENCHMARK: prepare a single withdrawal request
group.bench_function(
@@ -91,7 +97,16 @@ fn bench_compact_ecash(c: &mut Criterion) {
"[Client] withdrawal_request_{}_authorities_{}_L_{}_threshold",
case.num_authorities, case.ll, case.threshold_p,
),
|b| b.iter(|| withdrawal_request(user_keypair.secret_key(), expiration_date).unwrap()),
|b| {
b.iter(|| {
withdrawal_request(
user_keypair.secret_key(),
expiration_date,
encoded_ticket_type,
)
.unwrap()
})
},
);
// ISSUING AUTHRORITY BENCHMARK: Benchmark the issue function
@@ -110,6 +125,7 @@ fn bench_compact_ecash(c: &mut Criterion) {
user_keypair.public_key(),
&req,
expiration_date,
encoded_ticket_type,
)
})
},
@@ -122,6 +138,7 @@ fn bench_compact_ecash(c: &mut Criterion) {
user_keypair.public_key(),
&req,
expiration_date,
encoded_ticket_type,
);
wallet_blinded_signatures.push(blind_signature.unwrap());
}
@@ -223,7 +240,7 @@ fn bench_compact_ecash(c: &mut Criterion) {
|b| {
b.iter(|| {
payment
.spend_verify(&verification_key, &pay_info, date_scalar(spend_date))
.spend_verify(&verification_key, &pay_info, spend_date)
.unwrap()
})
},
+3 -1
View File
@@ -64,6 +64,7 @@ mod tests {
};
use nym_credentials::ecash::utils::EcashTime;
use nym_credentials::IssuanceTicketBook;
use nym_credentials_interface::TicketType;
use nym_crypto::asymmetric::ed25519;
use rand::rngs::OsRng;
@@ -75,7 +76,7 @@ mod tests {
let mut rng = OsRng;
let signing_key = ed25519::PrivateKey::new(&mut rng);
let issuance = IssuanceTicketBook::new(42, [], signing_key);
let issuance = IssuanceTicketBook::new(42, [], signing_key, TicketType::V1MixnetEntry);
let expiration_date = issuance.expiration_date();
let sig_req = issuance.prepare_for_signing();
let exp_date_sigs = generate_expiration_date_signatures(
@@ -91,6 +92,7 @@ mod tests {
sig_req.ecash_pub_key.clone(),
&sig_req.withdrawal_request,
expiration_date.ecash_unix_timestamp(),
issuance.ticketbook_type().encode(),
)
.unwrap();
+2
View File
@@ -27,6 +27,7 @@ pub trait EcashStorageManagerExt {
/// # Arguments
///
/// * `epoch_id`: Id of the (coconut) epoch in question.
#[allow(dead_code)]
async fn create_epoch_credentials_entry(&self, epoch_id: EpochId) -> Result<(), sqlx::Error>;
/// Update the EpochCredentials by incrementing the total number of issued credentials,
@@ -62,6 +63,7 @@ pub trait EcashStorageManagerExt {
) -> Result<Option<IssuedTicketbook>, sqlx::Error>;
/// Store the provided issued credential information and return its (database) id.
#[allow(clippy::too_many_arguments)]
async fn store_issued_ticketbook(
&self,
epoch_id: u32,
+2
View File
@@ -89,6 +89,7 @@ pub trait EcashStorageExt {
deposit_id: DepositId,
) -> Result<Option<IssuedTicketbook>, NymApiStorageError>;
#[allow(clippy::too_many_arguments)]
async fn store_issued_credential(
&self,
epoch_id: u32,
@@ -324,6 +325,7 @@ impl EcashStorageExt for NymApiStorage {
.await?)
}
#[allow(clippy::too_many_arguments)]
async fn store_issued_credential(
&self,
epoch_id: u32,
+1 -1
View File
@@ -35,7 +35,7 @@ nym-crypto = { path = "../../../common/crypto", features = ["asymmetric", "rand"
nym-config = { path = "../../../common/config" }
nym-validator-client = { path = "../../../common/client-libs/validator-client" }
nym-compact-ecash = { path = "../../../common/nym_offline_compact_ecash" }
dkg-bypass-contract = { path = "dkg-bypass-contract" }
dkg-bypass-contract = { path = "dkg-bypass-contract", default-features = false }
# contracts:
nym-mixnet-contract-common = { path = "../../../common/cosmwasm-smart-contracts/mixnet-contract" }
@@ -18,4 +18,8 @@ cosmwasm-schema = { workspace = true }
cw-storage-plus = { workspace = true }
nym-coconut-dkg-common = { path = "../../../../common/cosmwasm-smart-contracts/coconut-dkg" }
nym-contracts-common = { path = "../../../../common/cosmwasm-smart-contracts/contracts-common" }
nym-contracts-common = { path = "../../../../common/cosmwasm-smart-contracts/contracts-common" }
[features]
default = ["library"]
library = []
@@ -4,8 +4,7 @@
use crate::msg::MigrateMsg;
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{
entry_point, Addr, Deps, DepsMut, Env, MessageInfo, QueryResponse, Response, StdError,
StdResult, Storage,
Addr, Deps, DepsMut, Env, MessageInfo, QueryResponse, Response, StdError, StdResult, Storage,
};
use cw_storage_plus::{Index, IndexList, IndexedMap, Item, Map, MultiIndex};
use nym_coconut_dkg_common::dealer::DealerRegistrationDetails;
@@ -58,7 +57,7 @@ pub(crate) fn next_node_index(store: &mut dyn Storage) -> StdResult<NodeIndex> {
#[cw_serde]
pub enum EmptyMessage {}
#[cfg_attr(not(feature = "library"), entry_point)]
#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)]
pub fn instantiate(
_: DepsMut<'_>,
_: Env,
@@ -69,7 +68,7 @@ pub fn instantiate(
}
/// Handle an incoming message
#[cfg_attr(not(feature = "library"), entry_point)]
#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)]
pub fn execute(
_: DepsMut<'_>,
_: Env,
@@ -79,13 +78,13 @@ pub fn execute(
Ok(Response::new())
}
#[cfg_attr(not(feature = "library"), entry_point)]
#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)]
pub fn query(_: Deps<'_>, _: Env, _: EmptyMessage) -> Result<QueryResponse, StdError> {
Ok(Default::default())
}
// LIMITATION: we're not storing dealings themselves
#[cfg_attr(not(feature = "library"), entry_point)]
#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)]
pub fn migrate(deps: DepsMut<'_>, env: Env, msg: MigrateMsg) -> Result<Response, StdError> {
// on migration immediately attempt to rewrite the storage
let threshold = (2 * msg.dealers.len() as u64 + 3 - 1) / 3;
@@ -259,7 +259,7 @@ impl NetworkManager {
fs::write(
&mnemonic_path,
&Zeroizing::new(signer.data.cosmos_account.mnemonic.to_string()),
Zeroizing::new(signer.data.cosmos_account.mnemonic.to_string()),
)?;
fs::write(&endpoint_path, url.as_str())?;