14 releases (1 stable)

1.0.0 Mar 31, 2020
1.0.0-rc.1 Feb 7, 2020
0.13.0-rc.2 Dec 4, 2019
0.12.0 Aug 14, 2019
0.10.0 Dec 14, 2018

#1 in #exonum

Download history 132/week @ 2023-12-05 76/week @ 2023-12-12 88/week @ 2023-12-19 71/week @ 2023-12-26 52/week @ 2024-01-02 61/week @ 2024-01-09 55/week @ 2024-01-16 55/week @ 2024-01-23 41/week @ 2024-01-30 89/week @ 2024-02-06 74/week @ 2024-02-13 109/week @ 2024-02-20 112/week @ 2024-02-27 64/week @ 2024-03-05 97/week @ 2024-03-12 72/week @ 2024-03-19

392 downloads per month
Used in 19 crates (9 directly)

Apache-2.0

60KB
842 lines

Cryptography primitives for Exonum

Travis Build Status License: Apache-2.0 rust 1.42.0+ required

exonum-crypto provides a high-level API for work with various cryptography tasks.

Capabilities of exonum-crypto include:

  • Calculating the hash of data;
  • Generating key pairs for work with digital signatures;
  • Creating and verifying of digital signatures.

The main backend for exonum-crypto is sodiumoxide, and the used algorithms are:

  • SHA-256 for hashing.
  • Ed25519 for digital signatures.

Consult the crate docs for more details.

Examples

Signing data and verifying the signature:

exonum_crypto::init();
let (public_key, secret_key) = exonum_crypto::gen_keypair();
let data = [1, 2, 3];
let signature = exonum_crypto::sign(&data, &secret_key);
assert!(exonum_crypto::verify(&signature, &data, &public_key));

Hashing fixed amount of data:

exonum_crypto::init();
let data = [1, 2, 3];
let hash = exonum_crypto::hash(&data);

Hashing data by chunks:

use exonum_crypto::HashStream;

exonum_crypto::init();
let data: Vec<[u8; 5]> = vec![[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]];
let mut hash_stream = HashStream::new();
for chunk in data {
    hash_stream = hash_stream.update(&chunk);
}
let _ = hash_stream.hash();

Usage

Include exonum-crypto as a dependency in your Cargo.toml:

[dependencies]
exonum-crypto = "1.0.0"

License

exonum-crypto is licensed under the Apache License (Version 2.0). See LICENSE for details.

Dependencies

~1.9–4.5MB
~76K SLoC