Skip to content

Commit aaf46c8

Browse files
committed
Merge branch 'master' into dev
2 parents 97c3dea + 108f133 commit aaf46c8

5 files changed

Lines changed: 63 additions & 21 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Intro
22

3-
> cargo add https://github.com/LetsVerify/BBS_rust
3+
> cargo add bbs --git https://github.com/LetsVerify/BBS_rust
4+
5+
> and use:
6+
7+
```rust
8+
use bbs::bbs_bn254::*;
9+
```
10+
11+
> to import
12+
413

514
## See usage in [tests](./bbs/tests/)
615

bbs/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bbs_wasm/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ pub fn verify(
116116

117117
#[wasm_bindgen]
118118
pub fn pok_nizk_prove(
119+
<<<<<<< HEAD
119120
ctx: String,
121+
=======
122+
>>>>>>> origin/master
120123
params_js: JsValue,
121124
pk_js: JsValue,
122125
messages_js: JsValue,
@@ -150,7 +153,10 @@ pub fn pok_nizk_prove(
150153
.map_err(|e: String| JsValue::from_str(&e))?;
151154

152155
let proof = nizk_prove_prefix(
156+
<<<<<<< HEAD
153157
ctx.as_bytes(),
158+
=======
159+
>>>>>>> origin/master
154160
&params,
155161
&pk,
156162
&messages,
@@ -166,7 +172,10 @@ pub fn pok_nizk_prove(
166172

167173
#[wasm_bindgen]
168174
pub fn pok_nizk_verify(
175+
<<<<<<< HEAD
169176
ctx: String,
177+
=======
178+
>>>>>>> origin/master
170179
params_js: JsValue,
171180
pk_js: JsValue,
172181
disclosed_msgs_js: JsValue,

bbs_wasm/src/utils.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,49 @@ pub fn g1_to_json(p: &G1) -> G1Json {
3737
}
3838
}
3939

40+
pub fn g1_from_json(p: &G1Json) -> Result<G1, String> {
41+
let x = Fq::from_str(&p.x).map_err(|_| format!("Invalid x: {}", p.x))?;
42+
let y = Fq::from_str(&p.y).map_err(|_| format!("Invalid y: {}", p.y))?;
43+
Ok(G1::new_unchecked(x, y))
44+
#![allow(non_snake_case, dead_code)]
45+
46+
use ark_bn254::{Fq, Fq2, Fr as Scalar, G1Affine as G1, G2Affine as G2};
47+
use bbs::structs::{Messages, Params, PrivateKey, PublicKey, Signature};
48+
use serde::{Deserialize, Serialize};
49+
use std::str::FromStr;
50+
51+
pub fn set_panic_hook() {
52+
// When the `console_error_panic_hook` feature is enabled, we can call the
53+
// `set_panic_hook` function at least once during initialization, and then
54+
// we will get better error messages if our code ever panics.
55+
console_error_panic_hook::set_once();
56+
}
57+
58+
#[derive(Serialize, Deserialize)]
59+
pub struct G1Json {
60+
pub x: String,
61+
pub y: String,
62+
}
63+
64+
#[derive(Serialize, Deserialize)]
65+
pub struct Fq2Json {
66+
pub c0: String,
67+
pub c1: String,
68+
}
69+
70+
#[derive(Serialize, Deserialize)]
71+
pub struct G2Json {
72+
pub x: Fq2Json,
73+
pub y: Fq2Json,
74+
}
75+
76+
pub fn g1_to_json(p: &G1) -> G1Json {
77+
G1Json {
78+
x: p.x.to_string(),
79+
y: p.y.to_string(),
80+
}
81+
}
82+
4083
pub fn g1_from_json(p: &G1Json) -> Result<G1, String> {
4184
let x = Fq::from_str(&p.x).map_err(|_| format!("Invalid x: {}", p.x))?;
4285
let y = Fq::from_str(&p.y).map_err(|_| format!("Invalid y: {}", p.y))?;

0 commit comments

Comments
 (0)