Tari Crypto

Coverage Status

This crate is part of the Tari Cryptocurrency project.

Major features of this library include:

The tari_crypto crate makes heavy use of the excellent Dalek libraries. The default implementation for Tari ECC is the Ristretto255 curve.

Compiling to WebAssembly

To build the WebAssembly module, the wasm feature must be enabled:

$ wasm-pack build . -- --features "wasm"

To generate a module for use in node.js, use this command:

$ wasm-pack build --target nodejs -d tari_js . -- --features "wasm"

If you receive compoiler errors related to clear_on_drop, then add the no_cc or no_cc_nightly feature flags.

Note: Node v10+ is needed for the WASM

Example (Node.js)

```js const keys = KeyRing.new();

// Create new keypair keys.newkey("Alice"); keys.newkey("Bob"); console.log(${keys.len()} keys in ring); // 2 console.log("kA = ", keys.privatekey("Alice")); console.log("PB = ", keys.publickey("Bob")); keys.free(); ````

Benchmarks

To run the benchmarks:

$ cargo bench

The benchmarks use Criterion and will produce nice graphs (if you have gnuplot installed)

To run the benchmarks with SIMD instructions:

$ cargo bench --features "avx2"

Change log

v0.2.0

General

WASM module

Building the C FFI module

To build the C bindings, you can run

make ffi

To build the release version (recommended):

make ffi-release

To run the small demo:

make demo
./bin/demo