yarn add @noble/secp256k1# ornpm install @noble/secp256k1
// Common.js and ECMAScript Modules (ESM)import * as secp from '@noble/secp256k1';// If you're using single file, use global variable instead: `window.nobleSecp256k1`// Supports both async and sync methods, see docs(async () => {// keys, messages & other inputs can be Uint8Arrays or hex strings// Uint8Array.from([0xde, 0xad, 0xbe, 0xef]) === 'deadbeef'const privKey = secp.utils.randomPrivateKey();const pubKey = secp.getPublicKey(privKey);const msgHash = await secp.utils.sha256('hello world');const signature = await secp.sign(msgHash, privKey);const isValid = secp.verify(signature, msgHash, pubKey);// Schnorr signaturesconst rpub = secp.schnorr.getPublicKey(privKey);const rsignature = await secp.schnorr.sign(message, privKey);const risValid = await secp.schnorr.verify(rsignature, message, rpub);})();