4 releases

0.0.1-sol5 May 1, 2020
0.0.1-sol4 Oct 25, 2019
0.0.0 Aug 6, 2019
0.0.0-sol15 Jul 27, 2019
0.0.0-sol13 Jul 26, 2019

#6 in #libra

Download history 55/week @ 2024-03-11 62/week @ 2024-03-18 64/week @ 2024-03-25 90/week @ 2024-04-01 47/week @ 2024-04-08 43/week @ 2024-04-15 56/week @ 2024-04-22 40/week @ 2024-04-29 40/week @ 2024-05-06 62/week @ 2024-05-13 35/week @ 2024-05-20 49/week @ 2024-05-27 37/week @ 2024-06-03 34/week @ 2024-06-10 37/week @ 2024-06-17 55/week @ 2024-06-24

163 downloads per month
Used in 22 crates (8 directly)

Apache-2.0

225KB
4K SLoC


id: crypto title: Crypto custom_edit_url: https://github.com/libra/libra/edit/master/crypto/crypto/README.md

Crypto

The crypto component hosts all the implementations of cryptographic primitives we use in Libra: hashing, signing, and key derivation/generation. The parts of the library usig traits.rs contain the crypto API enforcing type safety, verifiable random functions, EdDSA & BLS signatures.

Overview

Libra makes use of several cryptographic algorithms:

  • SHA-3 as the main hash function. It is standardized in FIPS 202. It is based on the tiny_keccak library.
  • HKDF: HMAC-based Extract-and-Expand Key Derivation Function (HKDF) based on RFC 5869. It is used to generate keys from a salt (optional), seed, and application-info (optional).
  • traits.rs introduces new abstractions for the crypto API.
  • Ed25519 performs signatures using the new API design based on ed25519-dalek library with additional security checks (e.g. for malleability).
  • BLS12381 performs signatures using the new API design based on threshold_crypto library. BLS signatures currently undergo a standardization process.
  • ECVRF implements a verifiable random function (VRF) according to draft-irtf-cfrg-vrf-04 over curve25519.
  • SLIP-0010 implements universal hierarchical key derivation for Ed25519 according to SLIP-0010.
  • X25519 to perform key exchanges. It is used to secure communications between validators via the Noise Protocol Framework. It is based on the x25519-dalek library.

How is this module organized?

    crypto/src
    ├── hash.rs             # Hash function (SHA-3)
    ├── hkdf.rs             # HKDF implementation (HMAC-based Extract-and-Expand Key Derivation Function based on RFC 5869)
    ├── macros/             # Derivations for SilentDebug and SilentDisplay
    ├── utils.rs            # Serialization utility functions
    ├── lib.rs
    ├── bls12381.rs         # Bls12-381 implementation of the signing/verification API in traits.rs
    ├── ed25519.rs          # Ed25519 implementation of the signing/verification API in traits.rs
    ├── slip0010.rs         # SLIP-0010 universal hierarchical key derivation for Ed25519
    ├── x25519.rs           # X25519 keys generation
    ├── test_utils.rs
    ├── traits.rs           # New API design and the necessary abstractions
    ├── unit_tests/         # Tests
    └── vrf/
        ├── ecvrf.rs        # ECVRF implementation using curve25519 and SHA512
        ├── mod.rs
        └── unit_tests      # Tests

Dependencies

~7.5MB
~127K SLoC