Skip to content
Holochain-compatible key management for Holo web users
Rust JavaScript Makefile Nix Shell
Branch: develop
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests/unit
.gitignore
.jsdoc.json
CONTRIBUTING.md
Cargo.lock
Cargo.toml
Makefile
README.md
build.sh
default.nix
package-lock.json
package.json
pkgs.nix
shell.nix

README.md

Wasm Key Manager

Rust/Wasm key management implementation that uses Ed25519 signing algorithm and Argon2 key derivation. The private key remains in Wasm memory with no direct access for Javascript.

Release

Release source - https://github.com/Holo-Host/chaperone/tree/master/key-manager/

API Reference

API Reference

Usage

const { KeyManager, deriveSeedFrom } = require('@holo-host/wasm-key-manager');
const crypto = require('crypto');

const seed = crypto.randomBytes( 32 );
const hha_id = new Uint8Array([
    66, 123, 133, 136, 133,   6, 247, 116,
     4,  59,  43, 206, 131, 168, 123,  44,
    54,  52,   3,  53, 134,  75, 137,  43,
    63,  26, 216, 191,  67, 117,  38, 142
]);

// or derive seed
const seed = deriveSeedFrom( hha_id, "someone@example.com", "Passw0rd!");

const message = "Hello World";
const keys = new KeyManager( seed );

const signature = keys.sign( message );
const verified = keys.verify( message, signature );

const public_key = keys.publicKey();
const verified = keys.verifyWithPublicKey( message, signature, public_key );

Bundle for web

bootstrap.js

import("./index.js")
    .then(m => Object.assign(window, m))
    .catch(e => console.error("Error importing `index.js`:", e));

index.js

const { KeyManager, deriveSeedFrom } = require("@holo-host/wasm-key-manager");

module.exports = {
    KeyManager,
    deriveSeedFrom,
};

webpack.config.js

module.exports = {
    target: "web",

    entry: "./bootstrap.js",

    // Assign 'module.exports' to the window variable
    output: {
        libraryTarget: "window",
    },
};

Contributing

You can’t perform that action at this time.