1.1.4
WebAssembly port of Ed25519 signatures and X25519 key exchange
Repository
Current version released
2 years ago
Ed25519 for WebAssembly
WebAssembly port of Ed25519_dalek, a Rust implementation of Ed25519 signatures.
Install (Node)
npm i ed25519_dalek
Test (Deno)
deno run --allow-net https://deno.land/x/ed25519_dalek/deno/test.ts
Basic usage (Deno)
import Ed25519, {
Ed25519Keypair,
Ed25519PublicKey,
Ed25519Signature,
} from "https://deno.land/x/ed25519_dalek/deno/mod.ts";
// import Ed25519, {
// Ed25519Keypair,
// Ed25519PublicKey,
// Ed25519Signature,
// } from "ed25519_dalek";
await Ed25519();
// -- Generating an identity --
const keypair = new Ed25519Keypair();
const identity = keypair.public(); // Ed25519PublicKey
// -- Signing & Verifying --
const bytes = new TextEncoder().encode("hello world"); // Uint8Array
const proof = keypair.sign(bytes); // Ed25519Signature
const verified = identity.verify(bytes, proof); // boolean
Serializing to Uint8Array
const bytes = new Ed25519Keypair().to_bytes();
const keypair = Ed25519Keypair.from_bytes(bytes);
const bytes = keypair.public().to_bytes();
const identity = Ed25519PublicKey.from_bytes(bytes);
const bytes = keypair.sign(input).to_bytes();
const proof = Ed25519Signature.from_bytes(bytes);
Building
- Install Deno
- Install wasm-pack
cargo install wasm-pack
- Install dependencies
npm install
- Build wasm and module
npm run build