WASM Bindings for Abhedya: Sanskrit-Encoded PQC
npm install @abhedyam/wasmWebAssembly 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.
``bash`
npm install @abhedyam/wasm
`javascript
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();
`
Creates a new cryptographic context. The state (keys) is encapsulated within this instance.
Generates a new Kyber-768 equivalent Lattice Keypair ($N=768, Q=3329$).
- Returns: void (Keys are stored internally).
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.
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).