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