@optimystic/quereus-plugin-crypto 1.27.0 → 1.28.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased — native ECDSA verify
4
+
5
+ - `CryptoBackend` takes two more optional members, `p256Verify` and `secp256k1Verify`, which SQL and
6
+ JS `verify` use for `'p256'` and `'secp256k1'` (GitHub #59: 47 ms and 29 ms a call in JavaScript
7
+ under Hermes, against well under 1 ms in OpenSSL). Each takes the 64-byte compact r‖s signature,
8
+ the message (which it hashes with SHA-256), and a 33- or 65-byte SEC 1 public key.
9
+ - `setCryptoBackend` checks each against `@noble` on a valid signature under both key forms and on
10
+ six inputs `@noble` rejects, among them the high-S copy of a signature and a hybrid-encoded
11
+ (0x06/0x07) key, which OpenSSL accepts by default, and a DER-encoded signature. An adapter over OpenSSL without both guards is
12
+ refused, naming the member and the input. The README's Node adapter shows both guards.
13
+ - ECDSA `sign` stays on `@noble`: a native signer's random nonce could not be checked byte for byte.
14
+ - `verify` now passes `@noble` its ECDSA options explicitly (`prehash`, `lowS`, `compact`); they
15
+ equal the defaults, so no result changes.
16
+
3
17
  ## 1.21.0 — native crypto backend
4
18
 
5
19
  - New `setCryptoBackend(backend)` and `CryptoBackend` exports. An application can route SHA-256,
package/README.md CHANGED
@@ -13,7 +13,7 @@ Quereus plugin providing cryptographic functions for SQL queries with base64url
13
13
  - **Verification Functions**: Signature verification for all supported curves
14
14
  - **Key Generation**: Generate and derive cryptographic keys
15
15
  - **Multiple Encodings**: Support for base64url, base64, hex, utf8, and raw bytes
16
- - **Native Crypto Backend**: Optionally route SHA-256, SHA-512 and Ed25519 to a native library, checked against the JavaScript results when set
16
+ - **Native Crypto Backend**: Optionally route SHA-256, SHA-512, Ed25519, and P-256 and secp256k1 verification to a native library, checked against the JavaScript results when set
17
17
 
18
18
  ## Installation
19
19
 
