@hatk/hatk 0.0.1-alpha.92 → 0.0.1-alpha.93
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/dist/spaces/verify.d.ts
CHANGED
|
@@ -34,6 +34,13 @@ export declare function parseMultibaseKey(multibase: string): PublicKey;
|
|
|
34
34
|
* Low-S is required — atproto mandates it and a malleable signature would let
|
|
35
35
|
* the same assertion be presented twice with different bytes — and is what
|
|
36
36
|
* @noble enforces by default.
|
|
37
|
+
*
|
|
38
|
+
* `prehash: false` says the second argument is already a digest, and is not
|
|
39
|
+
* optional: @noble/curves hashes it again without it, so every signature from
|
|
40
|
+
* a real counterparty is rejected while one this module both makes and checks
|
|
41
|
+
* still matches. A test that signs through the same call cannot see that, so
|
|
42
|
+
* the vectors in the suite are fixed bytes from the library atproto signs
|
|
43
|
+
* with rather than a round trip through this one.
|
|
37
44
|
*/
|
|
38
45
|
export declare function verifySignature(key: PublicKey, signature: Uint8Array, message: Uint8Array): boolean;
|
|
39
46
|
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/spaces/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,MAAM,CAAA;AAE/C,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAE5C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAuBzD;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,YAAY,CAAA;IACnB,sCAAsC;IACtC,KAAK,EAAE,UAAU,CAAA;CAClB;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAO9D;AAED
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/spaces/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,MAAM,CAAA;AAE/C,qBAAa,cAAe,SAAQ,KAAK;CAAG;AAE5C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAuBzD;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,YAAY,CAAA;IACnB,sCAAsC;IACtC,KAAK,EAAE,UAAU,CAAA;CAClB;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAO9D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAUnG"}
|
package/dist/spaces/verify.js
CHANGED
|
@@ -71,6 +71,13 @@ export function parseMultibaseKey(multibase) {
|
|
|
71
71
|
* Low-S is required — atproto mandates it and a malleable signature would let
|
|
72
72
|
* the same assertion be presented twice with different bytes — and is what
|
|
73
73
|
* @noble enforces by default.
|
|
74
|
+
*
|
|
75
|
+
* `prehash: false` says the second argument is already a digest, and is not
|
|
76
|
+
* optional: @noble/curves hashes it again without it, so every signature from
|
|
77
|
+
* a real counterparty is rejected while one this module both makes and checks
|
|
78
|
+
* still matches. A test that signs through the same call cannot see that, so
|
|
79
|
+
* the vectors in the suite are fixed bytes from the library atproto signs
|
|
80
|
+
* with rather than a round trip through this one.
|
|
74
81
|
*/
|
|
75
82
|
export function verifySignature(key, signature, message) {
|
|
76
83
|
if (signature.length !== 64)
|
|
@@ -78,7 +85,7 @@ export function verifySignature(key, signature, message) {
|
|
|
78
85
|
const digest = sha256(message);
|
|
79
86
|
try {
|
|
80
87
|
const curve = key.curve === 'secp256k1' ? secp256k1 : p256;
|
|
81
|
-
return curve.verify(signature, digest, key.bytes);
|
|
88
|
+
return curve.verify(signature, digest, key.bytes, { prehash: false });
|
|
82
89
|
}
|
|
83
90
|
catch {
|
|
84
91
|
// A malformed point or scalar is a failed verification, not a crash.
|