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.
- Core Structure Types
- All structures have overloads for pretty printing to screen
- Primitive Structures
crypto_hash_t: 256-bit Hashcrypto_point_t: ED25519 Elliptic Curve Point- Caching of commonly used
getypes - Simple overloads for point:
- Addition
- Subtraction
- Aliases:
crypto_public_key_tcrypto_derivation_tcrypto_key_image_tcrypto_pedersen_commitment_t
- Caching of commonly used
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 Entropycrypto_seed_t: BIP-0039 Seed- Allows for generation of the seed using
crypto_entropy_tor 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
- Allows for generation of the seed using
crypto_hd_key_t: BIP-0044 Hierarchical Deterministic Key-
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_twhen required
- Vector Types
crypto_hash_vector_tcrypto_point_vector_t- Simple overloads for:
- Addition
- Subtraction
- Multiplication with scalars
- Simple overloads for:
crypto_scalar_vector_t- Simple overloads for:
- Addition
- Subtraction
- Multiplication
- Simple overloads for:
- Cryptographic Signature Types
- Proof Types
crypto_bulletproof_t: Bulletproofscrypto_bulletproof_plus_t: Bulletproofs+
- 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()
- Simple hashing via
- 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()
- Argon2d via
- 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
- Utilizes SHA3 instead of CRC32 for checksum generation
- Languages
- ED25519 Primitives
- Scalar Transcripts
- Easily generates deterministic scalar values based upon repetitive
update()calls
- Easily generates deterministic scalar values based upon repetitive
- Signature Generation / Verification
- Message Signing & Validation
- RFC-8032 ED25519
- Non-RFC 8032 (e.g. CryptoNote)
- Borromean Ring Signatures
- CLSAG Ring Signatures
- Optional use of pedersen commitment to zero proving
- Triptych Signatures
- Requires use of pedersen commitment to zero proving
- Message Signing & Validation
- Zero-knowledge proofs
- RingCT
- Pedersen Commitments
- Pseudo Commitments
- Blinding Factors
- Amount Masking
- 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()andverify()
- 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()andverify()
- RingCT
- Serialization
- Byte/Binary Serialization & De-Serialization
- Structure to/from JSON provided via RapidJSON
- Structure to/from Hexadecimal encoded string representations
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>C++ API documentation can be found in the headers (.h)
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 cryptogit submodule add https://github.com/gibme-c/crypto external/crypto
git submodule update --init --recursiveExternal 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.