use crate::field::field::Field; use crate::target::Target; use crate::merkle_proofs::{MerkleProofTarget, MerkleProof}; use std::convert::TryInto; /// Represents a ~256 bit hash output. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Hash { pub(crate) elements: [F; 4], } impl Hash { pub(crate) fn from_partial(mut elements: Vec) -> Self { debug_assert!(elements.len() <= 4); while elements.len() < 4 { elements.push(F::ZERO); } Self { elements: [elements[0], elements[1], elements[2], elements[3]] } } } /// Represents a ~256 bit hash output. pub struct HashTarget { pub(crate) elements: [Target; 4], } impl HashTarget { pub(crate) fn from_vec(elements: Vec) -> Self { debug_assert!(elements.len() == 4); HashTarget { elements: elements.try_into().unwrap() } } pub(crate) fn from_partial(mut elements: Vec, zero: Target) -> Self { debug_assert!(elements.len() <= 4); while elements.len() < 4 { elements.push(zero); } Self { elements: [elements[0], elements[1], elements[2], elements[3]] } } } pub struct Proof { /// Merkle root of LDEs of wire values. pub wires_root: Hash, /// Merkle root of LDEs of Z, in the context of Plonk's permutation argument. pub plonk_zs_root: Hash, /// Merkle root of LDEs of the quotient polynomial components. pub quotient_polys_root: Hash, /// Purported values of each polynomial at each challenge point. pub openings: Vec>, /// A FRI argument for each FRI query. pub fri_proofs: Vec>, } pub struct ProofTarget { /// Merkle root of LDEs of wire values. pub wires_root: HashTarget, /// Merkle root of LDEs of Z, in the context of Plonk's permutation argument. pub plonk_zs_root: HashTarget, /// Merkle root of LDEs of the quotient polynomial components. pub quotient_polys_root: HashTarget, /// Purported values of each polynomial at each challenge point. pub openings: Vec, /// A FRI argument for each FRI query. pub fri_proofs: Vec, } pub struct FriProof { /// A Merkle root for each reduced polynomial in the commit phase. pub commit_phase_merkle_roots: Vec>, /// Merkle proofs for the original purported codewords, i.e. the subject of the LDT. pub initial_merkle_proofs: Vec>, /// Merkle proofs for the reduced polynomials that were sent in the commit phase. pub intermediate_merkle_proofs: Vec>, /// The final polynomial in coefficient form. pub final_poly: Vec, } /// Represents a single FRI query, i.e. a path through the reduction tree. pub struct FriProofTarget { /// A Merkle root for each reduced polynomial in the commit phase. pub commit_phase_merkle_roots: Vec, /// Merkle proofs for the original purported codewords, i.e. the subject of the LDT. pub initial_merkle_proofs: Vec, /// Merkle proofs for the reduced polynomials that were sent in the commit phase. pub intermediate_merkle_proofs: Vec, /// The final polynomial in coefficient form. pub final_poly: Vec, } /// The purported values of each polynomial at a single point. pub struct OpeningSet { pub constants: Vec, pub plonk_sigmas: Vec, pub wires: Vec, pub plonk_zs: Vec, pub quotient_polys: Vec, } /// The purported values of each polynomial at a single point. pub struct OpeningSetTarget { pub constants: Vec, pub plonk_sigmas: Vec, pub wires: Vec, pub plonk_zs: Vec, pub quotient_polys: Vec, }