Skip to content

ecies/rs-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ecies-wasm

License NPM Package NPM Downloads Install size CI

A WASM binding for eciesrs.

Install

npm install ecies-wasm

Usage

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.

API

export function generateKeypair(): Uint8Array[]; // [sk, pk]
export function encrypt(pk: Uint8Array, msg: Uint8Array): Uint8Array;
export function decrypt(sk: Uint8Array, msg: Uint8Array): Uint8Array;

Build and test

wasm-pack build
wasm-pack build --target web
wasm-pack test --node

Changelog

See CHANGELOG.md.