frontend/components/
sha2_gkr.rs

1pub mod brent_kung_adder;
2pub mod nonlinear_gates;
3/// Utilities related to Ripple Carry Adder
4pub mod ripple_carry_adder;
5pub mod sha256_bit_decomp;
6use crate::layouter::builder::{Circuit, CircuitBuilder, InputLayerNodeRef, NodeRef};
7use shared_types::Field;
8
9/// Trait that's implemented by all SHA256 adders
10pub trait AdderGateTrait<F: Field> {
11    /// Data type of actual elements such as u32 (in sha256) or u64 (in
12    /// sha512)
13    type IntegralType: std::ops::Add<Output = Self::IntegralType>;
14
15    /// Build the layout of the adder circuit. The `carry_layer`
16    /// Auxiliary data is meant for passing in any additional layer or
17    /// circuit or wire information that can help the prover.
18    fn layout_adder_circuit(
19        circuit_builder: &mut CircuitBuilder<F>,   // Circuit builder
20        x_node: &NodeRef<F>,                       // reference to x in x + y
21        y_node: &NodeRef<F>,                       // reference to y in x + y
22        carry_layer: Option<InputLayerNodeRef<F>>, // Carry Layer information
23    ) -> Self;
24
25    /// Returns a reference to the note that corresponds to the adder
26    /// gate
27    fn get_output(&self) -> NodeRef<F>;
28
29    /// Optional trait that compute the actual sum and create any possible commitments
30    /// needed.
31    fn perform_addition(
32        &self,
33        _circuit: &mut Circuit<F>,
34        x: Self::IntegralType,
35        y: Self::IntegralType,
36    ) -> Self::IntegralType;
37}