Skip to content
/ crypto Public

Standalone C++17 cryptographic primitive library: Ed25519, ring signatures (CLSAG/Triptych), Bulletproofs/BP+/BP++, FROST threshold signatures, FCMP++, BIP-39/SLIP-10/SLIP-39 key derivation, with AVX2/AVX-512 SIMD backends

License

Notifications You must be signed in to change notification settings

gibme-c/crypto

Repository files navigation

Standalone Cryptography Library

This repository a standalone cryptographic primitive wrapper library that can be included in various other projects in a variety of development environments.

The source code is designed in such a way (using overloads for the majority of cryptographic functions) to make the code base easy for humans to read.

Features

  • Core Structure Types
    • All structures have overloads for pretty printing to screen
    • Primitive Structures
      • crypto_hash_t: 256-bit Hash
      • crypto_point_t: ED25519 Elliptic Curve Point
        • Caching of commonly used ge types
        • Simple overloads for point:
          • Addition
          • Subtraction
        • Aliases:
          • crypto_public_key_t
          • crypto_derivation_t
          • crypto_key_image_t
          • crypto_pedersen_commitment_t
      • crypto_scalar_t: ED25519 Elliptic Curve Scalar
        • Conform to RFC-8032 clamping
        • Simple overloads for scalar:
          • Addition
          • Subtraction
          • Multiplication (with scalars or points)
          • Division
        • Aliases:
          • crypto_blinding_factor_t
    • Hierarchical Deterministic Keys
      • crypto_entropy_t: BIP-0039 Entropy
        • Supports 12-word (128-bit) or 24-word (256-bit) entropy values
        • Allows for the encoding and decoding of the entropy to/from Mnemonic words or phrases
        • Optionally Encodes the unix time the entropy was created into the entropy
      • crypto_seed_t: BIP-0039 Seed
        • Allows for generation of the seed using crypto_entropy_t or by loading raw bytes
          • Allows for specifying a passphrase during initialization
          • Allows for specifying the HMAC salt
        • Generates the BIP-0032 root (or "master") key & chain code
        • Allows for generating child keys
          • Note All paths are fully hardened per SLIP-0010
      • crypto_hd_key_t: BIP-0044 Hierarchical Deterministic Key
        • Equivalent to a private/public keypair
        • Allows for generating child keys
          • Note All paths are fully hardened per SLIP-0010
        • crypto_secret_key_t: ED25519 Secret Keys
        • Allows for loading a RFC-8032 private key and then the scalar value and point are derived using SHA512
        • Overloads to RFC-8032 compliant crypto_scalar_t when required
    • Vector Types
      • crypto_hash_vector_t
      • crypto_point_vector_t
        • Simple overloads for:
          • Addition
          • Subtraction
          • Multiplication with scalars
      • crypto_scalar_vector_t
        • Simple overloads for:
          • Addition
          • Subtraction
          • Multiplication
    • Cryptographic Signature Types
      • crypto_signature_t: 512-bit ED25519 signature
      • crypto_borromean_signature_t: Borromean Ring Signature
      • crypto_clsag_signature_t: CLSAG Ring Signature
      • crypto_triptych_signature_t: Triptych Signature
    • Proof Types
  • Core Functionality
    • Stealth Addresses
    • Auditing Methods
      • Prove & Verify output ownership with linking tags (key images)
    • SHA3 (256-bit)
      • Simple hashing via crypto_hash_t::sha3()
      • Simple key stretching via crypto_hash_t::sha3_slow()
    • AES
      • Simple AES wrapper encrypting/decrypting data to/from hexadecimal encoded strings
    • Argon2 Hashing
      • Argon2d via crypto_hash_t::argon2d()
      • Argon2i via crypto_hash_t::argon2i()
      • Argon2id via crypto_hash_t::argon2id()
    • Address Encoding with Checksums
      • Dual-key (spend & view)
      • Single-key
      • Base58 or CryptoNote Base58 encoding
    • Base58 Encoding
      • With or Without Checksum Calculations/Checks
      • Note: This implementation is not block-based and will not work with block-based Base58 encoding (ie. CryptoNote)
    • CryptoNote Base58 Encoding
      • With or Without Checksum Calculations/Checks
      • Note: This implementation is block-based and will not work with non-block-based Base58 encoding
    • Mnemonic Encoding
    • ED25519 Primitives
    • Scalar Transcripts
      • Easily generates deterministic scalar values based upon repetitive update() calls
  • Signature Generation / Verification
    • Message Signing & Validation
    • Borromean Ring Signatures
    • CLSAG Ring Signatures
      • Optional use of pedersen commitment to zero proving
    • Triptych Signatures
      • Requires use of pedersen commitment to zero proving
  • Zero-knowledge proofs
    • RingCT
    • Bulletproofs Range Proofs
      • Variable bit length proofs (1 to 64 bits)
      • No limits to number of values proved or verified in a single call
      • Batch Verification
      • Implements caching of common points for faster repeat calls to prove() and verify()
    • Bulletproofs+ Range Proofs
      • Variable bit length proofs (1 to 64 bits)
      • No limits to number of values proved or verified in a single call
      • Batch Verification
      • Implements caching of common points for faster repeat calls to prove() and verify()
  • Serialization
    • Byte/Binary Serialization & De-Serialization
    • Structure to/from JSON provided via RapidJSON
    • Structure to/from Hexadecimal encoded string representations

C++ Library

A CMakeLists.txt file enables easy builds on most systems.

The CMake build system builds an optimized static library for you.

However, it is best to simply include this project in your project as a dependency with your CMake project.

Please reference your system documentation on how to compile with CMake.

To use this library in your project(s) simply link against the build target (crypto-static) and include the following in your relevant source or header file(s).

#include <crypto.h>

Documentation

C++ API documentation can be found in the headers (.h)

Cloning this Repository

This repository uses submodules, make sure you pull those before doing anything if you are cloning this project.

git clone --recursive https://github.com/gibme-c/crypto
cd crypto

As a dependency

git submodule add https://github.com/gibme-c/crypto external/crypto
git submodule update --init --recursive

License

External references are provided via libraries in the Public Domain (Unlicense), MIT, and/or BSD from their respective parties. Please see CREDITS or the packages in external/ for more information.

This wrapper library is provided under the BSD-3-Clause license found in the LICENSE file.

Please make sure when using this library that you follow the licensing requirements set forth in all licenses.

About

Standalone C++17 cryptographic primitive library: Ed25519, ring signatures (CLSAG/Triptych), Bulletproofs/BP+/BP++, FROST threshold signatures, FCMP++, BIP-39/SLIP-10/SLIP-39 key derivation, with AVX2/AVX-512 SIMD backends

Topics

Resources

License

Stars

Watchers

Forks