RELIC Cryptographic Meta-Toolkit
repository·main·Indexed 19 days ago
https://github.com/relic-toolkit/relicA high-performance, research-oriented cryptographic meta-toolkit providing low-level primitives including integer and field arithmetic, elliptic curves, and bilinear maps, as well as high-level protocols such as RSA, ECDSA, BLS, and pairing delegation. Designed for portability and flexibility, RELIC allows developers to build toolkits tailored to specific security levels. Note: This is alpha-quality software and is dual-licensed under Apache 2.0 and LGPL 2.1-or-above.
What's inside RELIC
- RELIC is a research-oriented cryptographic meta-toolkit designed for efficiency and flexibility. It allows developers to build cryptographic toolkits tailored to specific security levels and algorithmic requirements. The project emphasizes portability, ease of experimentation with alternative implementations, and maximum efficiency through flexible configuration.
Supported cryptographic algorithms in RELIC
mainRELIC provides a wide range of cryptographic primitives and protocols, including:
Arithmetic
- Multiple-precision integer arithmetic
- Prime and Binary field arithmetic
- Elliptic curves over prime and binary fields (NIST curves and pairing-friendly curves)
- Bilinear maps and related extension fields
Protocols
- Standard Protocols: RSA, Rabin, ECDSA, ECMQV, ECSS (Schnorr), ECIES, Sakai-Ohgishi-Kasahara ID-based authenticated key agreement, Boneh-Lynn-Schacham (BLS), Boneh-Boyen short signatures, Paillier and Benaloh homomorphic encryption systems.
- Pairing Delegation:
- Pairing delegation protocols (with public and private inputs).
- Batch pairing delegation protocols (with public inputs).
Build RELIC from source
mainDetailed instructions for building the RELIC library are maintained in the project Wiki.
For users working with pairing delegation protocols:
- To verify implementations, check the output of the
test_cptesting binary. - To evaluate performance, check the output of the
bench_cpbenchmarking binary. - In
bench_cpoutput, sequential versions are prefixed withcp_amore_* (1)and batch versions are prefixed withcp_amore_* (AGGS). - You can adjust the number of pairings in the batch version by modifying the
AGGSparameter directly in the source code.
- To verify implementations, check the output of the
Initialize and clean up the RELIC core
mainBefore performing any cryptographic operations, you must initialize the RELIC core using
core_init(). This function returnsRLC_OKon success or an error code on failure. When finished with the library, callcore_clean()to release global resources. Failure to initialize the core will result in errors during subsequent API calls.if (core_init() != RLC_OK) { // Handle error return 1; } // ... perform cryptographic operations ... core_clean();Set public parameters in RELIC
mainUse
pc_param_set_any()to set the public parameters for the cryptographic operations. This is a required step aftercore_init()and before performing cryptographic tasks like key generation or signing.if (pc_param_set_any() != RLC_OK) { core_clean(); return 1; }Security disclaimer and warnings
main⚠️ WARNING
RELIC is considered alpha-quality software.
- Correctness & Security: Implementations may not be correct or secure and may include patented algorithms.
- Configuration Risk: There are many configuration options that can make the library insecure.
- Side-Channels: Side-channel and fault injection attacks are generally not considered unless explicitly noted.
- API Stability: Backward API compatibility with early versions is not guaranteed.
Use at your own risk.
Licensing and usage terms for RELIC
mainRELIC is dual-licensed under Apache 2.0 and LGPL 2.1-or-above. Users may choose either license for their use case.
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1Note on derived works: Since version 0.3.3, static linking and changes made to the configuration or build system are explicitly exempted from being classified as derived works. Refer to the individual LICENSE files for full legal details.
Verify an authenticated computation using `cp_mklhs_ver`
mainThe
cp_mklhs_verfunction performs a full verification of an authenticated computation. It checks the signaturesigagainst the computed resultres, the secret key/parameterst, the database, region acronyms, labels, function values, and public keys.// Returns true if the signature is valid for the computation bool isValid = cp_mklhs_ver(sig, res, t, DATABASE, acs, labels, f, flen, pk, num_states);Generate a key pair using `cp_mklhs_gen`
mainTo generate a key pair for a signer, use
cp_mklhs_gen. This function takes a secret key (sk) and populates a public key (pk).// sk is the secret key, pk is the public key cp_mklhs_gen(sk, pk);Verify with precomputed values using `cp_mklhs_onv`
mainFor optimized verification,
cp_mklhs_onvcan be used when precomputed valuescsare available. This is typically faster than a standard verification.// Verifies using precomputed values cs bool isValid = cp_mklhs_onv(sig, res, t, DATABASE, acs, cs, ft, pk, num_states);Compute a function over messages using `cp_mklhs_fun`
mainIn authenticated computation scenarios,
cp_mklhs_funcan be used to compute a valuetbased on a set of messagesmand a functionf(represented as an array of values).// t is the result, m is the messages, f is the function values cp_mklhs_fun(t, m, f, length);Set up Elliptic Curve parameters
mainTo use a specific curve (such as Tweedledum), use
ec_param_set_any(). This function configures the global elliptic curve context. If it returnsRLC_ERR, the curve could not be set.if (ec_param_set_any() == RLC_ERR) { // Handle error }