diff --git a/web3.js/src/account.ts b/web3.js/src/account.ts index 113b2c560e319e..13370e78354520 100644 --- a/web3.js/src/account.ts +++ b/web3.js/src/account.ts @@ -1,4 +1,4 @@ -import * as nacl from 'tweetnacl'; +import nacl from 'tweetnacl'; import type {SignKeyPair as KeyPair} from 'tweetnacl'; import type {Buffer} from 'buffer'; diff --git a/web3.js/src/keypair.ts b/web3.js/src/keypair.ts index acd929757c559c..c61f35302007db 100644 --- a/web3.js/src/keypair.ts +++ b/web3.js/src/keypair.ts @@ -1,4 +1,4 @@ -import * as nacl from 'tweetnacl'; +import nacl from 'tweetnacl'; import {PublicKey} from './publickey'; diff --git a/web3.js/src/secp256k1-program.ts b/web3.js/src/secp256k1-program.ts index a7116f95c9c2c8..0e98460bdbe942 100644 --- a/web3.js/src/secp256k1-program.ts +++ b/web3.js/src/secp256k1-program.ts @@ -1,7 +1,7 @@ import {Buffer} from 'buffer'; import * as BufferLayout from '@solana/buffer-layout'; import secp256k1 from 'secp256k1'; -import {keccak_256} from 'js-sha3'; +import sha3 from 'js-sha3'; import {PublicKey} from './publickey'; import {TransactionInstruction} from './transaction'; @@ -86,9 +86,9 @@ export class Secp256k1Program { ); try { - return Buffer.from(keccak_256.update(toBuffer(publicKey)).digest()).slice( - -ETHEREUM_ADDRESS_BYTES, - ); + return Buffer.from( + sha3.keccak_256.update(toBuffer(publicKey)).digest(), + ).slice(-ETHEREUM_ADDRESS_BYTES); } catch (error) { throw new Error(`Error constructing Ethereum address: ${error}`); } @@ -197,7 +197,7 @@ export class Secp256k1Program { const privateKey = toBuffer(pkey); const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte const messageHash = Buffer.from( - keccak_256.update(toBuffer(message)).digest(), + sha3.keccak_256.update(toBuffer(message)).digest(), ); const {signature, recid: recoveryId} = ecdsaSign(messageHash, privateKey);