Skip to content

Commit

Permalink
fix: schnorrSign return type and type and signature (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
fboucquez authored Nov 16, 2024
1 parent 618bc35 commit 7e8d8bb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion features/keychain/api/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe('keychain api', () => {
'hex'
),
})
expect(Buffer.from(signature).toString('hex')).toBe(
expect(signature.toString('hex')).toBe(
'd8a41b022fab008d1d8bc32ce99dd16a4edae37da691047b3729d626c47d6e0850f78245656bc0edccf6002936b96fe04bb4553be5334cf425ac94ca2da33a2e'
)
})
Expand Down
4 changes: 3 additions & 1 deletion features/keychain/api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export interface KeychainApi {
secp256k1: {
signBuffer(params: { data: Buffer } & KeySource): Promise<Buffer>
signBuffer(params: { data: Buffer; enc: 'der' } & KeySource): Promise<Buffer>
signSchnorr(params: { data: Buffer; tweak?: Buffer } & KeySource): Promise<Buffer>
signSchnorr(
params: { data: Buffer; extraEntropy?: Buffer; tweak?: Buffer } & KeySource
): Promise<Buffer>
}
}

Expand Down
2 changes: 1 addition & 1 deletion features/keychain/module/__tests__/schnorr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Schnorr signer', () => {
extraEntropy: Buffer.from(fixture.entropy, 'hex'),
})

expect(Buffer.from(result).toString('hex')).toBe(fixture.sig)
expect(result.toString('hex')).toBe(fixture.sig)
})

it('should throw for keyType != secp256k1', async () => {
Expand Down
2 changes: 1 addition & 1 deletion features/keychain/module/crypto/secp256k1.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const create = ({ getPrivateHDKey }) => {
)
const hdkey = getPrivateHDKey({ seedId, keyId })
const privateKey = tweak ? tweakPrivateKey({ hdkey, tweak }) : hdkey.privateKey
return secp256k1.schnorrSign({ data, privateKey, extraEntropy })
return secp256k1.schnorrSign({ data, privateKey, extraEntropy, format: 'buffer' })
},
})

Expand Down

0 comments on commit 7e8d8bb

Please sign in to comment.