22 unstable releases (10 breaking)

0.11.2 Sep 6, 2021
0.11.1 Jul 5, 2021
0.10.0 Jul 2, 2021
0.9.0 Mar 18, 2021
0.0.1 Mar 29, 2019

#147 in Cryptography

Download history 390/week @ 2022-06-16 480/week @ 2022-06-23 411/week @ 2022-06-30 516/week @ 2022-07-07 636/week @ 2022-07-14 1126/week @ 2022-07-21 1118/week @ 2022-07-28 494/week @ 2022-08-04 484/week @ 2022-08-11 418/week @ 2022-08-18 690/week @ 2022-08-25 468/week @ 2022-09-01 1361/week @ 2022-09-08 739/week @ 2022-09-15 901/week @ 2022-09-22 825/week @ 2022-09-29

3,947 downloads per month
Used in 13 crates (12 directly)

BSD-3-Clause

480KB
8K 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.11.0

  • All dependencies to use the digest 0.9 traits and APIs.

Clients of this generally only need to update the result method to finalize; and obviously make use of the v0.9 digest::Digest trait where necessary.

As a result, the deprecated k12, sha3 and Blake3 objects have been removed. Methods and functins that need a hasher are all generic over Digest.

We retain the convenience wrapper over VarBlake2B to produce 256 bit hashes and implement the necessary sub-traits to support digest::Digest.

v0.10.0

  • Support stable rust

Updated dependencies such that Rust stable 1.53 is now supported. The optimised avx_2 option will NOT rust on stable because there's still an unstable feature on subtle-ng. BUT this feature is actually for doc generation and has been removed from Rust. As soon as subtle-ng merges https://github.com/dalek-cryptography/subtle/pull/85, avx2 will probably be supported on stable as well.

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

~8MB
~125K SLoC