Skip to main content

vega_prover/
lib.rs

1// Copyright (c) Microsoft Corporation.
2// SPDX-License-Identifier: MIT
3// This file is part of the vega-prover project.
4// See the LICENSE file in the project root for full license information.
5// Source repository: https://github.com/Microsoft/vega-prover
6
7//! This library implements the ZK provers of Vega, optimized for low-latency
8//! client-side proving of statements over signed data.
9#![deny(
10  warnings,
11  unused,
12  future_incompatible,
13  nonstandard_style,
14  rust_2018_idioms,
15  missing_docs
16)]
17#![allow(non_snake_case)]
18#![allow(clippy::upper_case_acronyms)]
19#![allow(clippy::type_complexity)]
20#![allow(clippy::too_many_arguments)]
21#![deny(unsafe_code)]
22
23// private modules
24mod digest;
25mod math;
26mod nifs;
27mod r1cs;
28mod zk;
29
30#[macro_use]
31mod macros;
32
33// public modules
34pub mod bellpepper;
35pub mod errors;
36pub mod provider;
37pub mod traits;
38
39// internal modules
40mod big_num;
41mod polys;
42mod sumcheck;
43
44// public modules for proof systems
45pub(crate) mod spartan_relaxed; // single-circuit prover for relaxed R1CS (non-ZK)
46pub mod vega_mc_zkp; // multi-circuit (NeutronNova folding) prover with zero-knowledge
47pub mod vega_sc; // single-circuit (Spartan) prover without zero-knowledge
48pub mod vega_sc_zkp; // single-circuit (Spartan) prover with zero-knowledge
49
50/// Start a span + timer, return `(Span, Instant)`.
51macro_rules! start_span {
52    ($name:expr $(, $($fmt:tt)+)?) => {{
53        let span       = tracing::info_span!($name $(, $($fmt)+)?);
54        let span_clone = span.clone();    // lives as long as the guard
55        let _guard      = span_clone.enter();
56        (span, std::time::Instant::now())
57    }};
58}
59pub(crate) use start_span;
60
61// The default width used for monolithic commitments.
62pub(crate) const DEFAULT_COMMITMENT_WIDTH: usize = 2048;
63
64use traits::{Engine, pcs::PCSEngineTrait};
65type CommitmentKey<E> = <<E as traits::Engine>::PCS as PCSEngineTrait<E>>::CommitmentKey;
66type VerifierKey<E> = <<E as traits::Engine>::PCS as PCSEngineTrait<E>>::VerifierKey;
67type Commitment<E> = <<E as Engine>::PCS as PCSEngineTrait<E>>::Commitment;
68type PCS<E> = <E as Engine>::PCS;
69type Blind<E> = <<E as Engine>::PCS as PCSEngineTrait<E>>::Blind;