Skip to content

Commit

Permalink
New test vectors when messages > curve_order. Also, adapt documentati…
Browse files Browse the repository at this point in the history
…on to reflect this change. For more background: #1
  • Loading branch information
landabaso committed Jan 10, 2023
1 parent 96668f0 commit 85b631b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ npm install @bitcoinerlab/secp256k1

This implementation follows the tiny-secp256k1 API. Please refer to [tiny-secp256k1](https://github.com/bitcoinjs/tiny-secp256k1#documentation) for documentation on the methods.

There are some minor differences, though:

- These methods are not yet implemented: `signRecoverable`, `recover`, `xOnlyPointAddTweakCheck`. They are not used in ecpair or bip32.
- `sign` throws an error with the message `Noble Ecc returns different values than Bitcoin Core for h = 0xffff.... This behavior is unsafe, so it has been disabled for safety reasons.` when `h = ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`. This is a security protection.

Tests have been adjusted to account for the differences above.
These methods are not yet implemented: `signRecoverable`, `recover`, `xOnlyPointAddTweakCheck`. They are not used in ecpair or bip32, though.

### Examples

Expand Down
8 changes: 0 additions & 8 deletions test/ecdsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ function corrupt(x) {
export default function (secp256k1) {
test("sign", (t) => {
for (const f of fecdsa.valid) {
//@bitcoinerlab: Added this if condition below not to test with this `h`.
//Read the docs at README.md
if (
f.m ===
'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
) {
continue;
}
const d = fromHex(f.d);
const m = fromHex(f.m);
const expected = fromHex(f.signature);
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/ecdsa.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@
},
{
"description": "Strange hash",
"note": "Using correct vector from https://github.com/paulmillr/noble-secp256k1/blob/e125abdd2f42b2ad4cf5f4a1b7927d7737b7becf/test/vectors/ecdsa.json#L94",
"d": "0000000000000000000000000000000000000000000000000000000000000001",
"m": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"signature": "3f8fe493cf305a7f02b2d2c060ba66a8f7bd13a7a64d5200c0655ad069bd85b51cf94236c3857e33a1023a5216cbc81b1dc3adcc1c71f4212df1997ffdfb140a",
"signature": "7cb38cc5712e9e11a767615f6080dbc111c9cdd613eb98999fd92a86bafd45407923ca1f4d03471d2866f776ef8a6d3cac099b427331aeb245aa9dafeddcf115",
"recoveryId": 1
},
{
Expand All @@ -121,9 +122,10 @@
},
{
"description": "Strange hash",
"note": "Using correct vector from https://github.com/paulmillr/noble-secp256k1/blob/e125abdd2f42b2ad4cf5f4a1b7927d7737b7becf/test/vectors/ecdsa.json#L106",
"d": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",
"m": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"signature": "2d0b04a7560652f419e2542ea7d27f2c4afb0e111bb409cfe9f34b7ff7d3315850118e90fcfe28abd0635a2e90f00db72bdbfcedbf56dad4049de85798031b38",
"signature": "a7f83b5963eaf5332c633327cc967be8f4166d3f1e0b77f9761d8f4e42211e9a58aae31be1eb1e496923bbe8ca5e843cfb89f4d986d61d4edfd7d6fc3c9cf62c",
"recoveryId": 0
},
{
Expand Down

0 comments on commit 85b631b

Please sign in to comment.