Skip to content

Commit

Permalink
Use noble/curves
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding committed Dec 7, 2023
1 parent 6e6abe5 commit 2522cdc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
},
"dependencies": {
"@metamask/utils": "^8.1.0",
"@noble/curves": "^1.2.0",
"@noble/hashes": "^1.3.2",
"@noble/secp256k1": "^1.7.1",
"superstruct": "^1.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-key.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bytesToHex, hasProperty } from '@metamask/utils';
import * as secp256k1 from '@noble/secp256k1';
import { secp256k1 } from '@noble/curves/secp256k1';
import assert from 'assert';
import * as dotenv from 'dotenv';
import fs from 'fs/promises';
Expand Down
9 changes: 3 additions & 6 deletions src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import {
assertStruct,
hexToBytes,
} from '@metamask/utils';
import { secp256k1 } from '@noble/curves/secp256k1';
import { sha256 } from '@noble/hashes/sha256';
import {
verify as nobleVerify,
Signature as NobleSignature,
} from '@noble/secp256k1';
import type { Infer } from 'superstruct';
import { literal, object, pattern, string } from 'superstruct';

Expand Down Expand Up @@ -46,8 +43,8 @@ export function verify({

const publicKeyBytes = hexToBytes(publicKey);

return nobleVerify(
NobleSignature.fromHex(remove0x(signature.signature)),
return secp256k1.verify(
remove0x(signature.signature),
sha256(stringToBytes(registry)),
publicKeyBytes,
);
Expand Down
3 changes: 1 addition & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,6 @@ __metadata:
"@metamask/utils": ^8.1.0
"@noble/curves": ^1.2.0
"@noble/hashes": ^1.3.2
"@noble/secp256k1": ^1.7.1
"@types/jest": ^28.1.6
"@types/node": ^17.0.23
"@typescript-eslint/eslint-plugin": ^5.43.0
Expand Down Expand Up @@ -1351,7 +1350,7 @@ __metadata:
languageName: node
linkType: hard

"@noble/secp256k1@npm:^1.5.5, @noble/secp256k1@npm:^1.7.1":
"@noble/secp256k1@npm:^1.5.5":
version: 1.7.1
resolution: "@noble/secp256k1@npm:1.7.1"
checksum: d2301f1f7690368d8409a3152450458f27e54df47e3f917292de3de82c298770890c2de7c967d237eff9c95b70af485389a9695f73eb05a43e2bd562d18b18cb
Expand Down

0 comments on commit 2522cdc

Please sign in to comment.