Skip to main content
Host UK

WASM Decryption API (RFC-0023)

Lethean R&D Labs
RFC WASM Browser JavaScript API

The WASM module exposes two JavaScript namespaces: BorgSMSG for content decryption (v1, v2, v3, chunked, ABR streaming) and BorgSTMF for form encryption. Full encryption stack available in the browser.

Features

BorgSMSG

Decrypt SMSG content: all versions, chunked, ABR streaming

BorgSTMF

Encrypt/decrypt form submissions with X25519

Metadata Extraction

Read SMSG headers without decryption

~6MB Module

Full Go crypto stack compiled to WASM

Installation

<script src="wasm_exec.js"></script>
<script>
const go = new Go();
WebAssembly.instantiateStreaming(fetch('stmf.wasm'), go.importObject)
    .then(result => {
        go.run(result.instance);
        // BorgSMSG and BorgSTMF now available
    });
</script>

Usage

BorgSMSG API

// Decrypt content
const decrypted = await BorgSMSG.decrypt(encrypted, password);

// Get metadata without decrypting
const meta = BorgSMSG.getMetadata(encrypted);
console.log(meta.title, meta.contentType, meta.size);

BorgSTMF API

// Encrypt form data
const encrypted = await BorgSTMF.encrypt(formData, serverPublicKey);

// Server-side decryption
const decrypted = await BorgSTMF.decrypt(encrypted, serverPrivateKey);

Ready Event

document.addEventListener('borgstmf:ready', (event) => {
    console.log('WASM ready, version:', event.detail.version);
});

More from Lethean R&D Labs

View all projects →

Fancy helping out?

Spotted a bug? Got an idea? We'd love to hear from you.

Read the contributing guide →