eczkp/lib.rs
1/*
2 * eczkp - A library for Zero Knowledge Proof protocols using elliptic curves
3 *
4 * Copyright (C) 2024 Lucas M. de Jong Larrarte
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20//! # eczkp - A Library for Zero Knowledge Proofs using Elliptic Curves
21//!
22//! `eczkp` is a cryptographic library for creating and verifying zero-knowledge proofs
23//! based on elliptic curves. This library implements a simple protocol that allows one
24//! party (the prover) to prove knowledge of a secret without revealing it, while the
25//! other party (the verifier) verifies the proof without learning the secret.
26//!
27//! ## Features
28//! - **Prover and Verifier**: Structures for handling the roles of prover and verifier in a zero-knowledge protocol.
29//! - **Elliptic Curve Support**: Supports elliptic curve cryptography through the `elliptic_curve` crate.
30//! - **Commitment, Challenge, Answer**: Well-defined cryptographic constructs for creating proofs.
31//! - **Secure Memory Management**: Leverages the `zeroize` crate to ensure secret data is securely wiped from memory.
32//!
33//! ## Example Usage
34//! Here is a simple example of how to use `eczkp` to perform a zero-knowledge proof with the Schnorr protocol:
35//!
36//! ```rust
37//! use eczkp::schnorr::ec::{SchnorrECProver, SchnorrECVerifier};
38//! use eczkp::schnorr::traits::{Prover, Verifier};
39//! use elliptic_curve::SecretKey;
40//! use rand::rngs::OsRng;
41//! use p256::NistP256;
42//!
43//! // Generate a new secret key and public key
44//! let secret_key = SecretKey::<NistP256>::random(&mut OsRng);
45//! let public_key = secret_key.public_key();
46//!
47//! // Prover creates a commitment
48//! let prover = SchnorrECProver::new(&secret_key, &mut OsRng);
49//! let commitment = prover.commitment();
50//!
51//! // Verifier generates a random challenge
52//! let verifier = SchnorrECVerifier::new(&public_key, commitment, &mut OsRng);
53//! let challenge = verifier.challenge();
54//!
55//! // Prover answers the challenge
56//! let answer = prover.answer(challenge);
57//!
58//! // Verifier verifies the proof
59//! assert!(verifier.verify(answer).is_ok());
60//! ```
61//!
62//! ## Crate Dependencies
63//! - `elliptic_curve`: Provides elliptic curve operations, used for cryptographic operations.
64//! - `zeroize`: Ensures sensitive data such as secrets are wiped from memory after use.
65//! - `rand_core`: Provides traits for secure random number generation.
66//!
67//! ## License
68//! This library is licensed under the GNU General Public License v3.0.
69
70/// Module for error types.
71pub mod error;
72/// Module for the Schnorr ZKP protocol.
73pub mod schnorr;