A WASM binding for eciesrs.
npm install ecies-wasm
import init, * as ecies from "ecies-wasm";
const encoder = new TextEncoder();
const decoder = new TextDecoder();
// if built with vite without plugin
// can also run with bun/deno
init().then(() => {
const [sk, pk] = ecies.generateKeypair();
const data = encoder.encode("hello ecies🔒");
const encrypted = ecies.encrypt(pk, data);
const decrypted = decoder.decode(ecies.decrypt(sk, encrypted));
console.log("decrypted: " + decrypted);
});
Check the example for how to use it in browsers.
export function generateKeypair(): Uint8Array[]; // [sk, pk]
export function encrypt(pk: Uint8Array, msg: Uint8Array): Uint8Array;
export function decrypt(sk: Uint8Array, msg: Uint8Array): Uint8Array;
wasm-pack build
wasm-pack build --target web
wasm-pack test --node
See CHANGELOG.md.