diff --git a/yarn-project/circuits.js/package.json b/yarn-project/circuits.js/package.json index 84d9bc378eee..aa44efac2909 100644 --- a/yarn-project/circuits.js/package.json +++ b/yarn-project/circuits.js/package.json @@ -39,7 +39,6 @@ "dependencies": { "@aztec/foundation": "workspace:^", "@msgpack/msgpack": "^3.0.0-beta2", - "@noble/curves": "^1.0.0", "@types/lodash.camelcase": "^4.3.7", "@types/lodash.times": "^4.3.7", "cross-fetch": "^3.1.5", diff --git a/yarn-project/circuits.js/src/barretenberg/crypto/ecdsa/index.test.ts b/yarn-project/circuits.js/src/barretenberg/crypto/ecdsa/index.test.ts index 2f309f3640ee..b30730e8f5ba 100644 --- a/yarn-project/circuits.js/src/barretenberg/crypto/ecdsa/index.test.ts +++ b/yarn-project/circuits.js/src/barretenberg/crypto/ecdsa/index.test.ts @@ -10,7 +10,7 @@ describe('ecdsa', () => { ecdsa = new Ecdsa(wasm); }); - it.skip('should verify signature', () => { + it('should verify signature', () => { // prettier-ignore const privateKey = Buffer.from([ 0x0b, 0x9b, 0x3a, 0xde, 0xe6, 0xb3, 0xd8, 0x1b, 0x28, 0xa0, 0x88, 0x6b, 0x2a, 0x84, 0x15, 0xc7, @@ -24,7 +24,7 @@ describe('ecdsa', () => { expect(verified).toBe(true); }); - it.skip('should recover public key from signature', () => { + it('should recover public key from signature', () => { // prettier-ignore const privateKey = Buffer.from([ 0x0b, 0x9b, 0x3a, 0xde, 0xe6, 0xb3, 0xd8, 0x1b, 0x28, 0xa0, 0x88, 0x6b, 0x2a, 0x84, 0x15, 0xc7, diff --git a/yarn-project/circuits.js/src/barretenberg/crypto/ecdsa/index.ts b/yarn-project/circuits.js/src/barretenberg/crypto/ecdsa/index.ts index 1007fe4da7b7..762c60a39909 100644 --- a/yarn-project/circuits.js/src/barretenberg/crypto/ecdsa/index.ts +++ b/yarn-project/circuits.js/src/barretenberg/crypto/ecdsa/index.ts @@ -1,10 +1,7 @@ import { IWasmModule } from '@aztec/foundation/wasm'; -import { EcdsaSignature } from './signature.js'; import { CircuitsWasm } from '../../../index.js'; import { Signer } from '../index.js'; -import { secp256k1 } from '@noble/curves/secp256k1'; -import { toBufferBE } from '@aztec/foundation/bigint-buffer'; -import { numToUInt32BE } from '@aztec/foundation/serialize'; +import { EcdsaSignature } from './signature.js'; export * from './signature.js'; @@ -45,18 +42,10 @@ export class Ecdsa implements Signer { this.wasm.writeMemory(mem, msg); this.wasm.call('ecdsa__construct_signature', mem, msg.length, 0, 32, 64, 96); - // TODO(#913): Understand why this doesn't work - // const sig = new EcdsaSignature( - // Buffer.from(this.wasm.getMemorySlice(32, 64)), - // Buffer.from(this.wasm.getMemorySlice(64, 96)), - // Buffer.from(this.wasm.getMemorySlice(96, 97)), - // ); - - const signature = secp256k1.sign(msg, privateKey); return new EcdsaSignature( - toBufferBE(signature.r, 32), - toBufferBE(signature.s, 32), - numToUInt32BE(signature.recovery!).subarray(3, 4), + Buffer.from(this.wasm.getMemorySlice(32, 64)), + Buffer.from(this.wasm.getMemorySlice(64, 96)), + Buffer.from(this.wasm.getMemorySlice(96, 97)), ); } diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index f64e91afa127..83845c46fd50 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -35,7 +35,6 @@ "@aztec/sequencer-client": "workspace:^", "@aztec/world-state": "workspace:^", "@jest/globals": "^29.5.0", - "@noble/curves": "^1.0.0", "@types/jest": "^29.5.0", "@types/levelup": "^5.1.2", "@types/lodash.every": "^4.6.7", diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 72187a5610c8..8bb6dd94611b 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -258,7 +258,6 @@ __metadata: "@aztec/yarn-project-base": "workspace:^" "@jest/globals": ^29.5.0 "@msgpack/msgpack": ^3.0.0-beta2 - "@noble/curves": ^1.0.0 "@types/detect-node": ^2.0.0 "@types/jest": ^29.5.0 "@types/lodash.camelcase": ^4.3.7 @@ -309,7 +308,6 @@ __metadata: "@aztec/sequencer-client": "workspace:^" "@aztec/world-state": "workspace:^" "@jest/globals": ^29.5.0 - "@noble/curves": ^1.0.0 "@rushstack/eslint-patch": ^1.1.4 "@types/jest": ^29.5.0 "@types/levelup": ^5.1.2 @@ -2380,7 +2378,7 @@ __metadata: languageName: node linkType: hard -"@noble/curves@npm:1.0.0, @noble/curves@npm:^1.0.0, @noble/curves@npm:~1.0.0": +"@noble/curves@npm:1.0.0, @noble/curves@npm:~1.0.0": version: 1.0.0 resolution: "@noble/curves@npm:1.0.0" dependencies: