1- import { concatBytes } from "@noble/curves/abstract/ utils" ;
2- import { secp256k1 } from "@noble/curves/secp256k1" ;
1+ import { concatBytes } from "@noble/curves/utils.js " ;
2+ import { secp256k1 } from "@noble/curves/secp256k1.js " ;
33
44// eslint-disable-next-line @typescript-eslint/no-explicit-any, n/no-unsupported-features/node-builtins
55const browserCrypto = globalThis . crypto || ( globalThis as any ) . msCrypto || { } ;
@@ -179,8 +179,8 @@ export const sign = async function (privateKey: Uint8Array, msg: Uint8Array): Pr
179179 assert ( isValidPrivateKey ( privateKey ) , "Bad private key" ) ;
180180 assert ( msg . length > 0 , "Message should not be empty" ) ;
181181 assert ( msg . length <= 32 , "Message is too long" ) ;
182- const sig = secp256k1 . sign ( msg , privateKey , { prehash : false } ) ;
183- return sig . toDERRawBytes ( ) ;
182+ const sig = secp256k1 . sign ( msg , privateKey , { prehash : false , format : "der" } ) ;
183+ return sig ;
184184} ;
185185
186186export const verify = async function ( publicKey : Uint8Array , msg : Uint8Array , sig : Uint8Array ) : Promise < null > {
@@ -193,7 +193,7 @@ export const verify = async function (publicKey: Uint8Array, msg: Uint8Array, si
193193 }
194194 assert ( msg . length > 0 , "Message should not be empty" ) ;
195195 assert ( msg . length <= 32 , "Message is too long" ) ;
196- if ( secp256k1 . verify ( sig , msg , publicKey , { prehash : false } ) ) return null ;
196+ if ( secp256k1 . verify ( sig , msg , publicKey , { prehash : false , format : "der" } ) ) return null ;
197197 throw new Error ( "Bad signature" ) ;
198198} ;
199199
0 commit comments