@@ -30,7 +30,7 @@ import type { Signature, Signer } from '@chorus-one/signer'
3030import type { CosmosNetworkConfig , CosmosSigningData } from './types'
3131import { Sha256 , keccak256 , Secp256k1 } from '@cosmjs/crypto'
3232
33- import secp256k1 from 'secp256k1'
33+ import { secp256k1 } from '@noble/curves/ secp256k1'
3434import { SafeJSONStringify , checkMaxDecimalPlaces } from '@chorus-one/utils'
3535import { CosmosClient } from './client'
3636import BigNumber from 'bignumber.js'
@@ -380,14 +380,18 @@ export async function getEthermintAccount (lcdUrl: string, address: string): Pro
380380
381381/** @ignore */
382382export function publicKeyToAddress ( pk : Uint8Array , bechPrefix : string ) : string {
383- const pkCompressed = secp256k1 . publicKeyConvert ( pk , true )
383+ // Convert public key to compressed format using @noble /curves
384+ const point = secp256k1 . Point . fromHex ( pk )
385+ const pkCompressed = point . toBytes ( true )
384386
385387 return toBech32 ( bechPrefix , rawSecp256k1PubkeyToRawAddress ( pkCompressed ) )
386388}
387389
388390/** @ignore */
389391export function publicKeyToEthBasedAddress ( pk : Uint8Array , bechPrefix : string ) : string {
390- const pkUncompressed = secp256k1 . publicKeyConvert ( pk , false )
392+ // Convert public key to uncompressed format using @noble /curves
393+ const point = secp256k1 . Point . fromHex ( pk )
394+ const pkUncompressed = point . toBytes ( false )
391395
392396 const hash = keccak256 ( pkUncompressed . subarray ( 1 ) )
393397 const ethAddress = hash . slice ( - 20 )
0 commit comments