import { generatePrivateKey } from "https://deno.land/x/libauth@v2.0.0-alpha.6/src/lib/key/key-utils.ts";
Securely generate a valid Secp256k1 private key given a secure source of randomness.
Node.js Usage
import { randomBytes } from 'crypto';
import { generatePrivateKey } from '@bitauth/libauth';
const key = generatePrivateKey(() => randomBytes(32));
Browser Usage
import { generatePrivateKey } from '@bitauth/libauth';
const key = generatePrivateKey(() =>
window.crypto.getRandomValues(new Uint8Array(32))
);