From 1665a55fbbd33bac1d7fbe766c671f2b596c910d Mon Sep 17 00:00:00 2001 From: Jordan Gensler Date: Tue, 13 Sep 2022 08:55:02 -0700 Subject: [PATCH] Use correct sha3 import (#4569) --- sdk/typescript/src/cryptography/ed25519-publickey.ts | 10 +++++++--- .../src/cryptography/secp256k1-publickey.ts | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sdk/typescript/src/cryptography/ed25519-publickey.ts b/sdk/typescript/src/cryptography/ed25519-publickey.ts index 78318c72d0de5..e051b5516ebab 100644 --- a/sdk/typescript/src/cryptography/ed25519-publickey.ts +++ b/sdk/typescript/src/cryptography/ed25519-publickey.ts @@ -3,8 +3,12 @@ import BN from 'bn.js'; import { Buffer } from 'buffer'; -import { sha3_256 } from 'js-sha3'; -import { checkPublicKeyData, PublicKeyInitData, SIGNATURE_SCHEME_TO_FLAG } from './publickey'; +import sha3 from 'js-sha3'; +import { + checkPublicKeyData, + PublicKeyInitData, + SIGNATURE_SCHEME_TO_FLAG, +} from './publickey'; const PUBLIC_KEY_SIZE = 32; @@ -92,6 +96,6 @@ export class Ed25519PublicKey { let tmp = new Uint8Array(PUBLIC_KEY_SIZE + 1); tmp.set([SIGNATURE_SCHEME_TO_FLAG['ED25519']]); tmp.set(this.toBytes(), 1); - return sha3_256(tmp).slice(0, 40); + return sha3.sha3_256(tmp).slice(0, 40); } } diff --git a/sdk/typescript/src/cryptography/secp256k1-publickey.ts b/sdk/typescript/src/cryptography/secp256k1-publickey.ts index 525a6a2c66fbf..bb730485f00e1 100644 --- a/sdk/typescript/src/cryptography/secp256k1-publickey.ts +++ b/sdk/typescript/src/cryptography/secp256k1-publickey.ts @@ -3,8 +3,13 @@ import BN from 'bn.js'; import { Buffer } from 'buffer'; -import { sha3_256 } from 'js-sha3'; -import { checkPublicKeyData, PublicKey, PublicKeyInitData, SIGNATURE_SCHEME_TO_FLAG } from './publickey'; +import sha3 from 'js-sha3'; +import { + checkPublicKeyData, + PublicKey, + PublicKeyInitData, + SIGNATURE_SCHEME_TO_FLAG, +} from './publickey'; const SECP256K1_PUBLIC_KEY_SIZE = 33; @@ -92,6 +97,6 @@ export class Secp256k1PublicKey implements PublicKey { let tmp = new Uint8Array(SECP256K1_PUBLIC_KEY_SIZE + 1); tmp.set([SIGNATURE_SCHEME_TO_FLAG['Secp256k1']]); tmp.set(this.toBytes(), 1); - return sha3_256(tmp).slice(0, 40); + return sha3.sha3_256(tmp).slice(0, 40); } }