From 8559d8f12b82beecca90aa51d23ad0be05247e78 Mon Sep 17 00:00:00 2001 From: Franco NG Date: Tue, 31 Oct 2023 09:37:46 +0100 Subject: [PATCH] Update formats on getLisk32AddressFromPublicKey --- elements/lisk-cryptography/src/constants.ts | 1 - elements/lisk-cryptography/test/address.spec.ts | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/elements/lisk-cryptography/src/constants.ts b/elements/lisk-cryptography/src/constants.ts index cda18b51ee..790b9e391c 100644 --- a/elements/lisk-cryptography/src/constants.ts +++ b/elements/lisk-cryptography/src/constants.ts @@ -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; diff --git a/elements/lisk-cryptography/test/address.spec.ts b/elements/lisk-cryptography/test/address.spec.ts index f53ff969fc..22acad9534 100644 --- a/elements/lisk-cryptography/test/address.spec.ts +++ b/elements/lisk-cryptography/test/address.spec.ts @@ -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)); });