diff --git a/src/components/zkcards_wasm/Cargo.toml b/src/components/zkcards_wasm/Cargo.toml index 47cde0742..5b79f244e 100644 --- a/src/components/zkcards_wasm/Cargo.toml +++ b/src/components/zkcards_wasm/Cargo.toml @@ -18,22 +18,16 @@ base64 = "0.12" hex = "0.4.2" js-sys = "0.3.27" rand_chacha = "0.2" -rand_core = { version = "0.5", default-features = false, features = ["alloc"] } -rand = { version = "0.7", features = ["wasm-bindgen"] } -serde = { version = "1.0.124", features = ["derive"] } +rand_core = { version = "0.6", default-features = false, features = ["alloc"] } +rand = "0.8" +serde = { version = "1", features = ["derive"] } serde_json = "1.0" -wasm-bindgen = { version = "=0.2.84", features = ["serde-serialize"] } - -ring = "0.16.19" -aes-gcm = "0.9.0" -bech32 = "0.7.2" +wasm-bindgen = { version = "0.2.84", features = ["serde-serialize"] } # Must enable the "js"-feature, # OR the compiling will fail. getrandom = { version = "0.2", features = ["js"] } -zei = { git = "https://github.com/FindoraNetwork/zei", branch = "stable-main" } - ark-ff = "0.3.0" ark-std = { version = "0.3.0", features = ["std"] } ark-serialize = { version = "0.3.0", features = ["derive"] } diff --git a/src/components/zkcards_wasm/src/zkcards/error.rs b/src/components/zkcards_wasm/src/zkcards/error.rs index 23aacd8f1..9d43038c6 100644 --- a/src/components/zkcards_wasm/src/zkcards/error.rs +++ b/src/components/zkcards_wasm/src/zkcards/error.rs @@ -36,3 +36,9 @@ impl From for GameErrors { Self::ProtocolError(value) } } + +impl From for GameErrors { + fn from(value: CryptoError) -> Self { + Self::CryptoError(value) + } +} diff --git a/src/components/zkcards_wasm/src/zkcards/mod.rs b/src/components/zkcards_wasm/src/zkcards/mod.rs index 21ff72f8b..38822f8db 100644 --- a/src/components/zkcards_wasm/src/zkcards/mod.rs +++ b/src/components/zkcards_wasm/src/zkcards/mod.rs @@ -13,6 +13,7 @@ use proof_essentials::{ }, }; use serde::{Deserialize, Serialize}; +use wasm_bindgen::prelude::*; // Choose elliptic curve setting // And instantiate concrete type for our card protocol @@ -23,6 +24,7 @@ type CardProtocol<'a> = discrete_log_cards::DLCards<'a, Curve>; type Enc = ElGamal; type Comm = PedersenCommitment; +#[wasm_bindgen] #[derive(Deserialize, Serialize)] pub struct CardParameters( #[serde(serialize_with = "ark_se", deserialize_with = "ark_de")] @@ -53,6 +55,7 @@ pub type PlayerPublicKey = discrete_log_cards::PublicKey; pub type PlayerSecretKey = discrete_log_cards::PlayerSecretKey; pub type AggregatePublicKey = discrete_log_cards::PublicKey; +#[wasm_bindgen] #[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Serialize, Deserialize)] pub struct Card( #[serde(serialize_with = "ark_se", deserialize_with = "ark_de")] @@ -69,6 +72,7 @@ impl From for discrete_log_cards::Card { } } +#[wasm_bindgen] #[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Serialize, Deserialize)] pub struct MaskedCard( #[serde(serialize_with = "ark_se", deserialize_with = "ark_de")] @@ -90,6 +94,7 @@ impl<'a> From<&'a MaskedCard> for &'a discrete_log_cards::MaskedCard { } } +#[wasm_bindgen] #[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Serialize, Deserialize)] pub struct RevealToken( #[serde(serialize_with = "ark_se", deserialize_with = "ark_de")] @@ -106,6 +111,7 @@ impl From for discrete_log_cards::RevealToken { } } +#[wasm_bindgen] #[derive(Copy, Clone, Deserialize, Serialize)] pub struct ProofKeyOwnership( #[serde(serialize_with = "ark_se", deserialize_with = "ark_de")] @@ -122,6 +128,7 @@ impl From for schnorr_identification::proof::Proof { } } +#[wasm_bindgen] #[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Deserialize, Serialize)] pub struct ProofReveal( #[serde(serialize_with = "ark_se", deserialize_with = "ark_de")] @@ -138,6 +145,7 @@ impl From for chaum_pedersen_dl_equality::proof::Proof { } } +#[wasm_bindgen] #[derive(Deserialize, Serialize)] pub struct ProofShuffle( #[serde(serialize_with = "ark_se", deserialize_with = "ark_de")] @@ -159,6 +167,7 @@ impl<'a> From<&'a ProofShuffle> for &'a shuffle::proof::Proof } } +#[wasm_bindgen] //pub struct ProofMasking(chaum_pedersen_dl_equality::proof::Proof); #[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Deserialize, Serialize)] pub struct ProofRemasking( @@ -176,6 +185,7 @@ impl From for chaum_pedersen_dl_equality::proof::Proof { } } +//#[wasm_bindgen] #[derive(Serialize, Deserialize)] pub struct RevealedToken { pub token: RevealToken,