Skip to main content
Glama
pure.signer.ts654 B
import elliptic from "elliptic"; import { SHA3 } from "sha3"; /** * Sign a message with a private key */ export function signWithKey(privateKeyHex: string, msg: string) { const ec = new elliptic.ec("p256"); const key = ec.keyFromPrivate(Buffer.from(privateKeyHex, "hex")); const sig = key.sign(_hashMsg(msg)); const n = 32; const r = sig.r.toArrayLike(Buffer, "be", n); const s = sig.s.toArrayLike(Buffer, "be", n); return Buffer.concat([r.valueOf(), s.valueOf()]).toString("hex"); } /** * Hash a message */ function _hashMsg(msg: string) { const sha = new SHA3(256); sha.update(Buffer.from(msg, "hex")); return sha.digest(); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Outblock/flow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server