diff --git a/common/client-libs/validator-client/src/nym_api/routes.rs b/common/client-libs/validator-client/src/nym_api/routes.rs index d670033049..bb3125f001 100644 --- a/common/client-libs/validator-client/src/nym_api/routes.rs +++ b/common/client-libs/validator-client/src/nym_api/routes.rs @@ -15,6 +15,7 @@ pub const REWARDED: &str = "rewarded"; pub const COCONUT_ROUTES: &str = "coconut"; pub const BANDWIDTH: &str = "bandwidth"; +pub const COCONUT_FREE_PASS: &str = "free-pass"; pub const COCONUT_BLIND_SIGN: &str = "blind-sign"; pub const COCONUT_VERIFY_BANDWIDTH_CREDENTIAL: &str = "verify-bandwidth-credential"; pub const COCONUT_EPOCH_CREDENTIALS: &str = "epoch-credentials"; diff --git a/nym-api/nym-api-requests/Cargo.toml b/nym-api/nym-api-requests/Cargo.toml index 1baf4d17dd..d76ce70675 100644 --- a/nym-api/nym-api-requests/Cargo.toml +++ b/nym-api/nym-api-requests/Cargo.toml @@ -16,10 +16,13 @@ serde = { workspace = true, features = ["derive"] } ts-rs = { workspace = true, optional = true } tendermint = { workspace = true } +# for serde on secp256k1 signatures +ecdsa = { version = "0.16", features = ["serde"] } + nym-credentials-interface = { path = "../../common/credentials-interface" } nym-crypto = { path = "../../common/crypto", features = ["serde", "asymmetric"]} -nym-mixnet-contract-common = { path= "../../common/cosmwasm-smart-contracts/mixnet-contract" } +nym-mixnet-contract-common = { path = "../../common/cosmwasm-smart-contracts/mixnet-contract" } nym-node-requests = { path = "../../nym-node/nym-node-requests", default-features = false } [features] diff --git a/nym-api/nym-api-requests/src/coconut/models.rs b/nym-api/nym-api-requests/src/coconut/models.rs index c4de811281..4092f8fbee 100644 --- a/nym-api/nym-api-requests/src/coconut/models.rs +++ b/nym-api/nym-api-requests/src/coconut/models.rs @@ -140,6 +140,20 @@ impl BlindedSignatureResponse { } } +#[derive(Serialize, Deserialize)] +pub struct FreePassRequest { + // secp256k1 key associated with the admin account + pub cosmos_pubkey: cosmrs::crypto::PublicKey, + + pub inner_sign_request: BlindSignRequest, + + /// Signature on the inner sign request + /// to prove the possession of the cosmos key/address + pub signature: cosmrs::crypto::secp256k1::Signature, + + pub public_attributes_plain: Vec, +} + #[derive(Serialize, Deserialize)] pub struct VerificationKeyResponse { pub key: VerificationKey, diff --git a/nym-api/src/coconut/api_routes/mod.rs b/nym-api/src/coconut/api_routes/mod.rs index b2b2dfc4bc..8d0a6a2caf 100644 --- a/nym-api/src/coconut/api_routes/mod.rs +++ b/nym-api/src/coconut/api_routes/mod.rs @@ -26,6 +26,11 @@ use rocket::State as RocketState; mod helpers; +pub async fn post_free_pass(state: &RocketState) { + // attach secp256k1 pubkey; derive address; check contract admin verify signature + todo!() +} + #[post("/blind-sign", data = "")] // Until we have serialization and deserialization traits we'll be using a crutch pub async fn post_blind_sign( diff --git a/nym-connect/desktop/Cargo.lock b/nym-connect/desktop/Cargo.lock index 6480b0a255..3c146f252d 100644 --- a/nym-connect/desktop/Cargo.lock +++ b/nym-connect/desktop/Cargo.lock @@ -1729,6 +1729,7 @@ dependencies = [ "digest 0.10.7", "elliptic-curve 0.13.5", "rfc6979 0.4.0", + "serdect", "signature 2.1.0", "spki 0.7.2", ] @@ -1837,6 +1838,7 @@ dependencies = [ "pkcs8 0.10.2", "rand_core 0.6.4", "sec1 0.7.3", + "serdect", "subtle 2.4.1", "zeroize", ] @@ -3693,6 +3695,7 @@ dependencies = [ "bs58 0.4.0", "cosmrs", "cosmwasm-std", + "ecdsa 0.16.8", "getset", "nym-credentials-interface", "nym-crypto", @@ -5824,6 +5827,7 @@ dependencies = [ "der 0.7.8", "generic-array 0.14.7", "pkcs8 0.10.2", + "serdect", "subtle 2.4.1", "zeroize", ] @@ -6149,6 +6153,16 @@ dependencies = [ "syn 2.0.28", ] +[[package]] +name = "serdect" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" +dependencies = [ + "base16ct 0.2.0", + "serde", +] + [[package]] name = "serialize-to-javascript" version = "0.1.1" diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index e9cdff7476..885674bddb 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -1480,6 +1480,7 @@ dependencies = [ "digest 0.10.7", "elliptic-curve 0.13.5", "rfc6979 0.4.0", + "serdect", "signature 2.1.0", "spki 0.7.2", ] @@ -1588,6 +1589,7 @@ dependencies = [ "pkcs8 0.10.2", "rand_core 0.6.4", "sec1 0.7.3", + "serdect", "subtle 2.4.1", "zeroize", ] @@ -3097,6 +3099,7 @@ dependencies = [ "bs58 0.4.0", "cosmrs 0.15.0 (git+https://github.com/jstuczyn/cosmos-rust?branch=nym-temp/all-validator-features)", "cosmwasm-std", + "ecdsa 0.16.8", "getset", "nym-credentials-interface", "nym-crypto", @@ -4690,6 +4693,7 @@ dependencies = [ "der 0.7.8", "generic-array 0.14.7", "pkcs8 0.10.2", + "serdect", "subtle 2.4.1", "zeroize", ] @@ -4878,6 +4882,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "serdect" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" +dependencies = [ + "base16ct 0.2.0", + "serde", +] + [[package]] name = "serialize-to-javascript" version = "0.1.1"