@abhedyam/wasm
v1.0.40
Published
WASM Bindings for Abhedya: Sanskrit-Encoded PQC
Readme
Abhedya WASM
WebAssembly bindings for Abhedya: Post-Quantum Sanskrit Cryptography.
This package brings the power of the Abhedya Rust core (Lattice-based LWE, $N=768$) to the JavaScript ecosystem via WebAssembly.
Installation
npm install @abhedyam/wasmUsage
import init, { AbhedyaWasm } from "@abhedyam/wasm";
async function main() {
// 1. Initialize WASM module
await init();
const abhedya = new AbhedyaWasm();
// 2. Generate Keys using internal CSPRNG
console.log("Generating Keys...");
abhedya.keygen();
// Keys are stored statefully in the WASM instance for security.
// 3. Encrypt Data
const message = "The quick brown fox jumps over the lazy dog";
const plainBytes = new TextEncoder().encode(message);
// Mode: false = Standard (Binary), true = Metered (Sanskrit Steganography)
const encrypted = abhedya.encrypt(plainBytes, false);
console.log(`Ciphertext Size: ${encrypted.length} bytes`);
// 4. Decrypt Data
const decrypted = abhedya.decrypt(encrypted);
console.log("Decrypted:", new TextDecoder().decode(decrypted));
}
main();API Reference
new AbhedyaWasm()
Creates a new cryptographic context. The state (keys) is encapsulated within this instance.
.keygen()
Generates a new Kyber-768 equivalent Lattice Keypair ($N=768, Q=3329$).
- Returns:
void(Keys are stored internally).
.encrypt(data: Uint8Array, metered: boolean): Uint8Array
Encrypts the input bytes.
data: The plaintext bytes.metered:false: Standard Mode. High-throughput binary output.true: Metered Mode. Output is shaped to match valid Sanskrit prosody (Anushtubh meter) for steganography.
- Returns: The ciphertext bytes.
.decrypt(ciphertext: Uint8Array): Uint8Array
Decrypts the input using the stored private key.
- Returns: The decrypted plaintext bytes.
- Performance: Uses O(1) Sanskrit-Phonetic lookup for ultra-fast decryption (~2.39µs).
