RELIC Cryptographic Meta-Toolkit

repository·main·Indexed 19 days ago

https://github.com/relic-toolkit/relic

A 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.

Tokens
1.9K
Snippets
12
Records
17
Agent score
68%

What's inside RELIC

  1. Overview of RELIC cryptographic meta-toolkit

    main
    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.
  2. Supported cryptographic algorithms in RELIC

    main

    RELIC 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).
  3. Build RELIC from source

    main

    Detailed 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_cp testing binary.
    • To evaluate performance, check the output of the bench_cp benchmarking binary.
    • In bench_cp output, sequential versions are prefixed with cp_amore_* (1) and batch versions are prefixed with cp_amore_* (AGGS).
    • You can adjust the number of pairings in the batch version by modifying the AGGS parameter directly in the source code.
  4. Initialize and clean up the RELIC core

    main

    Before performing any cryptographic operations, you must initialize the RELIC core using core_init(). This function returns RLC_OK on success or an error code on failure. When finished with the library, call core_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();
  5. Set public parameters in RELIC

    main

    Use pc_param_set_any() to set the public parameters for the cryptographic operations. This is a required step after core_init() and before performing cryptographic tasks like key generation or signing.

    if (pc_param_set_any() != RLC_OK) {
        core_clean();
        return 1;
    }
  6. 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.

  7. Licensing and usage terms for RELIC

    main

    RELIC 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.1

    Note 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.

  8. Verify an authenticated computation using `cp_mklhs_ver`

    main

    The cp_mklhs_ver function performs a full verification of an authenticated computation. It checks the signature sig against the computed result res, the secret key/parameters t, 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);
  9. Verify with precomputed values using `cp_mklhs_onv`

    main

    For optimized verification, cp_mklhs_onv can be used when precomputed values cs are 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);
  10. Compute a function over messages using `cp_mklhs_fun`

    main

    In authenticated computation scenarios, cp_mklhs_fun can be used to compute a value t based on a set of messages m and a function f (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);