Skip to content

Commit

Permalink
fix: rebase error
Browse files Browse the repository at this point in the history
  • Loading branch information
feri42 committed Jan 13, 2025
1 parent 011b799 commit f35186a
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions features/keychain/module/keychain.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,19 @@ export class Keychain {

#getPublicKeyFromHDKey = async ({ hdkey, keyId }) => {
const privateKey = hdkey.privateKey
let publicKey = null

if (exportPublic) {
publicKey = hdkey.publicKey
if (keyId.keyType === 'legacy') {
if (keyId.assetName in this.#legacyPrivToPub) {
const legacyPrivToPub = this.#legacyPrivToPub[keyId.assetName]
publicKey = await legacyPrivToPub(privateKey)
} else {
throw new Error(`asset name ${keyId.assetName} has no legacyPrivToPub mapper`)
}
} else if (keyId.derivationAlgorithm !== 'SLIP10' && keyId.keyType === 'nacl') {
// SLIP10 already produces the correct public key for curve ed25119
// so we can safely skip using the privToPub mapper.
publicKey = await sodium.privToPub(privateKey)
let publicKey = hdkey.publicKey
if (keyId.keyType === 'legacy') {
if (keyId.assetName in this.#legacyPrivToPub) {
const legacyPrivToPub = this.#legacyPrivToPub[keyId.assetName]
publicKey = await legacyPrivToPub(privateKey)
} else {
throw new Error(`asset name ${keyId.assetName} has no legacyPrivToPub mapper`)
}
} else if (keyId.derivationAlgorithm !== 'SLIP10' && keyId.keyType === 'nacl') {
// SLIP10 already produces the correct public key for curve ed25119
// so we can safely skip using the privToPub mapper.
publicKey = await sodium.privToPub(privateKey)
}

return publicKey
Expand Down

0 comments on commit f35186a

Please sign in to comment.