@nuggetslife/vc 0.0.10 → 0.0.15

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.
Files changed (31) hide show
  1. package/Cargo.toml +5 -2
  2. package/index.d.ts +303 -3
  3. package/index.js +15 -1
  4. package/package.json +11 -11
  5. package/src/bls_signatures/bbs_bls_holder_bound_signature_2022/mod.rs +268 -0
  6. package/src/bls_signatures/bbs_bls_holder_bound_signature_2022/types.rs +26 -0
  7. package/src/bls_signatures/bbs_bls_holder_bound_signature_proof_2022/mod.rs +100 -0
  8. package/src/bls_signatures/bbs_bls_holder_bound_signature_proof_2022/types.rs +17 -0
  9. package/src/bls_signatures/bbs_bls_signature_2020/mod.rs +329 -0
  10. package/src/bls_signatures/bbs_bls_signature_2020/types.rs +37 -0
  11. package/src/bls_signatures/bbs_bls_signature_proof_2020/mod.rs +92 -0
  12. package/src/bls_signatures/bbs_bls_signature_proof_2020/types.rs +13 -0
  13. package/src/bls_signatures/bls_12381_g2_keypair/mod.rs +470 -0
  14. package/src/{types.rs → bls_signatures/bls_12381_g2_keypair/types.rs} +0 -11
  15. package/src/{validators.rs → bls_signatures/bls_12381_g2_keypair/validators.rs} +1 -1
  16. package/src/bls_signatures/bound_bls_12381_g2_keypair/mod.rs +70 -0
  17. package/src/bls_signatures/bound_bls_12381_g2_keypair/types.rs +11 -0
  18. package/src/bls_signatures/mod.rs +6 -0
  19. package/src/jsonld.rs +200 -0
  20. package/src/ld_signatures.rs +311 -0
  21. package/src/lib.rs +3 -463
  22. package/test-data/bbs.json +92 -0
  23. package/test-data/citizenVocab.json +57 -0
  24. package/test-data/controllerDocument.json +5 -0
  25. package/test-data/credentialsContext.json +315 -0
  26. package/test-data/deriveProofFrame.json +15 -0
  27. package/test-data/inputDocument.json +29 -0
  28. package/test-data/keyPair.json +6 -0
  29. package/test-data/suiteContext.json +82 -0
  30. package/test.mjs +1088 -22
  31. package/test_jsonld_crossverify.mjs +256 -0
@@ -0,0 +1,470 @@
1
+ use base64::{
2
+ engine::general_purpose::URL_SAFE, engine::general_purpose::URL_SAFE_NO_PAD, Engine as _,
3
+ };
4
+ use napi::bindgen_prelude::*;
5
+ use types::{
6
+ BlsCurveName, FingerPrintFromPublicKeyOptions, GenerateKeyPairOptions, JsonWebKey,
7
+ JwkKeyPairOptions, JwkKty, KeyPairFromFingerPrintOptions, KeyPairOptions,
8
+ };
9
+ use validators::{assert_bls_12381_g2_private_jwk, assert_bls_12381_g2_public_jwk};
10
+ use vc::bbs_signatures::bls12381::{
11
+ bls_generate_g2_key, bls_sign, bls_verify, BlsBbsSignRequest, BlsBbsVerifyRequest, BlsKeyPair,
12
+ BLS12381G2_MULTICODEC_IDENTIFIER, DEFAULT_BLS12381_G2_PUBLIC_KEY_LENGTH,
13
+ MULTIBASE_ENCODED_BASE58_IDENTIFIER, VARIABLE_INTEGER_TRAILING_BYTE,
14
+ };
15
+
16
+ pub mod types;
17
+ pub mod validators;
18
+
19
+ #[derive(Clone)]
20
+ #[napi]
21
+ pub struct Bls12381G2KeyPair {
22
+ pub id: Option<String>,
23
+ pub controller: Option<String>,
24
+ pub private_key_inner: Option<Vec<u8>>,
25
+ pub public_key_inner: Option<Vec<u8>>,
26
+ #[napi(js_name = "type")]
27
+ pub type_: String,
28
+ }
29
+
30
+ #[napi]
31
+ impl Bls12381G2KeyPair {
32
+ #[napi(constructor)]
33
+ pub fn new(options: Option<KeyPairOptions>) -> Self {
34
+ match options {
35
+ Some(o) => {
36
+ // The provided publicKey needs to be 384 bits / 5.85 = 65.6
37
+ // which means the base58 encoded publicKey can be either 65 or 66 chars
38
+ // 5.85 = log base 2 (58) which is equivalent to the number of bits
39
+ // encoded per character of a base58 encoded string.
40
+ // if let Some(ref pubkey_bs58) = o.public_key_base58 {
41
+ // if pubkey_bs58.len() != 131 && pubkey_bs58.len() != 132 {
42
+ // panic!(
43
+ // "public_key_base58 invalid length. expected 131 or 132. got {}",
44
+ // pubkey_bs58.len()
45
+ // )
46
+ // }
47
+ // };
48
+
49
+ // Validates the size of the private key if one is included
50
+ // This is done by 256 bits / 5.85 = 43.7 which means
51
+ // the base58 encoded privateKey can be either 43 or 44 chars
52
+ // if let Some(ref privkey_bs58) = o.private_key_base58 {
53
+ // if privkey_bs58.len() != 43 && privkey_bs58.len() != 44 {
54
+ // panic!(
55
+ // "private_key_base58 invalid length. expected 43 or 44. got {}",
56
+ // privkey_bs58.len()
57
+ // )
58
+ // }
59
+ // };
60
+
61
+ let private_key_inner = o
62
+ .private_key_base58
63
+ .map(|v| bs58::decode(v).into_vec().unwrap());
64
+ let public_key_inner = o
65
+ .public_key_base58
66
+ .map(|v| bs58::decode(v).into_vec().unwrap());
67
+
68
+ Self {
69
+ id: o.id,
70
+ controller: o.controller,
71
+ private_key_inner,
72
+ public_key_inner,
73
+ type_: String::from("Bls12381G2Key2020"),
74
+ }
75
+ }
76
+ None => Self {
77
+ id: None,
78
+ controller: None,
79
+ private_key_inner: None,
80
+ public_key_inner: None,
81
+ type_: String::from("Bls12381G2Key2020"),
82
+ },
83
+ }
84
+ }
85
+
86
+ #[napi(factory)]
87
+ pub async fn generate(options: Option<GenerateKeyPairOptions>) -> Self {
88
+ match options {
89
+ Some(o) => {
90
+ let seed: Option<Vec<u8>> = o.seed.map(|s| s.into());
91
+ let kp = bls_generate_g2_key(seed).await;
92
+ let public_key_base58 = kp.public_key.map(|v| bs58::encode(v).into_string());
93
+ let private_key_base58 = kp.secret_key.map(|v| bs58::encode(v).into_string());
94
+
95
+ Self::new(Some(KeyPairOptions {
96
+ id: o.id,
97
+ controller: o.controller,
98
+ private_key_base58,
99
+ public_key_base58,
100
+ }))
101
+ }
102
+ None => {
103
+ let kp = bls_generate_g2_key(None).await;
104
+ let public_key_base58 = kp.public_key.map(|v| bs58::encode(v).into_string());
105
+ let private_key_base58 = kp.secret_key.map(|v| bs58::encode(v).into_string());
106
+
107
+ Self::new(Some(KeyPairOptions {
108
+ id: None,
109
+ controller: None,
110
+ private_key_base58,
111
+ public_key_base58,
112
+ }))
113
+ }
114
+ }
115
+ }
116
+
117
+ #[napi(factory)]
118
+ pub async fn from(options: KeyPairOptions) -> Self {
119
+ Bls12381G2KeyPair::new(Some(options))
120
+ }
121
+
122
+ #[napi(factory)]
123
+ pub async fn from_jwk(options: JwkKeyPairOptions) -> Result<Bls12381G2KeyPair> {
124
+ let JwkKeyPairOptions {
125
+ id,
126
+ controller,
127
+ private_key_jwk,
128
+ public_key_jwk,
129
+ } = options;
130
+
131
+ if let Some(jwk) = private_key_jwk {
132
+ assert_bls_12381_g2_private_jwk(&jwk)?;
133
+ let public_key_base58 = Some(convert_base64_url_to_base58(jwk.x)?);
134
+ let d = jwk
135
+ .d
136
+ .ok_or(napi::Error::from_reason("jwk.d value is none"))?;
137
+ let private_key_base58 = Some(convert_base64_url_to_base58(d)?);
138
+
139
+ let kp = Bls12381G2KeyPair::new(Some(KeyPairOptions {
140
+ id,
141
+ controller,
142
+ public_key_base58,
143
+ private_key_base58,
144
+ }));
145
+
146
+ Ok(kp)
147
+ } else if let Some(jwk) = public_key_jwk {
148
+ assert_bls_12381_g2_public_jwk(&jwk)?;
149
+ let public_key_base58 = Some(convert_base64_url_to_base58(jwk.x)?);
150
+ let kp = Bls12381G2KeyPair::new(Some(KeyPairOptions {
151
+ id,
152
+ controller,
153
+ public_key_base58,
154
+ private_key_base58: None,
155
+ }));
156
+
157
+ Ok(kp)
158
+ } else {
159
+ Err(napi::Error::from_reason("The JWK provided is not a valid"))
160
+ }
161
+ }
162
+
163
+ #[napi(factory)]
164
+ pub async fn from_fingerprint(
165
+ options: KeyPairFromFingerPrintOptions,
166
+ ) -> Result<Bls12381G2KeyPair> {
167
+ let KeyPairFromFingerPrintOptions {
168
+ id,
169
+ controller,
170
+ fingerprint,
171
+ } = options;
172
+ let mut chars = fingerprint.chars();
173
+ let head = chars
174
+ .next()
175
+ .ok_or(napi::Error::from_reason("fingerprint string is empty"))?
176
+ .to_string();
177
+
178
+ if head != MULTIBASE_ENCODED_BASE58_IDENTIFIER {
179
+ return Err(napi::Error::from_reason(
180
+ format!("Unsupported fingerprint type: expected first character to be `z` indicating base58 encoding, received {head}")
181
+ ));
182
+ };
183
+
184
+ let rest = chars.collect::<String>();
185
+ let buffer = bs58::decode(rest).into_vec().map_err(|err| {
186
+ napi::Error::from_reason(format!(
187
+ "failed to decode bs58 fingerprint to bytes. error: {err}"
188
+ ))
189
+ })?;
190
+
191
+ if buffer.len() != BLS12381G2_MULTICODEC_IDENTIFIER as usize {
192
+ return Err(napi::Error::from_reason(
193
+ format!("Unsupported public key length: expected `${DEFAULT_BLS12381_G2_PUBLIC_KEY_LENGTH}` received {}", buffer.len())
194
+ ));
195
+ }
196
+
197
+ if buffer[0] != DEFAULT_BLS12381_G2_PUBLIC_KEY_LENGTH {
198
+ return Err(napi::Error::from_reason(
199
+ format!("Unsupported public key identifier: expected second character to be {BLS12381G2_MULTICODEC_IDENTIFIER} indicating BLS12381G2 key pair, received {}", buffer[0])
200
+ ));
201
+ }
202
+
203
+ if buffer[1] != VARIABLE_INTEGER_TRAILING_BYTE {
204
+ return Err(napi::Error::from_reason(
205
+ format!("Missing variable integer trailing byte: expected third character to be {BLS12381G2_MULTICODEC_IDENTIFIER} indicating BLS12381G2 key pair, received {}", buffer[1])
206
+ ));
207
+ }
208
+
209
+ let pubkey_base58 = bs58::encode(buffer).into_string();
210
+ let opts = FingerPrintFromPublicKeyOptions {
211
+ public_key_base58: pubkey_base58.clone(),
212
+ };
213
+ let fingerprint = Bls12381G2KeyPair::fingerprint_from_public_key(opts).map_err(|err| {
214
+ napi::Error::from_reason(format!("fingerprint_from_public_key failed. error: {err}"))
215
+ })?;
216
+ let mapped_controller = match controller {
217
+ Some(v) => v,
218
+ None => {
219
+ format!("did:key:{fingerprint}",)
220
+ }
221
+ };
222
+
223
+ let mapped_id = match id {
224
+ Some(v) => v,
225
+ None => {
226
+ format!("#{fingerprint}",)
227
+ }
228
+ };
229
+
230
+ let kp = Bls12381G2KeyPair::new(Some(KeyPairOptions {
231
+ id: Some(mapped_id),
232
+ controller: Some(mapped_controller),
233
+ public_key_base58: Some(pubkey_base58),
234
+ private_key_base58: None,
235
+ }));
236
+
237
+ Ok(kp)
238
+ }
239
+
240
+ #[napi(getter)]
241
+ pub fn public_key(&self) -> Option<String> {
242
+ self
243
+ .public_key_inner
244
+ .clone()
245
+ .map(|b| bs58::encode(b).into_string())
246
+ }
247
+
248
+ #[napi(getter)]
249
+ pub fn public_key_buffer(&self) -> Buffer {
250
+ self.public_key_inner.clone().unwrap().into()
251
+ }
252
+
253
+ #[napi(getter)]
254
+ pub fn private_key_buffer(&self) -> Buffer {
255
+ self.private_key_inner.clone().unwrap().into()
256
+ }
257
+
258
+ #[napi]
259
+ pub fn public_key_jwk(&self) -> Result<JsonWebKey> {
260
+ let Some(ref public_key_inner) = self.public_key_inner else {
261
+ return Err(napi::Error::from_reason("no public_key_inner"));
262
+ };
263
+
264
+ Ok(JsonWebKey {
265
+ kid: self.id.to_owned(),
266
+ kty: JwkKty::EC.into(),
267
+ crv: BlsCurveName::G2.into(),
268
+ x: URL_SAFE_NO_PAD.encode(public_key_inner),
269
+ use_: None,
270
+ key_ops: None,
271
+ alg: None,
272
+ d: None,
273
+ y: None,
274
+ ext: None,
275
+ })
276
+ }
277
+
278
+ #[napi(getter)]
279
+ pub fn private_key(&self) -> Option<String> {
280
+ self
281
+ .private_key_inner
282
+ .clone()
283
+ .map(|b| bs58::encode(b).into_string())
284
+ }
285
+
286
+ #[napi]
287
+ pub fn private_key_jwk(&self) -> Result<JsonWebKey> {
288
+ let Some(ref public_key_inner) = self.public_key_inner else {
289
+ return Err(napi::Error::from_reason("no public_key_inner"));
290
+ };
291
+
292
+ let Some(ref private_key_inner) = self.private_key_inner else {
293
+ return Err(napi::Error::from_reason("no private_key_inner"));
294
+ };
295
+
296
+ Ok(JsonWebKey {
297
+ kid: self.id.to_owned(),
298
+ kty: JwkKty::EC.into(),
299
+ crv: BlsCurveName::G2.into(),
300
+ x: URL_SAFE_NO_PAD.encode(public_key_inner),
301
+ d: Some(URL_SAFE_NO_PAD.encode(private_key_inner)),
302
+ use_: None,
303
+ key_ops: None,
304
+ alg: None,
305
+ y: None,
306
+ ext: None,
307
+ })
308
+ }
309
+
310
+ #[napi]
311
+ pub fn signer(&self) -> KeyPairSigner {
312
+ KeyPairSigner { key: self.clone() }
313
+ }
314
+
315
+ #[napi]
316
+ pub fn verifier(&self) -> KeyPairVerifier {
317
+ KeyPairVerifier { key: self.clone() }
318
+ }
319
+
320
+ #[napi]
321
+ pub fn fingerprint(&self) -> Result<String> {
322
+ let Some(public_key_base58) = self.public_key() else {
323
+ return Err(napi::Error::from_reason("no public key"));
324
+ };
325
+ Bls12381G2KeyPair::fingerprint_from_public_key(FingerPrintFromPublicKeyOptions {
326
+ public_key_base58,
327
+ })
328
+ }
329
+
330
+ #[napi]
331
+ pub fn fingerprint_from_public_key(options: FingerPrintFromPublicKeyOptions) -> Result<String> {
332
+ let FingerPrintFromPublicKeyOptions { public_key_base58 } = options;
333
+ let mut key_bytes = bs58::decode(public_key_base58).into_vec().map_err(|err| {
334
+ napi::Error::from_reason(format!(
335
+ "failed to decode public_key_base58 value. error: {err}"
336
+ ))
337
+ })?;
338
+
339
+ let mut buffer = vec![
340
+ BLS12381G2_MULTICODEC_IDENTIFIER,
341
+ VARIABLE_INTEGER_TRAILING_BYTE,
342
+ ];
343
+ buffer.append(&mut key_bytes);
344
+
345
+ Ok(format!(
346
+ "{}{}",
347
+ MULTIBASE_ENCODED_BASE58_IDENTIFIER,
348
+ bs58::encode(buffer).into_string()
349
+ ))
350
+ }
351
+
352
+ #[napi]
353
+ pub fn verify_fingerprint(&self, fingerprint: String) -> Result<()> {
354
+ // fingerprint should have `z` prefix indicating
355
+ // that it's multi-base encoded
356
+ let mut chars = fingerprint.chars();
357
+ let head = chars
358
+ .next()
359
+ .ok_or(napi::Error::from_reason("fingerprint string is empty"))?
360
+ .to_string();
361
+
362
+ let rest = chars.collect::<String>();
363
+
364
+ if head != MULTIBASE_ENCODED_BASE58_IDENTIFIER {
365
+ return Err(napi::Error::from_reason(
366
+ "`fingerprint` must be a multibase encoded string.",
367
+ ));
368
+ };
369
+
370
+ let fingerprint_buffer = bs58::decode(rest).into_vec().map_err(|err| {
371
+ napi::Error::from_reason(format!("failed to decode bs58 value: error: {err}"))
372
+ })?;
373
+
374
+ let public_key_inner = self
375
+ .public_key_inner
376
+ .clone()
377
+ .ok_or(napi::Error::from_reason("public key buffer is missing"))?;
378
+
379
+ let leader = hex::encode(&fingerprint_buffer[..2]);
380
+ let leader_match = if leader == "eb01" { true } else { false };
381
+ let bytes_match = if &public_key_inner == &fingerprint_buffer[2..] {
382
+ true
383
+ } else {
384
+ false
385
+ };
386
+
387
+ if leader_match && bytes_match {
388
+ Ok(())
389
+ } else {
390
+ Err(napi::Error::from_reason(
391
+ "The fingerprint does not match the public key",
392
+ ))
393
+ }
394
+ }
395
+ }
396
+
397
+ pub fn convert_base64_url_to_base58(value: String) -> Result<String> {
398
+ let decoded = URL_SAFE.decode(value).map_err(|err| {
399
+ napi::Error::from_reason(format!("failed to decode base64 url_safe. error {err}"))
400
+ })?;
401
+ Ok(bs58::encode(decoded).into_string())
402
+ }
403
+
404
+ #[derive(Clone)]
405
+ #[napi]
406
+ pub struct KeyPairSigner {
407
+ key: Bls12381G2KeyPair,
408
+ }
409
+
410
+ #[napi(object)]
411
+ pub struct KeyPairSignerOptions {
412
+ pub data: Vec<Uint8Array>,
413
+ }
414
+
415
+ #[napi]
416
+ impl KeyPairSigner {
417
+ #[napi]
418
+ pub async fn sign(&self, options: KeyPairSignerOptions) -> Result<Uint8Array> {
419
+ if self.key.private_key_inner.is_none() {
420
+ return Err(napi::Error::from_reason("No private key to sign with."));
421
+ }
422
+
423
+ let messages: Vec<Vec<u8>> = options.data.into_iter().map(|x| x.to_vec()).collect();
424
+ let key_pair = BlsKeyPair {
425
+ public_key: self.key.public_key_inner.clone(),
426
+ secret_key: self.key.private_key_inner.clone(),
427
+ };
428
+ let sig = bls_sign(BlsBbsSignRequest { messages, key_pair })
429
+ .await
430
+ .map_err(|err| napi::Error::from_reason(format!("bls_signed failed: {err}")))?;
431
+
432
+ Ok(Uint8Array::from(sig))
433
+ }
434
+ }
435
+
436
+ #[napi]
437
+ pub struct KeyPairVerifier {
438
+ key: Bls12381G2KeyPair,
439
+ }
440
+
441
+ #[napi(object)]
442
+ pub struct KeyPairVerifierOptions {
443
+ pub data: Vec<Uint8Array>,
444
+ pub signature: Uint8Array,
445
+ }
446
+
447
+ #[napi]
448
+ impl KeyPairVerifier {
449
+ #[napi]
450
+ pub async fn verify(&self, options: KeyPairVerifierOptions) -> Result<bool> {
451
+ let KeyPairVerifierOptions { data, signature } = options;
452
+ let Some(public_key) = self.key.public_key_inner.clone() else {
453
+ return Err(napi::Error::from_reason(
454
+ "key.public_key is required for verify",
455
+ ));
456
+ };
457
+ let signature = signature.to_vec();
458
+ let messages = data.into_iter().map(|a| a.to_vec()).collect::<Vec<_>>();
459
+
460
+ let verified = bls_verify(BlsBbsVerifyRequest {
461
+ public_key,
462
+ signature,
463
+ messages,
464
+ })
465
+ .await
466
+ .map_err(|err| napi::Error::from_reason(format!("bls_verify failed: {err}")))?;
467
+
468
+ Ok(verified)
469
+ }
470
+ }
@@ -1,16 +1,5 @@
1
1
  use napi::bindgen_prelude::*;
