-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
[package] | ||
name = "wasm-key-manager" | ||
description = "Holochain-compatible key management for Holo web users" | ||
version = "1.1.0" | ||
version = "1.1.1" | ||
authors = [ "[email protected]", "[email protected]", "[email protected]"] | ||
edition = "2021" | ||
repository = "https://github.com/Holo-Host/chaperone-key-manager" | ||
repository = "https://github.com/Holo-Host/wasm-key-manager" | ||
|
||
[dependencies] | ||
console_error_panic_hook = "0.1.7" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |