18 releases (8 breaking)

0.9.0 Mar 18, 2021
0.8.2 Dec 21, 2020
0.8.0 Sep 29, 2020
0.6.0 Jul 28, 2020
0.0.1 Mar 29, 2019

#74 in Cryptography

Download history 893/week @ 2021-02-26 548/week @ 2021-03-05 529/week @ 2021-03-12 486/week @ 2021-03-19 479/week @ 2021-03-26 338/week @ 2021-04-02 465/week @ 2021-04-09 472/week @ 2021-04-16 381/week @ 2021-04-23 423/week @ 2021-04-30 573/week @ 2021-05-07 460/week @ 2021-05-14 510/week @ 2021-05-21 289/week @ 2021-05-28 197/week @ 2021-06-04 123/week @ 2021-06-11

2,466 downloads per month
Used in 13 crates (12 directly)

BSD-3-Clause

400KB
6.5K SLoC

Tari Crypto

Coverage Status

This crate is part of the Tari Cryptocurrency project.

Major features of this library include:

  • Pedersen commitments
  • Schnorr Signatures
  • Generic Public and Secret Keys
  • Musig!

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)

const keys = KeyRing.new();

// Create new keypair
keys.new_key("Alice");
keys.new_key("Bob");
console.log(`${keys.len()} keys in ring`); // 2
console.log("kA = ", keys.private_key("Alice"));
console.log("PB = ", keys.public_key("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 and crate version now match. Eliminate that confusion.

WASM module

  • Breaking change: KeyRing.sign doesn't take a nonce any more. It's not needed, and why risk someone re-using it?
  • New method: key_utils.sign to sign keys not in the key ring
  • New module: Commitments

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

Dependencies

~9MB
~160K SLoC