Skip to content

Commit d6c190e

Browse files
authored
Merge pull request #7930 from BitGo/BG-7254-ada-address-derivation-fix
fix(sdk-coin-ada): use derivedFromParentWithSeed in address verification
2 parents ed26c2e + 852137d commit d6c190e

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

modules/sdk-coin-ada/src/ada.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@ export class Ada extends BaseCoin {
174174
}
175175

176176
const commonKeychain = extractCommonKeychain(keychains);
177+
const derivationSeed = (keychains[0] as { derivedFromParentWithSeed?: string })?.derivedFromParentWithSeed;
177178
const { address: derivedAddress } = await this.getAdaAddressAndAccountId({
178179
bitgoKey: commonKeychain,
179180
index: indexNumber,
181+
seed: derivationSeed,
180182
});
181183

182184
return address === derivedAddress;

modules/sdk-coin-ada/test/unit/ada.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,86 @@ describe('ADA', function () {
10101010
})
10111011
.should.be.rejectedWith('all keychains must have the same commonKeychain for MPC coins');
10121012
});
1013+
1014+
it('should verify address when derivedFromParentWithSeed is present', async function () {
1015+
const derivedFromParentWithSeed = 'testDerivationSeed123';
1016+
1017+
const keychains = [
1018+
{
1019+
id: '1',
1020+
commonKeychain: commonKeychain,
1021+
derivedFromParentWithSeed: derivedFromParentWithSeed,
1022+
type: 'tss' as const,
1023+
source: 'user' as const,
1024+
},
1025+
{
1026+
id: '2',
1027+
commonKeychain: commonKeychain,
1028+
derivedFromParentWithSeed: derivedFromParentWithSeed,
1029+
type: 'tss' as const,
1030+
source: 'backup' as const,
1031+
},
1032+
{
1033+
id: '3',
1034+
commonKeychain: commonKeychain,
1035+
derivedFromParentWithSeed: derivedFromParentWithSeed,
1036+
type: 'tss' as const,
1037+
source: 'bitgo' as const,
1038+
},
1039+
];
1040+
1041+
const { address: expectedAddress } = await (basecoin as any).getAdaAddressAndAccountId({
1042+
bitgoKey: commonKeychain,
1043+
index: 0,
1044+
seed: derivedFromParentWithSeed,
1045+
});
1046+
1047+
const isValid = await basecoin.isWalletAddress({
1048+
address: expectedAddress,
1049+
keychains,
1050+
index: 0,
1051+
});
1052+
1053+
isValid.should.equal(true);
1054+
});
1055+
1056+
it('should fail verification when derivedFromParentWithSeed is missing but address was created with seed', async function () {
1057+
const derivedFromParentWithSeed = 'testDerivationSeed123';
1058+
const { address: addressWithSeed } = await (basecoin as any).getAdaAddressAndAccountId({
1059+
bitgoKey: commonKeychain,
1060+
index: 0,
1061+
seed: derivedFromParentWithSeed,
1062+
});
1063+
1064+
const keychainsWithoutSeed = [
1065+
{
1066+
id: '1',
1067+
commonKeychain: commonKeychain,
1068+
type: 'tss' as const,
1069+
source: 'user' as const,
1070+
},
1071+
{
1072+
id: '2',
1073+
commonKeychain: commonKeychain,
1074+
type: 'tss' as const,
1075+
source: 'backup' as const,
1076+
},
1077+
{
1078+
id: '3',
1079+
commonKeychain: commonKeychain,
1080+
type: 'tss' as const,
1081+
source: 'bitgo' as const,
1082+
},
1083+
];
1084+
1085+
const isValid = await basecoin.isWalletAddress({
1086+
address: addressWithSeed,
1087+
keychains: keychainsWithoutSeed,
1088+
index: 0,
1089+
});
1090+
1091+
isValid.should.equal(false);
1092+
});
10131093
});
10141094

10151095
describe('Verify token consolidation transaction:', () => {

0 commit comments

Comments
 (0)