Skip to content

Commit

Permalink
fix: address check should be insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomariscal committed Dec 11, 2024
1 parent dd0ce87 commit 784d757
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/utils/crypto/checkStealthAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ function checkStealthAddress({
schemeId
});

// Compare derived stealth address with the user's stealth address
return stealthAddress === userStealthAddress;
return stealthAddress.toLowerCase() === userStealthAddress.toLowerCase();
}

export default checkStealthAddress;
21 changes: 21 additions & 0 deletions src/utils/crypto/test/checkStealthAddress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,25 @@ describe('checkStealthAddress', () => {

expect(isForUser).toBe(false);
});

test('matches addresses regardless of case', () => {
// Test with different case variations
const variations = [
stealthAddress.toLowerCase(),
stealthAddress.toUpperCase()
];

for (const addressVariation of variations) {
const result = checkStealthAddress({
ephemeralPublicKey,
schemeId,
spendingPublicKey: bytesToHex(spendingPublicKey),
viewingPrivateKey,
userStealthAddress: addressVariation as `0x${string}`,
viewTag
});

expect(result).toBe(true);
}
});
});

0 comments on commit 784d757

Please sign in to comment.