@nuggetslife/vc 0.0.21 → 0.0.23

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
@@ -164,6 +164,120 @@ export interface BoundKeyPairOptions {
164
164
  commitment: Uint8Array
165
165
  blinded: Array<number>
166
166
  }
167
+ export const enum JoseNamedCurve {
168
+ P256 = 0,
169
+ P384 = 1,
170
+ P521 = 2,
171
+ Secp256k1 = 3,
172
+ Ed25519 = 4,
173
+ Ed448 = 5,
174
+ X25519 = 6,
175
+ X448 = 7
176
+ }
177
+ export const enum JoseContentEncryption {
178
+ A128gcm = 0,
179
+ A192gcm = 1,
180
+ A256gcm = 2,
181
+ A128cbcHs256 = 3,
182
+ A192cbcHs384 = 4,
183
+ A256cbcHs512 = 5
184
+ }
185
+ export const enum JoseKeyEncryption {
186
+ Dir = 0,
187
+ EcdhEs = 1,
188
+ EcdhEsA128kw = 2,
189
+ EcdhEsA192kw = 3,
190
+ EcdhEsA256kw = 4,
191
+ Rsa1_5 = 5,
192
+ RsaOaep = 6,
193
+ RsaOaep256 = 7,
194
+ RsaOaep384 = 8,
195
+ RsaOaep512 = 9,
196
+ Pbes2Hs256A128kw = 10,
197
+ Pbes2Hs384A192kw = 11,
198
+ Pbes2Hs512A256kw = 12,
199
+ A128kw = 13,
200
+ A192kw = 14,
201
+ A256kw = 15,
202
+ A128gcmkw = 16,
203
+ A192gcmkw = 17,
204
+ A256gcmkw = 18
205
+ }
206
+ export const enum JoseSigningAlgorithm {
207
+ Es256 = 0,
208
+ Es384 = 1,
209
+ Es512 = 2,
210
+ Es256k = 3,
211
+ Eddsa = 4,
212
+ Hs256 = 5,
213
+ Hs384 = 6,
214
+ Hs512 = 7,
215
+ Rs256 = 8,
216
+ Rs384 = 9,
217
+ Rs512 = 10,
218
+ Ps256 = 11,
219
+ Ps384 = 12,
220
+ Ps512 = 13
221
+ }
222
+ export interface JoseEncryptResult {
223
+ ciphertext: string
224
+ tag?: string
225
+ }
226
+ /**
227
+ * Generate a JWK key pair and return the JWK (public + private) as a JSON object.
228
+ * Matches ffi-jose `generateJWK({ namedCurve })`.
229
+ */
230
+ export declare function generateJwk(namedCurve: JoseNamedCurve): any
231
+ /**
232
+ * Generate a full key pair (JWK, PEM, DER formats) and return as a JSON object.
233
+ * Matches ffi-jose `generateKeyPair(type, { namedCurve })`.
234
+ */
235
+ export declare function generateKeyPair(namedCurve: JoseNamedCurve): any
236
+ /**
237
+ * Low-level symmetric encryption. Key and IV as hex strings, plaintext as base64.
238
+ * Matches ffi-jose `encrypt(enc, plaintext, cek, iv, aad, didcomm)`.
239
+ */
240
+ export declare function joseEncrypt(enc: JoseContentEncryption, key: string, iv: string, message: string, aad?: string | undefined | null): JoseEncryptResult
241
+ /**
242
+ * Low-level symmetric decryption. Returns base64-encoded plaintext.
243
+ * Matches ffi-jose `decrypt(enc, cek, ciphertext, iv, tag, aad)`.
244
+ */
245
+ export declare function joseDecrypt(enc: JoseContentEncryption, key: string, iv: string, ciphertext: string, aad?: string | undefined | null, tag?: string | undefined | null): string
246
+ /**
247
+ * Encrypt a JSON payload for one or more recipients using JWE General JSON serialization.
248
+ * Matches ffi-jose `generalEncryptJson(alg, enc, payload, recipients, didcomm)`.
249
+ */
250
+ export declare function generalEncryptJson(alg: JoseKeyEncryption, enc: JoseContentEncryption, payload: any, recipients: Array<any>, didcomm?: boolean | undefined | null): any
251
+ /**
252
+ * Decrypt a JWE JSON object using a JWK private key.
253
+ * Matches ffi-jose `decryptJson(jwe, jwk)`.
254
+ */
255
+ export declare function decryptJson(jwe: any, jwk: any): any
256
+ /**
257
+ * Sign a JSON payload using JWS Compact serialization.
258
+ * Matches ffi-jose `compactSignJson(alg, payload, jwk, didcomm)`.
259
+ */
260
+ export declare function compactSignJson(alg: JoseSigningAlgorithm, payload: any, jwk: any, didcomm?: boolean | undefined | null): string
261
+ /**
262
+ * Verify a JWS Compact serialization and return the payload.
263
+ * Matches ffi-jose `compactJsonVerify(jws, jwk)`.
264
+ */
265
+ export declare function compactJsonVerify(jws: string, jwk: any): any
266
+ /**
267
+ * Sign a JSON payload using JWS Flattened JSON serialization.
268
+ * Matches ffi-jose `flattenedSignJson(alg, payload, jwk, didcomm)`.
269
+ */
270
+ export declare function flattenedSignJson(alg: JoseSigningAlgorithm, payload: any, jwk: any, didcomm?: boolean | undefined | null): any
271
+ /**
272
+ * Verify a JWS Flattened or General JSON serialization and return the payload.
273
+ * Matches ffi-jose `jsonVerify(jws, jwk)`.
274
+ */
275
+ export declare function jsonVerify(jws: any, jwk: any): any
276
+ /**
277
+ * Sign a JSON payload using JWS General JSON serialization with multiple signers.
278
+ * Matches ffi-jose `generalSignJson(payload, jwks, didcomm)`.
279
+ */
280
+ export declare function generalSignJson(payload: any, jwks: Array<any>, didcomm?: boolean | undefined | null): any
167
281
  /**
168
282
  * Sign a document with BbsBlsSignature2020 and embed the proof.
169
283
  *
package/index.js CHANGED
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { BbsBlsHolderBoundSignature2022, BbsBlsHolderBoundSignatureProof2022, BbsBlsSignature2020, BbsBlsSignatureProof2020, Bls12381G2KeyPair, KeyPairSigner, KeyPairVerifier, BoundBls12381G2KeyPair, JsonLd, ldSign, ldVerify, ldDeriveProof, deriveProof, createCommitment, verifyCommitment, unblindSignature, deriveProofHolderBound } = nativeBinding
313
+ const { BbsBlsHolderBoundSignature2022, BbsBlsHolderBoundSignatureProof2022, BbsBlsSignature2020, BbsBlsSignatureProof2020, Bls12381G2KeyPair, KeyPairSigner, KeyPairVerifier, BoundBls12381G2KeyPair, JoseNamedCurve, JoseContentEncryption, JoseKeyEncryption, JoseSigningAlgorithm, generateJwk, generateKeyPair, joseEncrypt, joseDecrypt, generalEncryptJson, decryptJson, compactSignJson, compactJsonVerify, flattenedSignJson, jsonVerify, generalSignJson, JsonLd, ldSign, ldVerify, ldDeriveProof, deriveProof, createCommitment, verifyCommitment, unblindSignature, deriveProofHolderBound } = nativeBinding
314
314
 
315
315
  module.exports.BbsBlsHolderBoundSignature2022 = BbsBlsHolderBoundSignature2022
316
316
  module.exports.BbsBlsHolderBoundSignatureProof2022 = BbsBlsHolderBoundSignatureProof2022
@@ -320,6 +320,21 @@ module.exports.Bls12381G2KeyPair = Bls12381G2KeyPair
320
320
  module.exports.KeyPairSigner = KeyPairSigner
321
321
  module.exports.KeyPairVerifier = KeyPairVerifier
322
322
  module.exports.BoundBls12381G2KeyPair = BoundBls12381G2KeyPair
323
+ module.exports.JoseNamedCurve = JoseNamedCurve
324
+ module.exports.JoseContentEncryption = JoseContentEncryption
325
+ module.exports.JoseKeyEncryption = JoseKeyEncryption
326
+ module.exports.JoseSigningAlgorithm = JoseSigningAlgorithm
327
+ module.exports.generateJwk = generateJwk
328
+ module.exports.generateKeyPair = generateKeyPair
329
+ module.exports.joseEncrypt = joseEncrypt
330
+ module.exports.joseDecrypt = joseDecrypt
331
+ module.exports.generalEncryptJson = generalEncryptJson
332
+ module.exports.decryptJson = decryptJson
333
+ module.exports.compactSignJson = compactSignJson
334
+ module.exports.compactJsonVerify = compactJsonVerify
335
+ module.exports.flattenedSignJson = flattenedSignJson
336
+ module.exports.jsonVerify = jsonVerify
337
+ module.exports.generalSignJson = generalSignJson
323
338
  module.exports.JsonLd = JsonLd
324
339
  module.exports.ldSign = ldSign
325
340
  module.exports.ldVerify = ldVerify
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuggetslife/vc",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "napi": {
@@ -22,10 +22,7 @@
22
22
  "@mattrglobal/jsonld-signatures-bbs": "^1.2.0",
23
23
  "@napi-rs/cli": "^2.18.3",
24
24
  "@types/node": "^20.14.9",
25
- "ava": "^6.0.1"
26
- },
27
- "ava": {
28
- "timeout": "3m"
25
+ "jsonld": "^8.3.3"
29
26
  },
30
27
  "engines": {
31
28
  "node": ">= 10"
@@ -35,17 +32,17 @@
35
32
  "build": "napi build --platform --release",
36
33
  "build:debug": "napi build --platform",
37
34
  "prepublishOnly": "napi prepublish -t npm",
38
- "test": "ava",
35
+ "test": "node test.mjs && node test_jose.mjs && node test_jsonld_crossverify.mjs",
39
36
  "universal": "napi universal",
40
37
  "version": "napi version"
41
38
  },
42
39
  "packageManager": "yarn@4.3.1",
43
40
  "optionalDependencies": {
44
- "@nuggetslife/vc-darwin-arm64": "0.0.21",
45
- "@nuggetslife/vc-linux-arm64-gnu": "0.0.21",
46
- "@nuggetslife/vc-linux-arm64-musl": "0.0.21",
47
- "@nuggetslife/vc-linux-x64-gnu": "0.0.21",
48
- "@nuggetslife/vc-linux-x64-musl": "0.0.21"
41
+ "@nuggetslife/vc-darwin-arm64": "0.0.23",
42
+ "@nuggetslife/vc-linux-arm64-gnu": "0.0.23",
43
+ "@nuggetslife/vc-linux-arm64-musl": "0.0.23",
44
+ "@nuggetslife/vc-linux-x64-gnu": "0.0.23",
45
+ "@nuggetslife/vc-linux-x64-musl": "0.0.23"
49
46
  },
50
47
  "dependencies": {}
51
48
  }
@@ -1,10 +1,10 @@
1
- #![allow(dead_code)]
2
1
  use napi::bindgen_prelude::*;
3
2
  use serde_json::json;
4
3
  use types::{BoundCreateProofOptions, BoundSignatureSuiteOptions, BoundVerifyProofOptions};
5
4
 
5
+ use super::bbs_bls_signature_2020::napi_key_to_rust_key;
6
6
  use super::bls_12381_g2_keypair::Bls12381G2KeyPair;
7
- use crate::ld_signatures::{create_document_loader, parse_contexts};
7
+ use crate::ld_signatures::loader_from_contexts;
8
8
 
9
9
  pub mod types;
10
10
 
@@ -80,22 +80,9 @@ impl BbsBlsHolderBoundSignature2022 {
80
80
  &self,
81
81
  options: BoundCreateProofOptions,
82
82
  ) -> Result<serde_json::Value> {
83
- let additional_contexts = options
84
- .contexts
85
- .as_ref()
86
- .map(|v| parse_contexts(&json!({ "contexts": v })))
87
- .unwrap_or_default();
88
- let (loader, cr) = create_document_loader(additional_contexts);
83
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
89
84
 
90
- let rust_key =
91
- vc::jsonld::signatures::bbs::bls_12381_g2_keypair::Bls12381G2KeyPair::new(Some(
92
- vc::jsonld::signatures::bbs::bls_12381_g2_keypair::types::KeyPairOptions {
93
- id: self.key.id.clone(),
94
- controller: self.key.controller.clone(),
95
- public_key_base58: self.key.public_key(),
96
- private_key_base58: self.key.private_key(),
97
- },
98
- ));
85
+ let rust_key = napi_key_to_rust_key(&self.key);
99
86
 
100
87
  // Commitment/blinded not needed for counting messages — use empty placeholders.
101
88
  let bound_key = vc::jsonld::signatures::bbs::bound_keypair::BoundBls12381G2KeyPair::new(
@@ -128,12 +115,7 @@ impl BbsBlsHolderBoundSignature2022 {
128
115
  &self,
129
116
  options: BoundCreateProofOptions,
130
117
  ) -> Result<serde_json::Value> {
131
- let additional_contexts = options
132
- .contexts
133
- .as_ref()
134
- .map(|v| parse_contexts(&json!({ "contexts": v })))
135
- .unwrap_or_default();
136
- let (loader, cr) = create_document_loader(additional_contexts);
118
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
137
119
 
138
120
  let commitment = self
139
121
  .commitment
@@ -144,15 +126,7 @@ impl BbsBlsHolderBoundSignature2022 {
144
126
  .as_ref()
145
127
  .ok_or_else(|| napi::Error::from_reason("No blinded indices set on suite"))?;
146
128
 
147
- let rust_key =
148
- vc::jsonld::signatures::bbs::bls_12381_g2_keypair::Bls12381G2KeyPair::new(Some(
149
- vc::jsonld::signatures::bbs::bls_12381_g2_keypair::types::KeyPairOptions {
150
- id: self.key.id.clone(),
151
- controller: self.key.controller.clone(),
152
- public_key_base58: self.key.public_key(),
153
- private_key_base58: self.key.private_key(),
154
- },
155
- ));
129
+ let rust_key = napi_key_to_rust_key(&self.key);
156
130
 
157
131
  let bound_key = vc::jsonld::signatures::bbs::bound_keypair::BoundBls12381G2KeyPair::new(
158
132
  rust_key,
@@ -189,12 +163,7 @@ impl BbsBlsHolderBoundSignature2022 {
189
163
  &self,
190
164
  options: BoundVerifyProofOptions,
191
165
  ) -> Result<serde_json::Value> {
192
- let additional_contexts = options
193
- .contexts
194
- .as_ref()
195
- .map(|v| parse_contexts(&json!({ "contexts": v })))
196
- .unwrap_or_default();
197
- let (loader, cr) = create_document_loader(additional_contexts);
166
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
198
167
 
199
168
  let blinding_factor = options.blinding_factor.to_vec();
200
169
  let blinded_messages: Vec<Vec<u8>> =
@@ -2,7 +2,7 @@ use napi::bindgen_prelude::*;
2
2
  use serde_json::json;
3
3
  use types::{BoundDeriveProofOptions, BoundVerifyDerivedProofOptions};
4
4
 
5
- use crate::ld_signatures::{create_document_loader, parse_contexts};
5
+ use crate::ld_signatures::loader_from_contexts;
6
6
 
7
7
  pub mod types;
8
8
 
@@ -27,12 +27,7 @@ impl BbsBlsHolderBoundSignatureProof2022 {
27
27
  &self,
28
28
  options: BoundDeriveProofOptions,
29
29
  ) -> Result<serde_json::Value> {
30
- let additional_contexts = options
31
- .contexts
32
- .as_ref()
33
- .map(|v| parse_contexts(&json!({ "contexts": v })))
34
- .unwrap_or_default();
35
- let (loader, cr) = create_document_loader(additional_contexts);
30
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
36
31
 
37
32
  let blinding_factor = options.blinding_factor.to_vec();
38
33
  let blinded_messages: Vec<Vec<u8>> =
@@ -60,12 +55,7 @@ impl BbsBlsHolderBoundSignatureProof2022 {
60
55
  &self,
61
56
  options: BoundVerifyDerivedProofOptions,
62
57
  ) -> Result<serde_json::Value> {
63
- let additional_contexts = options
64
- .contexts
65
- .as_ref()
66
- .map(|v| parse_contexts(&json!({ "contexts": v })))
67
- .unwrap_or_default();
68
- let (loader, cr) = create_document_loader(additional_contexts);
58
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
69
59
 
70
60
  let purpose = vc::jsonld::signatures::AssertionProofPurpose::new();
71
61
  let result = vc::jsonld::signatures::verify(&options.document, &purpose, loader, cr)
@@ -1,4 +1,3 @@
1
- #![allow(dead_code)]
2
1
  use base64::{engine::general_purpose::STANDARD, Engine as _};
3
2
  use chrono::Utc;
4
3
  use napi::bindgen_prelude::*;
@@ -11,12 +10,12 @@ use types::{
11
10
  use super::bls_12381_g2_keypair::{
12
11
  Bls12381G2KeyPair, KeyPairSigner, KeyPairSignerOptions, KeyPairVerifier, KeyPairVerifierOptions,
13
12
  };
14
- use crate::ld_signatures::{create_document_loader, parse_contexts};
13
+ use crate::ld_signatures::loader_from_contexts;
15
14
 
16
15
  pub mod types;
17
16
 
18
17
  /// Convert a NAPI Bls12381G2KeyPair to a Rust core Bls12381G2KeyPair.
19
- fn napi_key_to_rust_key(
18
+ pub(crate) fn napi_key_to_rust_key(
20
19
  napi_key: &Bls12381G2KeyPair,
21
20
  ) -> vc::jsonld::signatures::bbs::bls_12381_g2_keypair::Bls12381G2KeyPair {
22
21
  vc::jsonld::signatures::bbs::bls_12381_g2_keypair::Bls12381G2KeyPair::new(Some(
@@ -166,12 +165,7 @@ impl BbsBlsSignature2020 {
166
165
  /// Returns just the proof object (matching JS reference behavior).
167
166
  #[napi]
168
167
  pub async fn create_proof(&self, options: CreateProofOptions) -> Result<serde_json::Value> {
169
- let additional_contexts = options
170
- .contexts
171
- .as_ref()
172
- .map(|v| parse_contexts(&json!({ "contexts": v })))
173
- .unwrap_or_default();
174
- let (loader, cr) = create_document_loader(additional_contexts);
168
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
175
169
 
176
170
  let rust_key = napi_key_to_rust_key(&self.key);
177
171
  let suite = vc::jsonld::signatures::bbs::BbsBlsSignature2020::new(
@@ -200,12 +194,7 @@ impl BbsBlsSignature2020 {
200
194
  /// Returns `{ verified: boolean, error?: string }`.
201
195
  #[napi]
202
196
  pub async fn verify_proof(&self, options: VerifyProofOptions) -> Result<serde_json::Value> {
203
- let additional_contexts = options
204
- .contexts
205
- .as_ref()
206
- .map(|v| parse_contexts(&json!({ "contexts": v })))
207
- .unwrap_or_default();
208
- let (loader, cr) = create_document_loader(additional_contexts);
197
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
209
198
 
210
199
  let purpose = vc::jsonld::signatures::AssertionProofPurpose::new();
211
200
  let result = vc::jsonld::signatures::verify(&options.document, &purpose, loader, cr)
@@ -308,22 +297,3 @@ impl BbsBlsSignature2020 {
308
297
  Ok(verified)
309
298
  }
310
299
  }
311
-
312
- #[cfg(test)]
313
- mod tests {
314
-
315
- use super::*;
316
- #[test]
317
- pub fn it_works() {
318
- let mut j = json!({});
319
-
320
- let Some(obj) = j.as_object_mut() else {
321
- return ();
322
- };
323
-
324
- obj.insert(String::from("hello"), "there".into());
325
- let _x = STANDARD.decode("hello");
326
-
327
- println!("{j}")
328
- }
329
- }
@@ -1,4 +1,3 @@
1
- #![allow(dead_code)]
2
1
  use napi::bindgen_prelude::Uint8Array;
3
2
 
4
3
  use crate::bls_signatures::bls_12381_g2_keypair::types::KeyPairOptions;
@@ -2,7 +2,7 @@ use napi::bindgen_prelude::*;
2
2
  use serde_json::json;
3
3
  use types::{DeriveProofOptions, VerifyDerivedProofOptions};
4
4
 
5
- use crate::ld_signatures::{create_document_loader, parse_contexts};
5
+ use crate::ld_signatures::loader_from_contexts;
6
6
 
7
7
  pub mod types;
8
8
 
@@ -24,12 +24,7 @@ impl BbsBlsSignatureProof2020 {
24
24
  /// Derive a selective disclosure proof from a signed document.
25
25
  #[napi]
26
26
  pub async fn derive_proof(&self, options: DeriveProofOptions) -> Result<serde_json::Value> {
27
- let additional_contexts = options
28
- .contexts
29
- .as_ref()
30
- .map(|v| parse_contexts(&json!({ "contexts": v })))
31
- .unwrap_or_default();
32
- let (loader, cr) = create_document_loader(additional_contexts);
27
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
33
28
 
34
29
  let nonce = options.nonce.map(|s| s.as_bytes().to_vec());
35
30
 
@@ -52,12 +47,7 @@ impl BbsBlsSignatureProof2020 {
52
47
  &self,
53
48
  options: VerifyDerivedProofOptions,
54
49
  ) -> Result<serde_json::Value> {
55
- let additional_contexts = options
56
- .contexts
57
- .as_ref()
58
- .map(|v| parse_contexts(&json!({ "contexts": v })))
59
- .unwrap_or_default();
60
- let (loader, cr) = create_document_loader(additional_contexts);
50
+ let (loader, cr) = loader_from_contexts(options.contexts.as_ref());
61
51
 
62
52
  let purpose = vc::jsonld::signatures::AssertionProofPurpose::new();
63
53
  let result = vc::jsonld::signatures::verify(&options.document, &purpose, loader, cr)
@@ -58,12 +58,8 @@ impl Bls12381G2KeyPair {
58
58
  // }
59
59
  // };
60
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());
61
+ let private_key_inner = o.private_key_base58.and_then(|v| bs58::decode(v).into_vec().ok());
62
+ let public_key_inner = o.public_key_base58.and_then(|v| bs58::decode(v).into_vec().ok());
67
63
 
68
64
  Self {
69
65
  id: o.id,
@@ -246,13 +242,21 @@ impl Bls12381G2KeyPair {
246
242
  }
247
243
 
248
244
  #[napi(getter)]
249
- pub fn public_key_buffer(&self) -> Buffer {
250
- self.public_key_inner.clone().unwrap().into()
245
+ pub fn public_key_buffer(&self) -> Result<Buffer> {
246
+ self
247
+ .public_key_inner
248
+ .clone()
249
+ .map(|b| b.into())
250
+ .ok_or_else(|| napi::Error::from_reason("no public key set"))
251
251
  }
252
252
 
253
253
  #[napi(getter)]
254
- pub fn private_key_buffer(&self) -> Buffer {
255
- self.private_key_inner.clone().unwrap().into()
254
+ pub fn private_key_buffer(&self) -> Result<Buffer> {
255
+ self
256
+ .private_key_inner
257
+ .clone()
258
+ .map(|b| b.into())
259
+ .ok_or_else(|| napi::Error::from_reason("no private key set"))
256
260
  }
257
261
 
258
262
  #[napi]
@@ -377,12 +381,8 @@ impl Bls12381G2KeyPair {
377
381
  .ok_or(napi::Error::from_reason("public key buffer is missing"))?;
378
382
 
379
383
  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
- };
384
+ let leader_match = leader == "eb01";
385
+ let bytes_match = public_key_inner == fingerprint_buffer[2..];
386
386
 
387
387
  if leader_match && bytes_match {
388
388
  Ok(())
@@ -1,4 +1,3 @@
1
- #![allow(dead_code)]
2
1
  use napi::bindgen_prelude::*;
3
2
 
4
3
  use super::bls_12381_g2_keypair::Bls12381G2KeyPair;
@@ -64,12 +63,12 @@ impl BoundBls12381G2KeyPair {
64
63
  }
65
64
 
66
65
  #[napi(getter)]
67
- pub fn public_key_buffer(&self) -> Buffer {
66
+ pub fn public_key_buffer(&self) -> Result<Buffer> {
68
67
  self.inner.public_key_buffer()
69
68
  }
70
69
 
71
70
  #[napi(getter)]
72
- pub fn private_key_buffer(&self) -> Buffer {
71
+ pub fn private_key_buffer(&self) -> Result<Buffer> {
73
72
  self.inner.private_key_buffer()
74
73
  }
75
74
 
@@ -84,6 +83,7 @@ impl BoundBls12381G2KeyPair {
84
83
  }
85
84
 
86
85
  /// Convert to a Rust core BoundBls12381G2KeyPair for use in signing.
86
+ #[allow(dead_code)] // Used by holder-bound suite after refactoring
87
87
  pub(crate) fn to_rust_bound_key(
88
88
  &self,
89
89
  ) -> vc::jsonld::signatures::bbs::bound_keypair::BoundBls12381G2KeyPair {