mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
BREAKING CHANGE(fix): deriveKeypair ignoring a manual algorithm being specified (#2376)
This commit is contained in:
committed by
Caleb Kniffen
parent
07afcea97d
commit
041055082a
@@ -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
|
||||
|
||||
@@ -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.')
|
||||
|
||||
Reference in New Issue
Block a user