Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Update formats on getLisk32AddressFromPublicKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Phanco committed Oct 31, 2023
1 parent 75aa719 commit 8559d8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion elements/lisk-cryptography/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ export const SHA256 = 'sha256';
export const LISK32_CHARSET = 'zxvcpmbn3465o978uyrtkqew2adsjhfg';
export const LISK32_ADDRESS_LENGTH = 41;
export const MESSAGE_TAG_NON_PROTOCOL_MESSAGE = 'LSK_NPM_';

export const ED25519_PUBLIC_KEY_LENGTH = 32;
10 changes: 8 additions & 2 deletions elements/lisk-cryptography/test/address.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ describe('address', () => {
describe('#getLisk32AddressFromPublicKey', () => {
it('should reject when publicKey length not equal to ED25519_PUBLIC_KEY_LENGTH', () => {
expect(() =>
getLisk32AddressFromPublicKey(Buffer.alloc(ED25519_PUBLIC_KEY_LENGTH - 1), 'lsk'),
getLisk32AddressFromPublicKey(
Buffer.alloc(ED25519_PUBLIC_KEY_LENGTH - 1),
DEFAULT_LISK32_ADDRESS_PREFIX,
),
).toThrow(`publicKey length must be ${ED25519_PUBLIC_KEY_LENGTH}.`);
});

it('should generate lisk32 address from publicKey', () => {
const address = getLisk32AddressFromPublicKey(defaultPublicKey, 'lsk');
const address = getLisk32AddressFromPublicKey(
defaultPublicKey,
DEFAULT_LISK32_ADDRESS_PREFIX,
);

expect(address).toBe(getLisk32AddressFromAddress(defaultAddress));
});
Expand Down

0 comments on commit 8559d8f

Please sign in to comment.