Skip to content

UnSea ​

The cryptography under it all: keys, signatures and encryption, in plain JavaScript, on any page.

bash
npm install unsea

GitHub · npm

What it does ​

  • Random or deterministic key pairs (P-256), with post-quantum hybrid keys since 3.0: ML-DSA-65 signatures and ML-KEM-768 key exchange next to P-256.
  • Signing and verifying messages.
  • Encryption to a recipient (ECDH and AES-GCM), with the sender's key and a timestamp in the message.
  • SHA-256 of text or bytes, as hex, base64url or bytes.
  • Export and import keys as JWK and PEM; encrypted persistence in IndexedDB behind a password.
  • Proof of work: mining and checking SHA-256 work, and signed proof of work.

One ES module for Node 20+ and browsers: use import, in a <script type="module"> on a page.

js
import * as unsea from 'unsea'

const keys = await unsea.generateRandomPair()
const signature = await unsea.signMessage('hello', keys.priv)
const ok = await unsea.verifyMessage('hello', signature, keys.pub)

From a CDN:

html
<script type="module">
  import * as unsea from 'https://cdn.jsdelivr.net/npm/unsea/dist/unsea.mjs'
</script>

Pages without crypto.subtle ​

Browsers give crypto.subtle only to secure pages. On a plain-http page (a build served at a LAN address), UnSea uses its own stand-in on noble for hashing, key derivation and AES-GCM, with the same results. unsea.getSubtle() returns whichever is in use, and unsea.hasNativeSubtle() says which. PeerPigeon, PigeonIdP and FreeRTC all go through it, so the whole stack works there.

peer.ooo · peer to peer on PeerPigeon