import { ensureLeading0x , hexToBuffer } from '@celo/base/lib/address' ; import { isValidPrivate , privateToAddress , privateToPublic , pubToAddress , toBuffer , toChecksumAddress , } from 'ethereumjs-util' ; import * as Web3Utils from 'web3-utils' ; export { Address , bufferToHex , ensureLeading0x , eqAddress , findAddressIndex , getAddressChunks , hexToBuffer , isHexString , mapAddressListDataOnto , mapAddressListOnto , normalizeAddress , normalizeAddressWith0x , NULL_ADDRESS , trimLeading0x , } from '@celo/base/lib/address' ; export { isValidChecksumAddress , toChecksumAddress } from 'ethereumjs-util' ; export const privateKeyToAddress = ( privateKey ) => toChecksumAddress ( ensureLeading0x ( privateToAddress ( hexToBuffer ( privateKey ) ) . toString ( 'hex' ) ) ) ; export const privateKeyToPublicKey = ( privateKey ) => toChecksumAddress ( ensureLeading0x ( privateToPublic ( hexToBuffer ( privateKey ) ) . toString ( 'hex' ) ) ) ; export const publicKeyToAddress = ( publicKey ) => toChecksumAddress ( ensureLeading0x ( pubToAddress ( toBuffer ( ensureLeading0x ( publicKey ) ) , true ) . toString ( 'hex' ) ) ) ; export const isValidPrivateKey = ( privateKey ) => privateKey . startsWith ( '0x' ) && isValidPrivate ( hexToBuffer ( privateKey ) ) ; export const isValidAddress = ( input ) : boolean => Web3Utils . isAddress ( input ) ;