Skip to content

Commit b2a7185

Browse files
author
simonjiao
committed
export some data structure
1 parent c2faae6 commit b2a7185

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/components/zkcards_wasm/Cargo.toml

+4-10
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,16 @@ base64 = "0.12"
1818
hex = "0.4.2"
1919
js-sys = "0.3.27"
2020
rand_chacha = "0.2"
21-
rand_core = { version = "0.5", default-features = false, features = ["alloc"] }
22-
rand = { version = "0.7", features = ["wasm-bindgen"] }
23-
serde = { version = "1.0.124", features = ["derive"] }
21+
rand_core = { version = "0.6", default-features = false, features = ["alloc"] }
22+
rand = "0.8"
23+
serde = { version = "1", features = ["derive"] }
2424
serde_json = "1.0"
25-
wasm-bindgen = { version = "=0.2.84", features = ["serde-serialize"] }
26-
27-
ring = "0.16.19"
28-
aes-gcm = "0.9.0"
29-
bech32 = "0.7.2"
25+
wasm-bindgen = { version = "0.2.84", features = ["serde-serialize"] }
3026

3127
# Must enable the "js"-feature,
3228
# OR the compiling will fail.
3329
getrandom = { version = "0.2", features = ["js"] }
3430

35-
zei = { git = "https://github.com/FindoraNetwork/zei", branch = "stable-main" }
36-
3731
ark-ff = "0.3.0"
3832
ark-std = { version = "0.3.0", features = ["std"] }
3933
ark-serialize = { version = "0.3.0", features = ["derive"] }

src/components/zkcards_wasm/src/zkcards/error.rs

+6
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ impl From<CardProtocolError> for GameErrors {
3636
Self::ProtocolError(value)
3737
}
3838
}
39+
40+
impl From<CryptoError> for GameErrors {
41+
fn from(value: CryptoError) -> Self {
42+
Self::CryptoError(value)
43+
}
44+
}

src/components/zkcards_wasm/src/zkcards/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use proof_essentials::{
1313
},
1414
};
1515
use serde::{Deserialize, Serialize};
16+
use wasm_bindgen::prelude::*;
1617

1718
// Choose elliptic curve setting
1819
// And instantiate concrete type for our card protocol
@@ -23,6 +24,7 @@ type CardProtocol<'a> = discrete_log_cards::DLCards<'a, Curve>;
2324
type Enc = ElGamal<Curve>;
2425
type Comm = PedersenCommitment<Curve>;
2526

27+
#[wasm_bindgen]
2628
#[derive(Deserialize, Serialize)]
2729
pub struct CardParameters(
2830
#[serde(serialize_with = "ark_se", deserialize_with = "ark_de")]
@@ -53,6 +55,7 @@ pub type PlayerPublicKey = discrete_log_cards::PublicKey<Curve>;
5355
pub type PlayerSecretKey = discrete_log_cards::PlayerSecretKey<Curve>;
5456
pub type AggregatePublicKey = discrete_log_cards::PublicKey<Curve>;
5557

58+
#[wasm_bindgen]
5659
#[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Serialize, Deserialize)]
5760
pub struct Card(
5861
#[serde(serialize_with = "ark_se", deserialize_with = "ark_de")]
@@ -69,6 +72,7 @@ impl From<Card> for discrete_log_cards::Card<Curve> {
6972
}
7073
}
7174

75+
#[wasm_bindgen]
7276
#[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Serialize, Deserialize)]
7377
pub struct MaskedCard(
7478
#[serde(serialize_with = "ark_se", deserialize_with = "ark_de")]
@@ -90,6 +94,7 @@ impl<'a> From<&'a MaskedCard> for &'a discrete_log_cards::MaskedCard<Curve> {
9094
}
9195
}
9296

97+
#[wasm_bindgen]
9398
#[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Serialize, Deserialize)]
9499
pub struct RevealToken(
95100
#[serde(serialize_with = "ark_se", deserialize_with = "ark_de")]
@@ -106,6 +111,7 @@ impl From<RevealToken> for discrete_log_cards::RevealToken<Curve> {
106111
}
107112
}
108113

114+
#[wasm_bindgen]
109115
#[derive(Copy, Clone, Deserialize, Serialize)]
110116
pub struct ProofKeyOwnership(
111117
#[serde(serialize_with = "ark_se", deserialize_with = "ark_de")]
@@ -122,6 +128,7 @@ impl From<ProofKeyOwnership> for schnorr_identification::proof::Proof<Curve> {
122128
}
123129
}
124130

131+
#[wasm_bindgen]
125132
#[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Deserialize, Serialize)]
126133
pub struct ProofReveal(
127134
#[serde(serialize_with = "ark_se", deserialize_with = "ark_de")]
@@ -138,6 +145,7 @@ impl From<ProofReveal> for chaum_pedersen_dl_equality::proof::Proof<Curve> {
138145
}
139146
}
140147

148+
#[wasm_bindgen]
141149
#[derive(Deserialize, Serialize)]
142150
pub struct ProofShuffle(
143151
#[serde(serialize_with = "ark_se", deserialize_with = "ark_de")]
@@ -159,6 +167,7 @@ impl<'a> From<&'a ProofShuffle> for &'a shuffle::proof::Proof<Scalar, Enc, Comm>
159167
}
160168
}
161169

170+
#[wasm_bindgen]
162171
//pub struct ProofMasking(chaum_pedersen_dl_equality::proof::Proof<Curve>);
163172
#[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Deserialize, Serialize)]
164173
pub struct ProofRemasking(
@@ -176,6 +185,7 @@ impl From<ProofRemasking> for chaum_pedersen_dl_equality::proof::Proof<Curve> {
176185
}
177186
}
178187

188+
//#[wasm_bindgen]
179189
#[derive(Serialize, Deserialize)]
180190
pub struct RevealedToken {
181191
pub token: RevealToken,

0 commit comments

Comments
 (0)