File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ wasm_bindgen_wrapper! {
17
17
18
18
#[ wasm_bindgen]
19
19
impl Scalar {
20
+ #[ wasm_bindgen]
21
+ pub fn zero ( ) -> Self {
22
+ Self ( blstrs:: Scalar :: zero ( ) )
23
+ }
24
+
20
25
#[ wasm_bindgen]
21
26
pub fn random ( ) -> Self {
22
27
Self ( blstrs:: Scalar :: random ( thread_rng ( ) ) )
@@ -45,6 +50,13 @@ impl Fr {
45
50
Self ( ironfish_jubjub:: Fr :: random ( thread_rng ( ) ) )
46
51
}
47
52
53
+ #[ wasm_bindgen( js_name = fromBytes) ]
54
+ pub fn from_bytes ( & self , bytes : & [ u8 ] ) -> Option < Self > {
55
+ let bytes: & [ u8 ; 32 ] = bytes. try_into ( ) . ok ( ) ?;
56
+ let fr = Option :: from ( ironfish_jubjub:: Fr :: from_bytes ( bytes) ) ?;
57
+ Some ( Self ( fr) )
58
+ }
59
+
48
60
#[ wasm_bindgen( js_name = toBytes) ]
49
61
pub fn to_bytes ( & self ) -> Vec < u8 > {
50
62
self . 0 . to_bytes ( ) . to_vec ( )
You can’t perform that action at this time.
0 commit comments