Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Don't use from_ed25519_bytes when making keypairs #12

Closed
wants to merge 15 commits into from
Closed
22 changes: 13 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
name = "x25519-chacha20poly1305"
version = "0.1.0"
edition = "2021"
authors = [ "John Sahhar <[email protected]>" ]
authors = ["John Sahhar <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "x25519 & chacha20poly1305"
repository = "https://github.com/entropyxyz/x25519-chacha20poly1305"

[dependencies]
hex = "*"
bip39 ={ git="https://github.com/infincia/bip39-rs.git", tag="v0.6.0-beta.1" }
bip39 = { git = "https://github.com/infincia/bip39-rs.git", tag = "v0.6.0-beta.1" }
wasm-bindgen = "0.2.83"
x25519-dalek = { version = "2.0.0-rc.2", features = ["static_secrets"] }
serde ={ version="1.0", features=["derive"] }
serde_json ="1.0"
blake2 ="0.10.4"
chacha20poly1305="0.10.1"
sp-core ="6.0.0"
generic-array ="0.14.6"
x25519-dalek = { version = "2.0.0", features = ["static_secrets"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
blake2 = "0.10.4"
chacha20poly1305 = "0.10.1"
sp-core = "6.0.0"
generic-array = "0.14.6"
rand_core = { version = "0.6.4", features = ["getrandom"] }
getrandom = { version = "0.2", features = ["js"] }
schnorrkel = "0.9.1"
js-sys = "0.3.64"
thiserror = "1.0.47"
zeroize = "1.5.7"

[lib]
crate-type = ["cdylib", "rlib"]
38 changes: 37 additions & 1 deletion pkg/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,49 @@
### x25519-chacha20poly1305

---
**WARNING: This code has not been audited and is not yet suitable for production. Use at your own risk.**

---

> NOTE: make sure you have your C archiver and compiler env vars set, or `secp256k1-sys` will fail to build
>
> e.g.
> `AR=/opt/homebrew/opt/llvm/bin/llvm-ar`
> `CC=/opt/homebrew/opt/llvm/bin/clang`

Nodejs package for x25519 key exchange and chacha20poly1305 encryption, written in Rust compiled to WASM.

## Development process

### Install dependencies

Requires `wasm-pack` which can be installed with `cargo install wasm-pack`.
See `example/ci-test.sh` for example of how to install both rust and javascript dependencies.

### Compile

Compile a nodejs/wasm library from the Rust source.

```sh
make
```

### Link

Link the nodejs/wasm library locally.

```sh
make link
```

### Test

After compiling and linking, run:

```sh
ts-node example/test.ts
```

### NPM

link to package on npm: https://www.npmjs.com/package/x25519

4 changes: 4 additions & 0 deletions pkg/x25519_chacha20poly1305.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/* tslint:disable */
/* eslint-disable */
/**
* Convert a Vec<u8> to a hex encoded string
* @param {Uint8Array} v
* @returns {string}
*/
export function to_hex(v: Uint8Array): string;
/**
* Convert a hex string to a Vec<u8>, ignoring 0x prefix
* @param {string} v
* @returns {Uint8Array}
*/
export function from_hex(v: string): Uint8Array;
/**
* Derives a public DH key from a static DH secret.
* sk must be 64 bytes in length or an error will be returned.
* @param {Uint8Array} sk
* @returns {Uint8Array}
*/
Expand Down
Loading
Loading