Skip to content

Repository files navigation

Browser Network Crypto

Browser-compatible cryptographic helpers for Browser Network. It uses audited Noble primitives: secp256k1 signatures/ECDH, HKDF, and XChaCha20-Poly1305.

Installation

npm install @browser-network/crypto

For a script tag, load the UMD bundle. It exposes window.Bnc:

<script src="https://unpkg.com/@browser-network/crypto/umd/crypto.min.js"></script>

Usage

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.

About

A wrapper around eccrypto designed for use in the browser-network ecosystem

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages