Skip to content

Commit

Permalink
Merge pull request #104 from blockchain-certificates/feat/support-mul…
Browse files Browse the repository at this point in the history
…tikey-format

fix(IssuingAddress): compare with same case
  • Loading branch information
lemoustachiste authored Sep 5, 2024
2 parents eb73ab2 + 5faf893 commit 3498b34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/inspectors/compareIssuingAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import VerifierError from '../models/VerifierError';

export default function compareIssuingAddress (issuingAddress: string, derivedIssuingAddress: string): void {
const baseError = getText('errors', 'identityErrorBaseMessage');
if (issuingAddress !== derivedIssuingAddress) {
if (issuingAddress.toLowerCase() !== derivedIssuingAddress.toLowerCase()) {
throw new VerifierError('compareIssuingAddress', `${baseError} - ${getText('errors', 'compareIssuingAddress')}`);
}
}
18 changes: 18 additions & 0 deletions tests/inspectors/deriveIssuingAddressFromPublicKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,23 @@ describe('deriveIssuingAddressFromPublicKey test suite', function () {
const address = await deriveIssuingAddressFromPublicKey(publicKey, BLOCKCHAINS.bitcoin);
expect(address).toBe('1862cjGVHodmYyvfumSgrgfnWcpCMHK9sq');
});

it('should return the address of Bitcoin Testnet', async function () {
const publicKey = {
publicKeyMultibase: 'zQ3shvX9Dd7cAG7ZcJN4d9DksshpVYSGpqEyrLjopoGpk97CR'
};

const address = await deriveIssuingAddressFromPublicKey(publicKey, BLOCKCHAINS.testnet);
expect(address).toBe('mgdWjvq4RYAAP5goUNagTRMx7Xw534S5am');
});

it('should return the address of Ethereum', async function () {
const publicKey = {
publicKeyMultibase: 'zQ3shvX9Dd7cAG7ZcJN4d9DksshpVYSGpqEyrLjopoGpk97CR'
};

const address = await deriveIssuingAddressFromPublicKey(publicKey, BLOCKCHAINS.ethmain);
expect(address).toBe('0x40cf9b7db6fcc742ad0a76b8588c7f8de2b54a60');
});
});
});

0 comments on commit 3498b34

Please sign in to comment.