Skip to content

Commit

Permalink
export some data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjiao committed Apr 21, 2023
1 parent c2faae6 commit b2a7185
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/components/zkcards_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
6 changes: 6 additions & 0 deletions src/components/zkcards_wasm/src/zkcards/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ impl From<CardProtocolError> for GameErrors {
Self::ProtocolError(value)
}
}

impl From<CryptoError> for GameErrors {
fn from(value: CryptoError) -> Self {
Self::CryptoError(value)
}
}
10 changes: 10 additions & 0 deletions src/components/zkcards_wasm/src/zkcards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +24,7 @@ type CardProtocol<'a> = discrete_log_cards::DLCards<'a, Curve>;
type Enc = ElGamal<Curve>;
type Comm = PedersenCommitment<Curve>;

#[wasm_bindgen]
#[derive(Deserialize, Serialize)]
pub struct CardParameters(
#[serde(serialize_with = "ark_se", deserialize_with = "ark_de")]
Expand Down Expand Up @@ -53,6 +55,7 @@ pub type PlayerPublicKey = discrete_log_cards::PublicKey<Curve>;
pub type PlayerSecretKey = discrete_log_cards::PlayerSecretKey<Curve>;
pub type AggregatePublicKey = discrete_log_cards::PublicKey<Curve>;

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

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

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

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

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

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

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

//#[wasm_bindgen]
#[derive(Serialize, Deserialize)]
pub struct RevealedToken {
pub token: RevealToken,
Expand Down

0 comments on commit b2a7185

Please sign in to comment.