arcanum_zkp/lib.rs
1//! # Arcanum Zero-Knowledge Proofs
2//!
3//! Zero-knowledge proof systems for proving statements without revealing secrets.
4//!
5//! ## Bulletproofs
6//!
7//! Efficient range proofs without trusted setup:
8//! - Prove a committed value is within a range [0, 2^n)
9//! - Logarithmic proof size
10//! - Aggregatable for multiple proofs
11//!
12//! ## Schnorr Proofs
13//!
14//! Interactive proofs of knowledge:
15//! - Proof of discrete log knowledge
16//! - Proof of equality of discrete logs
17//! - Made non-interactive via Fiat-Shamir
18//!
19//! ## Pedersen Commitments
20//!
21//! Information-theoretically hiding commitments:
22//! - Perfectly hiding: reveals nothing about the value
23//! - Computationally binding: cannot open to different value
24//! - Homomorphic: C(a) + C(b) = C(a + b)
25//!
26//! ## Example
27//!
28//! ```ignore
29//! use arcanum_zkp::prelude::*;
30//!
31//! // Range proof: prove value is in [0, 2^32)
32//! let value = 42u64;
33//! let blinding = Scalar::random(&mut OsRng);
34//! let (commitment, proof) = RangeProof::prove(value, blinding, 32)?;
35//!
36//! // Verify the proof
37//! assert!(proof.verify(&commitment, 32)?);
38//! ```
39
40#![deny(unsafe_code)]
41#![allow(clippy::needless_return)]
42#![allow(clippy::needless_borrow, clippy::needless_borrows_for_generic_args)]
43#![allow(unused_imports, unused_mut, dead_code, clippy::needless_range_loop)]
44#![warn(missing_docs, rust_2018_idioms)]
45
46mod commitment;
47mod traits;
48
49#[cfg(feature = "bulletproofs")]
50pub mod range_proof;
51
52#[cfg(feature = "schnorr-proofs")]
53pub mod schnorr_proof;
54
55pub use commitment::{PedersenCommitment, PedersenOpening};
56pub use traits::*;
57
58#[cfg(feature = "bulletproofs")]
59pub use range_proof::{RangeProof, RangeProofBatch};
60
61#[cfg(feature = "schnorr-proofs")]
62pub use schnorr_proof::{DiscreteLogProof, EqualityProof, SchnorrProof, SchnorrProofBuilder};
63
64/// Prelude for convenient imports.
65pub mod prelude {
66 pub use crate::commitment::{PedersenCommitment, PedersenOpening};
67 pub use crate::traits::*;
68
69 #[cfg(feature = "bulletproofs")]
70 pub use crate::range_proof::{RangeProof, RangeProofBatch};
71
72 #[cfg(feature = "schnorr-proofs")]
73 pub use crate::schnorr_proof::{DiscreteLogProof, EqualityProof, SchnorrProof};
74}
75
76/// Re-export curve25519-dalek types for convenience.
77pub mod curve {
78 pub use curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT;
79 pub use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
80 pub use curve25519_dalek::scalar::Scalar;
81}