Skip to content

Commit

Permalink
feat: allow "pers" EC option
Browse files Browse the repository at this point in the history
  • Loading branch information
feri42 committed Sep 24, 2024
1 parent 2d523b6 commit b2d1a61
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions features/keychain/module/crypto/secp256k1.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import assert from 'minimalistic-assert'
import elliptic from '@exodus/elliptic'
import { mapValues, pick } from '@exodus/basic-utils'
import { mapValues } from '@exodus/basic-utils'
import ecc from '@exodus/bitcoinerlab-secp256k1'

import { tweakPrivateKey } from './tweak.js'

const isValidEcOptions = (ecOptions) =>
!ecOptions || Object.keys(ecOptions).every((key) => ['canonical'].includes(key))
!ecOptions || Object.keys(ecOptions).every((key) => ['canonical', 'pers'].includes(key))

const encodeSignature = ({ signature, enc }) => {
if (enc === 'der') return Buffer.from(signature.toDER())
Expand All @@ -31,7 +31,7 @@ export const create = ({ getPrivateHDKey }) => {
assert(['der', 'raw', 'binary'].includes(enc), 'signBuffer: invalid enc')
assert(isValidEcOptions(ecOptions), 'signBuffer: invalid EC option')
const { privateKey } = getPrivateHDKey({ seedId, keyId })
const signature = curve.sign(data, privateKey, pick(ecOptions, ['canonical']))
const signature = curve.sign(data, privateKey, ecOptions)
return encodeSignature({ signature, enc })
},
signSchnorr: async ({ seedId, keyId, data, tweak, extraEntropy }) => {
Expand Down

0 comments on commit b2d1a61

Please sign in to comment.