|
1 |
| -import { json } from './utils.js'; |
2 |
| -import { hexToBytes, bytesToHex as hex } from '@noble/hashes/utils'; |
3 |
| -import { deepStrictEqual, throws } from 'node:assert'; |
| 1 | +import { bytesToHex as hex, hexToBytes } from '@noble/hashes/utils'; |
4 | 2 | import * as fc from 'fast-check';
|
| 3 | +import { describe, should } from 'micro-should'; |
| 4 | +import { deepStrictEqual, throws } from 'node:assert'; |
5 | 5 | import { readFileSync } from 'node:fs';
|
6 |
| -import { should, describe } from 'micro-should'; |
| 6 | +import { json } from './utils.js'; |
7 | 7 | // prettier-ignore
|
8 | 8 | import {
|
9 |
| - secp, sigFromDER, sigToDER, selectHash, normVerifySig, mod, bytesToNumberBE, numberToBytesBE |
| 9 | + bytesToNumberBE, |
| 10 | + mod, |
| 11 | + normVerifySig, |
| 12 | + numberToBytesBE, |
| 13 | + secp, |
| 14 | + selectHash, |
| 15 | + sigFromDER, sigToDER |
10 | 16 | } from './secp256k1.helpers.js';
|
11 | 17 |
|
12 | 18 | const ecdsa = json('./vectors/secp256k1/ecdsa.json');
|
@@ -428,11 +434,15 @@ describe('secp256k1', () => {
|
428 | 434 | const s = 115792089237316195423570985008687907852837564279074904382605163141518162728904n;
|
429 | 435 |
|
430 | 436 | const pub = new Point(x, y, 1n).toRawBytes();
|
431 |
| - const signature = new secp.Signature(2n, 2n); |
432 |
| - signature.r = r; |
433 |
| - signature.s = s; |
| 437 | + const sig = new secp.Signature(2n, 2n); |
| 438 | + throws(() => { |
| 439 | + sig.r = r; |
| 440 | + sig.s = s; |
| 441 | + }); |
| 442 | + const sigHex = |
| 443 | + '0000000000000000000000000000000000000000000000000000000000000001fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd04917c8'; |
434 | 444 |
|
435 |
| - const verified = secp.verify(signature, msg, pub); |
| 445 | + const verified = secp.verify(sigHex, msg, pub); |
436 | 446 | // Verifies, but it shouldn't, because signature S > curve order
|
437 | 447 | deepStrictEqual(verified, false);
|
438 | 448 | });
|
|
0 commit comments