fullcodec_plonk/constraint_system/
witness.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4//
5// Copyright (c) DUSK NETWORK. All rights reserved.
6
7//! This module holds the components needed in the Constraint System.
8//! The components used are Variables, Witness and Wires.
9
10/// Stores the data for a specific wire in an arithmetic circuit
11/// This data is the gate index and the type of wire
12/// Left(1) signifies that this wire belongs to the first gate and is the left
13/// wire
14#[derive(Copy, Clone, PartialEq, Eq, Debug)]
15pub(crate) enum WireData {
16    /// Left Wire of n'th gate
17    Left(usize),
18    /// Right Wire of n'th gate
19    Right(usize),
20    /// Output Wire of n'th gate
21    Output(usize),
22    /// Fourth Wire of n'th gate
23    Fourth(usize),
24}
25
26/// Witness data indexed in a [`TurboComposer`](super::TurboComposer) instance
27#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
28pub struct Witness {
29    index: usize,
30}
31
32impl Witness {
33    /// Generate a new [`Witness`]
34    pub(crate) const fn new(index: usize) -> Self {
35        Self { index }
36    }
37
38    /// Index of the allocated witness in the composer
39    pub const fn index(&self) -> usize {
40        self.index
41    }
42}