Skip to content

Commit

Permalink
fix(keychain)!: only export secret if "exportPrivate" flag is set (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoskichel authored Sep 13, 2024
1 parent 6762be9 commit 7a01522
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions features/keychain/module/__tests__/sodium.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ describe('libsodium', () => {
const {
sign: { privateKey: signPrivateKey },
box: { privateKey: boxPrivateKey },
secret,
} = await keychain.sodium.getSodiumKeysFromSeed({ seedId, keyId: ALICE_KEY })

expect(signPrivateKey).toBeNull()
expect(boxPrivateKey).toBeNull()
expect(secret).toBeNull()
})

it('should allow exporting private keys', async () => {
Expand All @@ -52,6 +54,7 @@ describe('libsodium', () => {
const {
sign: { privateKey: signPrivateKey },
box: { privateKey: boxPrivateKey },
secret,
} = await keychain.sodium.getSodiumKeysFromSeed({
seedId,
keyId: ALICE_KEY,
Expand All @@ -60,6 +63,7 @@ describe('libsodium', () => {

expect(signPrivateKey).toBeDefined()
expect(boxPrivateKey).toBeDefined()
expect(secret).toBeDefined()
})

it('should have sign keys compatibility with SLIP10 (using sodium instance)', async () => {
Expand Down
2 changes: 1 addition & 1 deletion features/keychain/module/crypto/sodium.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const create = ({ getPrivateHDKey }) => {
return {
box: cloneKeypair({ keys: box, exportPrivate }),
sign: cloneKeypair({ keys: sign, exportPrivate }),
secret: cloneBuffer(secret),
secret: exportPrivate ? cloneBuffer(secret) : null,
}
},
sign: async ({ seedId, keyId, data }) => {
Expand Down

0 comments on commit 7a01522

Please sign in to comment.