2
2
 
3
- #[derive(Clone)]
4
- #[napi]
5
- pub struct Bls12381G2KeyPair {
6
- pub id: Option<String>,
7
- pub controller: Option<String>,
8
- pub private_key_inner: Option<Vec<u8>>,
9
- pub public_key_inner: Option<Vec<u8>>,
10
- #[napi(js_name = "type")]
11
- pub type_: String,
12
- }
13
-
14
3
  #[napi(object)]
15
4
  pub struct KeyPairOptions {
16
5
  pub id: Option<String>,
@@ -1,4 +1,4 @@
1
- use crate::types::{BlsCurveName, JsonWebKey, JwkKty};
1
+ use super::types::{BlsCurveName, JsonWebKey, JwkKty};
2
2
 
3
3
  pub fn check_common_bls_jwk_values(jwk: &JsonWebKey) -> napi::Result<()> {
4
4
  BlsCurveName::try_from(jwk.crv.as_str())?;
@@ -0,0 +1,70 @@
1
+ #![allow(dead_code)]
2
+ use napi::bindgen_prelude::*;
3
+
4
+ use super::bls_12381_g2_keypair::Bls12381G2KeyPair;
5
+ use types::BoundKeyPairOptions;
6
+
7
+ pub mod types;
8
+
9
+ #[napi]
10
+ pub struct BoundBls12381G2KeyPair {
11
+ inner: Bls12381G2KeyPair,
12
+ commitment_bytes: Vec<u8>,
13
+ blinded_indices: Vec<usize>,
14
+ }
15
+
16
+ #[napi]
17
+ impl BoundBls12381G2KeyPair {
18
+ #[napi(constructor)]
19
+ pub fn new(options: BoundKeyPairOptions) -> Self {
20
+ let inner = Bls12381G2KeyPair::new(Some(
21
+ super::bls_12381_g2_keypair::types::KeyPairOptions {
22
+ id: options.id,
23
+ controller: options.controller,
24
+ public_key_base58: options.public_key_base58,
25
+ private_key_base58: options.private_key_base58,
26
+ },
27
+ ));
28
+
29
+ Self {
30
+ inner,
31
+ commitment_bytes: options.commitment.to_vec(),
32
+ blinded_indices: options.blinded.iter().map(|&i| i as usize).collect(),
33
+ }
34
+ }
35
+
36
+ #[napi(factory)]
37
+ pub fn from(options: BoundKeyPairOptions) -> Self {
38
+ Self::new(options)
39
+ }
40
+
41
+ #[napi(getter)]
42
+ pub fn commitment(&self) -> Uint8Array {
43
+ Uint8Array::from(self.commitment_bytes.clone())
44
+ }
45
+
46
+ #[napi(getter)]
47
+ pub fn blinded(&self) -> Vec<u32> {
48
+ self.blinded_indices.iter().map(|&i| i as u32).collect()
49
+ }
50
+
51
+ /// Convert to a Rust core BoundBls12381G2KeyPair for use in signing.
52
+ pub(crate) fn to_rust_bound_key(
53
+ &self,
54
+ ) -> vc::jsonld::signatures::bbs::bound_keypair::BoundBls12381G2KeyPair {
55
+ let rust_key = vc::jsonld::signatures::bbs::bls_12381_g2_keypair::Bls12381G2KeyPair::new(
56
+ Some(vc::jsonld::signatures::bbs::bls_12381_g2_keypair::types::KeyPairOptions {
57
+ id: self.inner.id.clone(),
58
+ controller: self.inner.controller.clone(),
59
+ public_key_base58: self.inner.public_key(),
60
+ private_key_base58: self.inner.private_key(),
61
+ }),
62
+ );
63
+
64
+ vc::jsonld::signatures::bbs::bound_keypair::BoundBls12381G2KeyPair::new(
65
+ rust_key,
66
+ self.commitment_bytes.clone(),
67
+ self.blinded_indices.clone(),
68
+ )
69
+ }
70
+ }
@@ -0,0 +1,11 @@
1
+ use napi::bindgen_prelude::*;
2
+
3
+ #[napi(object)]
4
+ pub struct BoundKeyPairOptions {
5
+ pub id: Option<String>,
6
+ pub controller: Option<String>,
7
+ pub public_key_base58: Option<String>,
8
+ pub private_key_base58: Option<String>,
9
+ pub commitment: Uint8Array,
10
+ pub blinded: Vec<u32>,
11
+ }
@@ -0,0 +1,6 @@
1
+ mod bbs_bls_holder_bound_signature_2022;
2
+ mod bbs_bls_holder_bound_signature_proof_2022;
3
+ mod bbs_bls_signature_2020;
4
+ mod bbs_bls_signature_proof_2020;
5
+ mod bls_12381_g2_keypair;
6
+ mod bound_bls_12381_g2_keypair;