@nuggetslife/vc 0.0.18 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -331,6 +331,13 @@ export declare class KeyPairVerifier {
331
331
  export declare class BoundBls12381G2KeyPair {
332
332
  constructor(options: BoundKeyPairOptions)
333
333
  static from(options: BoundKeyPairOptions): BoundBls12381G2KeyPair
334
+ get id(): string | null
335
+ get controller(): string | null
336
+ get type(): string
337
+ get publicKey(): string | null
338
+ get privateKey(): string | null
339
+ get publicKeyBuffer(): Buffer
340
+ get privateKeyBuffer(): Buffer
334
341
  get commitment(): Uint8Array
335
342
  get blinded(): Array<number>
336
343
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuggetslife/vc",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "napi": {
@@ -41,11 +41,11 @@
41
41
  },
42
42
  "packageManager": "yarn@4.3.1",
43
43
  "optionalDependencies": {
44
- "@nuggetslife/vc-darwin-arm64": "0.0.18",
45
- "@nuggetslife/vc-linux-arm64-gnu": "0.0.18",
46
- "@nuggetslife/vc-linux-arm64-musl": "0.0.18",
47
- "@nuggetslife/vc-linux-x64-gnu": "0.0.18",
48
- "@nuggetslife/vc-linux-x64-musl": "0.0.18"
44
+ "@nuggetslife/vc-darwin-arm64": "0.0.20",
45
+ "@nuggetslife/vc-linux-arm64-gnu": "0.0.20",
46
+ "@nuggetslife/vc-linux-arm64-musl": "0.0.20",
47
+ "@nuggetslife/vc-linux-x64-gnu": "0.0.20",
48
+ "@nuggetslife/vc-linux-x64-musl": "0.0.20"
49
49
  },
50
50
  "dependencies": {}
51
51
  }
@@ -38,6 +38,41 @@ impl BoundBls12381G2KeyPair {
38
38
  Self::new(options)
39
39
  }
40
40
 
41
+ #[napi(getter)]
42
+ pub fn id(&self) -> Option<String> {
43
+ self.inner.id.clone()
44
+ }
45
+
46
+ #[napi(getter)]
47
+ pub fn controller(&self) -> Option<String> {
48
+ self.inner.controller.clone()
49
+ }
50
+
51
+ #[napi(getter, js_name = "type")]
52
+ pub fn key_type(&self) -> String {
53
+ "Bls12381G2Key2020".to_string()
54
+ }
55
+
56
+ #[napi(getter)]
57
+ pub fn public_key(&self) -> Option<String> {
58
+ self.inner.public_key()
59
+ }
60
+
61
+ #[napi(getter)]
62
+ pub fn private_key(&self) -> Option<String> {
63
+ self.inner.private_key()
64
+ }
65
+
66
+ #[napi(getter)]
67
+ pub fn public_key_buffer(&self) -> Buffer {
68
+ self.inner.public_key_buffer()
69
+ }
70
+
71
+ #[napi(getter)]
72
+ pub fn private_key_buffer(&self) -> Buffer {
73
+ self.inner.private_key_buffer()
74
+ }
75
+
41
76
  #[napi(getter)]
42
77
  pub fn commitment(&self) -> Uint8Array {
43
78
  Uint8Array::from(self.commitment_bytes.clone())
@@ -2,6 +2,7 @@ use std::collections::{BTreeMap, HashMap};
2
2
  use std::num::NonZeroUsize;
3
3
  use std::sync::Arc;
4
4
 
5
+ use base64::prelude::BASE64_STANDARD;
5
6
  use base64::Engine;
6
7
  use lru::LruCache;
7
8
  use napi::bindgen_prelude::*;
@@ -137,7 +138,11 @@ pub async fn ld_derive_proof(options: Value) -> napi::Result<Value> {
137
138
  let nonce = options
138
139
  .get("nonce")
139
140
  .and_then(|v| v.as_str())
140
- .map(|s| s.as_bytes().to_vec());
141
+ .map(|s| {
142
+ BASE64_STANDARD
143
+ .decode(s)
144
+ .unwrap_or_else(|_| s.as_bytes().to_vec())
145
+ });
141
146
 
142
147
  let additional_contexts = parse_contexts(&options);
143
148
 
@@ -161,7 +166,11 @@ pub async fn derive_proof(
161
166
  let nonce = options
162
167
  .get("nonce")
163
168
  .and_then(|v| v.as_str())
164
- .map(|s| s.as_bytes().to_vec());
169
+ .map(|s| {
170
+ BASE64_STANDARD
171
+ .decode(s)
172
+ .unwrap_or_else(|_| s.as_bytes().to_vec())
173
+ });
165
174
 
166
175
  let additional_contexts = parse_contexts(&options);
167
176
 
@@ -292,7 +301,11 @@ pub async fn derive_proof_holder_bound(
292
301
  let nonce = options
293
302
  .get("nonce")
294
303
  .and_then(|v| v.as_str())
295
- .map(|s| s.as_bytes().to_vec());
304
+ .map(|s| {
305
+ BASE64_STANDARD
306
+ .decode(s)
307
+ .unwrap_or_else(|_| s.as_bytes().to_vec())
308
+ });
296
309
 
297
310
  let additional_contexts = parse_contexts(&options);
298
311