s_ota on Nostr: nostr-tools 内部でも使っている noble-secp256k1 で "破壊的変更" ...
nostr-tools 内部でも使っている noble-secp256k1 で "破壊的変更" が来てた。
Nostr に関連しそうなのはこの辺。シュノア署名は @noble/curves に移動。今まで非同期だったのが同期になった等。
```
-import * as secp from '@noble/secp256k1';
+import { secp256k1, schnorr } from '@noble/curves/secp256k1';
+import * as utils from '@noble/curves/abstract/utils';
+import { sha256 } from '@noble/hashes/sha256';
-event.sig = secp.utils.bytesToHex(await secp.schnorr.sign(event.id, getPrivateKey(account)));
-// console.assert(await secp.schnorr.verify(event.sig, event.id, event.pubkey));
+event.sig = utils.bytesToHex(schnorr.sign(event.id, getPrivateKey(account)));
+// console.assert(schnorr.verify(event.sig, event.id, event.pubkey));
-const key = secp.getSharedSecret(privkey, '02' + pubkey);
+const key = secp256k1.getSharedSecret(privkey, '02' + pubkey);
```
https://github.com/susumuota/nostr-keyx/commit/1c405ac1568a01b8d8129cff1a3bdb2d09e79338Published at
2023-03-25 04:41:41Event JSON
{
"id": "a69b2a2ee9515b229df59d4d62eadf2d67e7398df50e6b3978afd61d453ad841",
"pubkey": "8721cdf007e798f80549a4bf174b973dc388e01952f0a952f5473c2cf84a7f60",
"created_at": 1679719301,
"kind": 1,
"tags": [],
"content": "nostr-tools 内部でも使っている noble-secp256k1 で \"破壊的変更\" が来てた。\n\nNostr に関連しそうなのはこの辺。シュノア署名は @noble/curves に移動。今まで非同期だったのが同期になった等。\n\n```\n-import * as secp from '@noble/secp256k1';\n+import { secp256k1, schnorr } from '@noble/curves/secp256k1';\n+import * as utils from '@noble/curves/abstract/utils';\n+import { sha256 } from '@noble/hashes/sha256';\n\n-event.sig = secp.utils.bytesToHex(await secp.schnorr.sign(event.id, getPrivateKey(account)));\n-// console.assert(await secp.schnorr.verify(event.sig, event.id, event.pubkey));\n+event.sig = utils.bytesToHex(schnorr.sign(event.id, getPrivateKey(account)));\n+// console.assert(schnorr.verify(event.sig, event.id, event.pubkey));\n\n-const key = secp.getSharedSecret(privkey, '02' + pubkey);\n+const key = secp256k1.getSharedSecret(privkey, '02' + pubkey);\n```\n\nhttps://github.com/susumuota/nostr-keyx/commit/1c405ac1568a01b8d8129cff1a3bdb2d09e79338\n",
"sig": "f06c51c3657f86c69cfd584d0b4ada907c51c4953c259e57b853fc563f0418e7b06e21abb5f01713cadac41097e773ea9fdf39eaf341be05360b8028eaa4fe66"
}