Skip to content

Conversation

@ravibitgo
Copy link
Contributor

@ravibitgo ravibitgo commented Nov 3, 2025

Ticket: COIN-6323

@ravibitgo ravibitgo requested review from a team as code owners November 3, 2025 13:51
Copy link
Contributor

@OttoAllmendinger OttoAllmendinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrishikeshjain
hrishikeshjain previously approved these changes Nov 3, 2025
@ravibitgo
Copy link
Contributor Author

see https://bitgoinc.atlassian.net/browse/EA-643?focusedCommentId=363573 please

yes makes sense, I'll change the implementation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a better way to test this is to create two wallets with different key triples, create two addresses, and assert that isWalletAddress is true for the correct wallet and false for the other wallet

Comment on lines +130 to +137
const commonKeychain = extractCommonKeychain(keychains);
const MPC = await EDDSAMethods.getInitializedMpcInstance();
const derivationPath = 'm/0';
const derivedPublicKey = MPC.deriveUnhardened(commonKeychain, derivationPath).slice(0, 64);
const publicKeyBase64 = Buffer.from(derivedPublicKey, 'hex').toString('base64');
const rootAddressFingerprint = utils.getAddressFromPublicKey(publicKeyBase64);
const rootAddress = `${rootAddressFingerprint.slice(0, 5)}::${rootAddressFingerprint}`;
return addressPart === rootAddress;
Copy link
Contributor

@zahin-mohammad zahin-mohammad Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-use the generic methods used for other ED coins.

  async isWalletAddress(params: TssVerifyAddressOptions): Promise<boolean> {
    return verifyEddsaTssWalletAddress(
      params,
      (address) => this.isValidAddress(address),
      (publicKey) => this.getAddressFromPublicKey(publicKey)
    );
  }

you just need to change the implementation of the two call back functions.

Copy link
Contributor Author

@ravibitgo ravibitgo Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @zahin-mohammad , canton is a memo based coin so I can't directly use this function. I was thinking of adding,

export async function verifyEddsaMemoBasedWalletAddress(
params: TssVerifyAddressOptions,
isValidAddress: (address: string) => boolean,
getAddressFromPublicKey: (publicKey: string) => string
): Promise {
const { keychains, address, index } = params;
const [addressPart, memoId] = address.split('?memoId=');

if (memoId && memoId !== index) {
throw new InvalidAddressError(invalid memoId: ${memoId});
}

if (!isValidAddress(addressPart)) {
throw new InvalidAddressError(invalid address: ${addressPart});
}

const commonKeychain = extractCommonKeychain(keychains);

const MPC = await EDDSAMethods.getInitializedMpcInstance();
const derivationPath = 'm/0';
const derivedPublicKey = MPC.deriveUnhardened(commonKeychain, derivationPath).slice(0, 64);
const expectedAddress = getAddressFromPublicKey(derivedPublicKey);

return addressPart === expectedAddress;
}

This method and use it when sdk-core is published. I'll create a ticket in backlog for this refactor, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants