Browser-compatible cryptographic helpers for Browser Network. It uses audited Noble primitives: secp256k1 signatures/ECDH, HKDF, and XChaCha20-Poly1305.
npm install @browser-network/cryptoFor a script tag, load the UMD bundle. It exposes window.Bnc:
<script src="https://unpkg.com/@browser-network/crypto/umd/crypto.min.js"></script>import * as Bnc from '@browser-network/crypto'
const secret = Bnc.generateSecret() // hexadecimal secp256k1 private key
const publicKey = Bnc.derivePubKey(secret)
const value = { message: 'hello' }
const signature = await Bnc.sign(secret, value)
const valid = await Bnc.verifySignature(value, signature, publicKey)sign() uses canonical key-sorted JSON serialization. encrypt() and
decrypt() authenticate ciphertext; decryption rejects altered or malformed
input. A secret is an identity private key: never send it to peers, the
Switchboard, or application servers.