Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.1.0 #18

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,858 changes: 947 additions & 911 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "wasm-key-manager"
description = "Holochain-compatible key management for Holo web users"
version = "1.0.0"
authors = ["[email protected]", "[email protected]"]
edition = "2018"
repository = "https://github.com/Holo-Host/chaperone-key-manager"
version = "1.1.1"
authors = [ "[email protected]", "[email protected]", "[email protected]"]
edition = "2021"
repository = "https://github.com/Holo-Host/wasm-key-manager"

[dependencies]
console_error_panic_hook = "0.1.6"
ed25519-dalek = { version = "1.0.0-pre.2", features = ["nightly"] }
failure = "0.1.6"
js-sys = "0.3.30"
wasm-bindgen = "0.2.51"
wasm-bindgen-cli = "0.2.51"
wee_alloc = "0.4.4"
console_error_panic_hook = "0.1.7"
ed25519-dalek = { version = "1" }
failure = "0.1.8"
js-sys = "0.3.64"
wasm-bindgen = "0.2.87"
wasm-bindgen-cli = "0.2.86"
wee_alloc = "0.4.5"

[dependencies.argon2min]
git = "https://github.com/Holo-Host/argon2min"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pkg/package.json: Cargo.toml Cargo.lock src/*.rs
nix-shell --run 'cargo-fmt; bash build.sh'
cargo-fmt; bash build.sh

pkg/README.md:
ln ../README.md pkg
Expand Down
67 changes: 33 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,81 @@

# 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.
derivation. The private key remains in Wasm memory with no direct access for Javascript.

![](https://img.shields.io/maintenance/last%20update%202019-12/2019?style=flat-square)
![](https://img.shields.io/badge/[email protected]?style=flat-square)

## Release ![](https://img.shields.io/npm/v/@holo-host/wasm-key-manager/latest?style=flat-square)
Release source - https://github.com/Holo-Host/chaperone-key-manager/

Release source - https://github.com/Holo-Host/wasm-key-manager/

## API Reference

[API Reference](https://holo-host.github.io/chaperone/key-manager/docs/KeyManager.html)


## Usage

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

const seed = crypto.randomBytes( 32 );
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
]);
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, "[email protected]", "Passw0rd!");
const seed = deriveSeedFrom(hha_id, '[email protected]', 'Passw0rd!')

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

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

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

## Bundle for web

### `bootstrap.js`

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

### `index.js`

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

module.exports = {
KeyManager,
deriveSeedFrom,
};
KeyManager,
deriveSeedFrom,
}
```

### `webpack.config.js`

```js
module.exports = {
target: "web",
target: 'web',

entry: "./bootstrap.js",
entry: './bootstrap.js',

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

## Contributing

- [master/../CONTRIBUTING.md](https://github.com/Holo-Host/chaperone-key-manager/blob/master/README.md)
- [master/../CONTRIBUTING.md](https://github.com/Holo-Host/wasm-key-manager/blob/master/README.md)
- [./CONTRIBUTING.md](./CONTRIBUTING.md)
3 changes: 0 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ PACKAGE_NAME=$(basename $(jq -r .name pkg/package.json | tr - _))

cp pkg-nodejs/${PACKAGE_NAME}.js pkg/${PACKAGE_NAME}_node.js

sed "s/${PACKAGE_NAME}.js')/${PACKAGE_NAME}_node.js')/" \
pkg-nodejs/${PACKAGE_NAME}_bg.js > pkg/${PACKAGE_NAME}_bg.js

PACKAGE_JQ_FILTER=$(cat <<END
.files += ["${PACKAGE_NAME}_bg.js"] | .main = "${PACKAGE_NAME}_node.js"
END
Expand Down
34 changes: 0 additions & 34 deletions default.nix

This file was deleted.

4 changes: 0 additions & 4 deletions pkgs.nix

This file was deleted.

7 changes: 0 additions & 7 deletions shell.nix

This file was deleted.