@@ -355,18 +355,23 @@ By default every hash and signature runs in JavaScript (`@noble/hashes`, `@noble
355
355
  phone that already has fast native crypto, that is the slow part: on a Galaxy S7, one SQL `verify`
356
356
  took 408 ms, 366 ms of it in JavaScript Ed25519, and every `digest` hashed with JavaScript SHA-256
357
357
  even after the app routed `crypto.subtle.digest` to native code (this plugin never calls
358
- `crypto.subtle`). `setCryptoBackend` routes SHA-256, SHA-512 and Ed25519 to a synchronous native
359
- implementation for the whole process:
358
+ `crypto.subtle`). On a Pixel 8 emulator under Hermes, a P-256 `verify` took 47 ms in JavaScript
359
+ against 0.13 ms in OpenSSL, and a secp256k1 one 29 ms against 0.24 ms, paid on every row a schema
360
+ `CHECK` constraint verifies. `setCryptoBackend` routes SHA-256, SHA-512, Ed25519, and P-256 and
361
+ secp256k1 verification to a synchronous native implementation for the whole process:
360
362
 
361
363
  ```ts
362
364
  import { setCryptoBackend } from '@optimystic/quereus-plugin-crypto';
363
365
 
364
- setCryptoBackend({ sha256, sha512, ed25519Sign, ed25519Verify }); // every member optional
366
+ // every member optional
367
+ setCryptoBackend({ sha256, sha512, ed25519Sign, ed25519Verify, p256Verify, secp256k1Verify });
365
368
  ```
366
369
 
367
370
  - **What it speeds up.** `digest`, `cid`, `hash_mod`, `set_commit` and `set_verify` whenever they
368
- hash with sha256 or sha512, and `sign` / `verify` with `'ed25519'`. BLAKE3, secp256k1 and P-256
369
- stay on `@noble`, and so does any member the backend omits.
371
+ hash with sha256 or sha512, `sign` / `verify` with `'ed25519'`, and `verify` with `'p256'` and
372
+ `'secp256k1'`. BLAKE3 and ECDSA `sign` stay on `@noble`, and so does any member the backend omits.
373
+ There is no native ECDSA signing member because OpenSSL signs ECDSA with a random nonce unless asked
374
+ for RFC 6979, so its signature could not be checked byte for byte against `@noble`'s deterministic one.
370
375
  - **Set it once, at startup, for the whole process.** One call reaches the JS API and every
371
376
  `Database`'s SQL functions, including those loaded from `@optimystic/quereus-plugin-crypto/plugin`
372
377
  and those registered *before* the call: each hash and signature reads the installed backend when
@@ -377,7 +382,10 @@ setCryptoBackend({ sha256, sha512, ed25519Sign, ed25519Verify }); // every membe
377
382
  inputs: a hash must equal the `@noble/hashes` one; `ed25519Sign` must produce exactly the
378
383
  `@noble/curves` signature for a fixed raw 32-byte seed (Ed25519 signing is deterministic);
379
384
  `ed25519Verify` must accept that signature and reject it once one byte of the message is flipped.
380
- The inputs are views at a non-zero offset into a larger buffer, so an adapter that hands the native
385
+ `p256Verify` and `secp256k1Verify` must accept a fixed signature under both the 33-byte compressed
386
+ and the 65-byte uncompressed key, and reject six inputs `@noble` rejects: the message with one byte
387
+ flipped, the high-S copy of the signature (s replaced by n − s), r = 0, r = n, the uncompressed
388
+ key re-prefixed as hybrid (0x06 or 0x07), and the signature re-encoded as DER. The inputs are views at a non-zero offset into a larger buffer, so an adapter that hands the native
381
389
  side `data.buffer` instead of the view fails too. On any failure `setCryptoBackend` throws, naming
382
390
  the member, and the previously installed backend (or `@noble`) stays in place, so the mistake shows
383
391
  at app start rather than as wrong signatures persisted and replicated.
@@ -390,6 +398,17 @@ setCryptoBackend({ sha256, sha512, ed25519Sign, ed25519Verify }); // every membe
390
398
  or signature must throw or return `false`, as `@noble` does. Every array a member returns must be
391
399
  newly allocated: a raw-bytes result reaches the caller uncopied, so a library that reuses one output
392
400
  buffer would rewrite results already returned.
401
+ - **ECDSA verify must match `@noble`'s rules.** `@noble` hashes the message with SHA-256 itself,
402
+ takes only the 64-byte compact r‖s form (never DER), and rejects a high-S signature (s > n/2), r or
403
+ s outside [1, n−1], and any public key but a 33-byte one prefixed 0x02 or 0x03 or a 65-byte one
404
+ prefixed 0x04. OpenSSL, and so `node:crypto`, accepts high-S signatures and hybrid-encoded keys.
405
+ Both are reachable by anyone who can write a row: replacing s by n − s turns an honest signature
406
+ into one OpenSSL accepts and `@noble` refuses, and so does re-encoding the key as hybrid. `verify`
407
+ runs inside `CHECK` constraints on replicated rows, so a member that accepted either would let a
408
+ machine with the backend accept a row every other machine rejects. The self-check refuses an
409
+ adapter missing either guard, naming the member and the input it accepted; the adapter below has
410
+ both. It also refuses one that verifies DER (`dsaEncoding: 'der'`, or a fallback to it), since an
411
+ honest signature re-encoded as DER needs no secret either; pass `'ieee-p1363'`, as below.
393
412
  - **Ed25519 strictness differs on crafted input.** `@noble` verifies under the ZIP-215 rule, which
394
413
  accepts some non-canonical point encodings and small-order components that an RFC 8032-strict
395
414
  library such as OpenSSL rejects. Honest signatures verify identically either way. A deliberately
@@ -397,8 +416,9 @@ setCryptoBackend({ sha256, sha512, ed25519Sign, ed25519Verify }); // every membe
397
416
  only where peers re-execute a statement whose outcome depends on `verify`, which no Optimystic
398
417
  deployment does today.
399
418
 
400
- A working adapter for Node.js, on `node:crypto`. Raw Ed25519 keys are wrapped as DER (PKCS#8 for the
401
- 32-byte seed, SPKI for the 32-byte public key) because that is the form the Node API takes:
419
+ A working adapter for Node.js, on `node:crypto`. Raw keys are wrapped as DER (PKCS#8 for the Ed25519
420
+ 32-byte seed, SPKI for every public key) because that is the form the Node API takes, and the ECDSA
421
+ members refuse the two inputs OpenSSL would otherwise accept:
402
422
 
403
423
  ```ts
404
424
  import { createHash, createPrivateKey, createPublicKey, sign, verify } from 'node:crypto';
@@ -407,6 +427,31 @@ import { setCryptoBackend } from '@optimystic/quereus-plugin-crypto';
407
427
  const PKCS8_ED25519_PREFIX = Buffer.from('302e020100300506032b657004220420', 'hex');
408
428
  const SPKI_ED25519_PREFIX = Buffer.from('302a300506032b6570032100', 'hex');
409
429
 
430
+ type EcdsaCurve = 'p256' | 'secp256k1';
431
+ // SPKI DER prefix for a raw SEC 1 point, by key length: id-ecPublicKey, the curve's OID, the BIT STRING header.
432
+ const SPKI_EC_PREFIX: Record<EcdsaCurve, Record<number, string>> = {
433
+ p256: { 33: '3039301306072a8648ce3d020106082a8648ce3d030107032200', 65: '3059301306072a8648ce3d020106082a8648ce3d030107034200' },
434
+ secp256k1: { 33: '3036301006072a8648ce3d020106052b8104000a032200', 65: '3056301006072a8648ce3d020106052b8104000a034200' },
435
+ };
436
+ const CURVE_ORDER: Record<EcdsaCurve, bigint> = {
437
+ p256: 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n,
438
+ secp256k1: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,
439
+ };
440
+
441
+ const ecdsaVerify = (curve: EcdsaCurve) => (signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean => {
442
+ if (signature.length !== 64) return false;
443
+ const prefixOk = (publicKey.length === 33 && (publicKey[0] === 0x02 || publicKey[0] === 0x03))
444
+ || (publicKey.length === 65 && publicKey[0] === 0x04);
445
+ if (!prefixOk) return false; // OpenSSL accepts hybrid 0x06/0x07 keys; @noble does not
446
+ const n = CURVE_ORDER[curve];
447
+ const r = BigInt('0x' + Buffer.from(signature.subarray(0, 32)).toString('hex'));
448
+ const s = BigInt('0x' + Buffer.from(signature.subarray(32)).toString('hex'));
449
+ if (r === 0n || s === 0n || r >= n || s > n / 2n) return false; // OpenSSL accepts high-S
450
+ const prefix = Buffer.from(SPKI_EC_PREFIX[curve][publicKey.length]!, 'hex');
451
+ const key = createPublicKey({ key: Buffer.concat([prefix, publicKey]), format: 'der', type: 'spki' });
452
+ return verify('sha256', message, { key, dsaEncoding: 'ieee-p1363' }, signature);
453
+ };
454
+
410
455
  setCryptoBackend({
411
456
  sha256: (data) => createHash('sha256').update(data).digest(),
412
457
  sha512: (data) => createHash('sha512').update(data).digest(),
@@ -414,12 +459,14 @@ setCryptoBackend({
414
459
  createPrivateKey({ key: Buffer.concat([PKCS8_ED25519_PREFIX, secretKey]), format: 'der', type: 'pkcs8' })),
415
460
  ed25519Verify: (signature, message, publicKey) => verify(null, message,
416
461
  createPublicKey({ key: Buffer.concat([SPKI_ED25519_PREFIX, publicKey]), format: 'der', type: 'spki' }), signature),
462
+ p256Verify: ecdsaVerify('p256'),
463
+ secp256k1Verify: ecdsaVerify('secp256k1'),
417
464
  });
418
465
  ```
419
466
 
420
467
  `react-native-quick-crypto` mirrors this API, so the same shape is the starting point on a phone.
421
- Whether its synchronous Ed25519 accepts these keys unchanged has not been confirmed; if it does not,
422
- `setCryptoBackend` throws at startup rather than producing wrong signatures.
468
+ Whether its synchronous Ed25519 and ECDSA accept these keys and options unchanged has not been
469
+ confirmed; if they do not, `setCryptoBackend` throws at startup rather than producing wrong results.
423
470
 
424
471
  ## Supported Algorithms
425
472
 
@@ -579,7 +626,7 @@ Derive the public key from a private key.
579
626
 
580
627
  ## Security Notes
581
628
 
582
- - All cryptographic operations use audited libraries (@noble/*), unless a [native crypto backend](#native-crypto-backend) is installed, in which case SHA-2 and Ed25519 run in that library
629
+ - All cryptographic operations use audited libraries (@noble/*), unless a [native crypto backend](#native-crypto-backend) is installed, in which case SHA-2, Ed25519, and P-256 and secp256k1 verification run in that library
583
630
  - Private keys should be handled securely and never exposed
584
631
  - Random number generation uses platform CSPRNG (crypto.getRandomValues)
585
632
  - Signatures use deterministic k-generation (RFC 6979)
@@ -592,7 +639,8 @@ These functions run on React Native without any native module. By default they u
592
639
  - `@noble/hashes` for hashing
593
640
  - `crypto.getRandomValues()` for secure randomness (polyfill required for React Native)
594
641
 
595
- An app that has native crypto can route SHA-256, SHA-512 and Ed25519 to it; see
642
+ An app that has native crypto can route SHA-256, SHA-512, Ed25519, and P-256 and secp256k1
643
+ verification to it; see
596
644
  [Native crypto backend](#native-crypto-backend).
597
645
 
598
646
  ## License
package/dist/index.d.ts CHANGED
@@ -24,9 +24,13 @@ type OutputEncoder = (bytes: Uint8Array) => string | Uint8Array;
24
24
  * `digest`, `cid` and `set_commit` are `replicable`, and their outputs are signed
25
25
  * and persisted. {@link setCryptoBackend} checks each supplied member against
26
26
  * @noble before installing it. A member handed a malformed key or signature must
27
- * throw or return false, as @noble does; that is not checked. Each returned array
28
- * must be freshly allocated: under the `bytes` encoding it reaches the caller
29
- * uncopied, so a native library's reused output buffer would rewrite earlier results.
27
+ * throw or return false, as @noble does; beyond the ECDSA inputs listed on
28
+ * `p256Verify`, that is not checked. Each returned array must be freshly allocated:
29
+ * under the `bytes` encoding it reaches the caller uncopied, so a native library's
30
+ * reused output buffer would rewrite earlier results.
31
+ *
32
+ * There is no ECDSA signing member: a native ECDSA signer draws a random nonce unless it
33
+ * implements RFC 6979, so its signature could not be checked byte for byte against @noble's.
30
34
  */
31
35
  interface CryptoBackend {
32
36
  sha256?(data: Uint8Array): Uint8Array;
@@ -35,6 +39,19 @@ interface CryptoBackend {
35
39
  ed25519Verify?(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
36
40
  /** Message, raw 32-byte secret seed (the form noble and generatePrivateKey('ed25519') use). Returns the raw 64-byte signature. */
37
41
  ed25519Sign?(message: Uint8Array, secretKey: Uint8Array): Uint8Array;
42
+ /**
43
+ * 64-byte compact r‖s signature (big-endian, 32 bytes each), message, 33- or 65-byte SEC 1
44
+ * public key. The member hashes the message with SHA-256 itself; it is never handed a digest.
45
+ * It must decide exactly as @noble/curves' verify does: reject any signature but the 64-byte
46
+ * compact form (a DER one included: the caller's bytes are passed through unchecked), a high-S
47
+ * signature (s > n/2), r or s outside [1, n−1], and any key but 0x02/0x03 with 33 bytes or 0x04
48
+ * with 65. OpenSSL
49
+ * accepts high-S signatures and hybrid 0x06/0x07 keys, so an adapter over it must refuse both
50
+ * itself. Returns false, or throws, for an invalid signature or key.
51
+ */
52
+ p256Verify?(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
53
+ /** As `p256Verify`, over secp256k1. */
54
+ secp256k1Verify?(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
38
55
  }
39
56
  /**
40
57
  * Install a backend for this process, or pass undefined to restore the @noble defaults.
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { utf8ToBytes, concatBytes, randomBytes as randomBytes$1 } from '@noble/h
4
4
  import { secp256k1 } from '@noble/curves/secp256k1.js';
5
5
  import { p256 } from '@noble/curves/nist.js';
6
6
  import { ed25519 } from '@noble/curves/ed25519.js';
7
- import { bytesToHex, hexToBytes } from '@noble/curves/utils.js';
7
+ import { hexToBytes, bytesToHex } from '@noble/curves/utils.js';
8
8
  import { toString, fromString } from 'uint8arrays';
9
9
  import { CID } from 'multiformats/cid';
10
10
  import * as Digest from 'multiformats/hashes/digest';
@@ -68,12 +68,14 @@ function setCryptoBackend(backend) {
68
68
  backendSlot[BACKEND_KEY] = installed;
69
69
  }
70
70
  function snapshotBackend(backend) {
71
- var _a, _b, _c, _d;
71
+ var _a, _b, _c, _d, _e, _f;
72
72
  return Object.freeze({
73
73
  sha256: (_a = backend.sha256) == null ? void 0 : _a.bind(backend),
74
74
  sha512: (_b = backend.sha512) == null ? void 0 : _b.bind(backend),
75
75
  ed25519Verify: (_c = backend.ed25519Verify) == null ? void 0 : _c.bind(backend),
76
- ed25519Sign: (_d = backend.ed25519Sign) == null ? void 0 : _d.bind(backend)
76
+ ed25519Sign: (_d = backend.ed25519Sign) == null ? void 0 : _d.bind(backend),
77
+ p256Verify: (_e = backend.p256Verify) == null ? void 0 : _e.bind(backend),
78
+ secp256k1Verify: (_f = backend.secp256k1Verify) == null ? void 0 : _f.bind(backend)
77
79
  });
78
80
  }
79
81
  var CHECK_MESSAGE = utf8ToBytes("@optimystic/quereus-plugin-crypto backend self-check");
@@ -83,6 +85,8 @@ function selfCheckBackend(backend) {
83
85
  if (backend.sha512) checkHash("sha512", backend.sha512, sha512);
84
86
  if (backend.ed25519Sign) checkEd25519Sign(backend.ed25519Sign);
85
87
  if (backend.ed25519Verify) checkEd25519Verify(backend.ed25519Verify);
88
+ if (backend.p256Verify) checkEcdsaVerify("p256Verify", p256, backend.p256Verify);
89
+ if (backend.secp256k1Verify) checkEcdsaVerify("secp256k1Verify", secp256k1, backend.secp256k1Verify);
86
90
  }
87
91
  function checkHash(member, native, noble) {
88
92
  const actual = runCheck(member, () => native(offsetView(CHECK_MESSAGE)));
@@ -103,13 +107,51 @@ function checkEd25519Verify(native) {
103
107
  if (accepted !== true) {
104
108
  throw backendRefused("ed25519Verify", "did not accept a valid signature over a raw 32-byte public key");
105
109
  }
106
- const tampered = CHECK_MESSAGE.slice();
107
- tampered[0] ^= 1;
108
- if (rejectsOrThrows(() => native(offsetView(signature), offsetView(tampered), offsetView(publicKey)))) {
110
+ if (rejectsOrThrows(() => native(offsetView(signature), offsetView(tamperedCheckMessage()), offsetView(publicKey)))) {
109
111
  return;
110
112
  }
111
113
  throw backendRefused("ed25519Verify", "accepted a signature over a different message");
112
114
  }
115
+ function checkEcdsaVerify(member, curve, native) {
116
+ const signature = curve.sign(CHECK_MESSAGE, CHECK_SEED, { lowS: true });
117
+ const compressed = curve.getPublicKey(CHECK_SEED);
118
+ const uncompressed = curve.getPublicKey(CHECK_SEED, false);
119
+ checkEcdsaAccepts(member, native, signature, compressed, "33-byte compressed");
120
+ checkEcdsaAccepts(member, native, signature, uncompressed, "65-byte uncompressed");
121
+ for (const vector of ecdsaRejections(curve, signature, compressed, uncompressed)) {
122
+ if (!rejectsOrThrows(() => native(offsetView(vector.signature), offsetView(vector.message), offsetView(vector.publicKey)))) {
123
+ throw backendRefused(member, `accepted ${vector.what}, which @noble/curves rejects`);
124
+ }
125
+ }
126
+ }
127
+ function checkEcdsaAccepts(member, native, signature, publicKey, keyForm) {
128
+ const accepted = runCheck(member, () => native(offsetView(signature), offsetView(CHECK_MESSAGE), offsetView(publicKey)));
129
+ if (accepted !== true) {
130
+ throw backendRefused(member, `did not accept a valid signature over a ${keyForm} public key`);
131
+ }
132
+ }
133
+ function ecdsaRejections(curve, signature, compressed, uncompressed) {
134
+ const order = curve.Point.Fn.ORDER;
135
+ const width = signature.length / 2;
136
+ const r = signature.subarray(0, width);
137
+ const s = signature.subarray(width);
138
+ const scalar = (value) => hexToBytes(value.toString(16).padStart(width * 2, "0"));
139
+ const hybrid = uncompressed.slice();
140
+ hybrid[0] = 6 | uncompressed[uncompressed.length - 1] & 1;
141
+ return [
142
+ { what: "a signature over a different message", signature, message: tamperedCheckMessage(), publicKey: compressed },
143
+ { what: "a high-S signature", signature: concatBytes(r, scalar(order - BigInt(`0x${bytesToHex(s)}`))), message: CHECK_MESSAGE, publicKey: compressed },
144
+ { what: "a signature with r = 0", signature: concatBytes(new Uint8Array(width), s), message: CHECK_MESSAGE, publicKey: compressed },
145
+ { what: "a signature with r equal to the curve order", signature: concatBytes(scalar(order), s), message: CHECK_MESSAGE, publicKey: compressed },
146
+ { what: "a hybrid-encoded (0x06/0x07) public key", signature, message: CHECK_MESSAGE, publicKey: hybrid },
147
+ { what: "a DER-encoded signature", signature: curve.Signature.fromBytes(signature, "compact").toBytes("der"), message: CHECK_MESSAGE, publicKey: compressed }
148
+ ];
149
+ }
150
+ function tamperedCheckMessage() {
151
+ const tampered = CHECK_MESSAGE.slice();
152
+ tampered[0] ^= 1;
153
+ return tampered;
154
+ }
113
155
  function rejectsOrThrows(attempt) {
114
156
  try {
115
157
  return attempt() === false;
@@ -151,6 +193,12 @@ function ed25519Verify(signature, message, publicKey) {
151
193
  const native = (_a = currentBackend()) == null ? void 0 : _a.ed25519Verify;
152
194
  return native ? native(signature, message, publicKey) : ed25519.verify(signature, message, publicKey);
153
195
  }
196
+ var ECDSA_VERIFY_OPTS = Object.freeze({ prehash: true, lowS: true, format: "compact" });
197
+ function ecdsaVerify(member, curve, signature, message, publicKey) {
198
+ var _a;
199
+ const native = (_a = currentBackend()) == null ? void 0 : _a[member];
200
+ return native ? native(signature, message, publicKey) : curve.verify(signature, message, publicKey, ECDSA_VERIFY_OPTS);
201
+ }
154
202
  var HASHERS = {
155
203
  sha256: dispatchHash("sha256", sha256),
156
204
  sha512: dispatchHash("sha512", sha512),
@@ -318,10 +366,10 @@ function verify(data, signature, publicKey, curve = "secp256k1", inputEncoding =
318
366
  const keyBytes = toBytes(publicKey, keyEncoding);
319
367
  switch (curve) {
320
368
  case "secp256k1": {
321
- return secp256k1.verify(sigBytes, dataBytes, keyBytes);
369
+ return ecdsaVerify("secp256k1Verify", secp256k1, sigBytes, dataBytes, keyBytes);
322
370
  }
323
371
  case "p256": {
324
- return p256.verify(sigBytes, dataBytes, keyBytes);
372
+ return ecdsaVerify("p256Verify", p256, sigBytes, dataBytes, keyBytes);
325
373
  }
326
374
  case "ed25519": {
327
375
  return ed25519Verify(sigBytes, dataBytes, keyBytes);