11import { isValidXpub , SigningError } from '@bitgo/sdk-core' ;
22import { InMemorySigner } from '@taquito/signer' ;
33import * as base58check from 'bs58check' ;
4- import { ec as EC } from 'elliptic ' ;
4+ import { secp256k1 } from '@noble/curves/secp256k1 ' ;
55import sodium from 'libsodium-wrappers' ;
66import { HashType , SignResponse } from './iface' ;
77import { KeyPair } from './keyPair' ;
@@ -101,9 +101,8 @@ export async function verifySignature(
101101 signature : string ,
102102 watermark : Uint8Array = DEFAULT_WATERMARK
103103) : Promise < boolean > {
104- const rawPublicKey = decodeKey ( publicKey , hashTypes . sppk ) ;
105- const ec = new EC ( 'secp256k1' ) ;
106- const key = ec . keyFromPublic ( rawPublicKey ) ;
104+ const rawPublicKey = decodeKey ( publicKey , hashTypes . sppk ) . toString ( 'hex' ) ;
105+ const key = secp256k1 . ProjectivePoint . fromHex ( rawPublicKey ) ;
107106
108107 const messageBuffer = Uint8Array . from ( Buffer . from ( message , 'hex' ) ) ;
109108 // Tezos signatures always have a watermark
@@ -115,7 +114,7 @@ export async function verifySignature(
115114 const bytesHash = Buffer . from ( sodium . crypto_generichash ( 32 , messageWithWatermark ) ) ;
116115
117116 const rawSignature = decodeSignature ( signature , hashTypes . sig ) ;
118- return key . verify ( bytesHash , { r : rawSignature . slice ( 0 , 32 ) , s : rawSignature . slice ( 32 , 64 ) } ) ;
117+ return secp256k1 . verify ( rawSignature , bytesHash , key . toHex ( ) ) ;
119118}
120119
121120/**
0 commit comments