BREAKING CHANGE(fix): deriveKeypair ignoring a manual algorithm being specified (#2376)

This commit is contained in:
Jackson Mills
2023-08-08 15:19:44 -07:00
committed by Caleb Kniffen
parent 07afcea97d
commit 041055082a
7 changed files with 83 additions and 55 deletions

View File

@@ -1,6 +1,7 @@
# ripple-keypairs Release History
## Unreleased
* Fix `deriveKeypair` ignoring manual decoding algorithm. (Specifying algorithm=`ed25519` in `opts` now works on secrets like `sNa1...`)
## 1.3.1 (2023-09-27)
### Fixed

View File

@@ -104,13 +104,19 @@ function select(algorithm): any {
function deriveKeypair(
seed: string,
options?: object,
options?: {
algorithm?: 'ed25519' | 'ecdsa-secp256k1'
validator?: boolean
accountIndex?: number
},
): {
publicKey: string
privateKey: string
} {
const decoded = addressCodec.decodeSeed(seed)
const algorithm = decoded.type === 'ed25519' ? 'ed25519' : 'ecdsa-secp256k1'
const proposedAlgorithm = options?.algorithm ?? decoded.type
const algorithm =
proposedAlgorithm === 'ed25519' ? 'ed25519' : 'ecdsa-secp256k1'
const method = select(algorithm)
const keypair = method.deriveKeypair(decoded.bytes, options)
const messageToVerify = hash('This test message should verify.')