mod coinbase_solution;
pub use coinbase_solution::*;
mod epoch_challenge;
pub use epoch_challenge::*;
mod partial_solution;
pub use partial_solution::*;
mod prover_solution;
pub use prover_solution::*;
mod puzzle_commitment;
pub use puzzle_commitment::*;
use crate::{hash_commitment, hash_commitments, CoinbasePuzzle};
use console::{account::Address, prelude::*, types::Field};
use snarkvm_algorithms::{
fft::{domain::FFTPrecomputation, DensePolynomial, EvaluationDomain},
polycommit::kzg10::{KZGCommitment, KZGProof, LagrangeBasis, VerifierKey, KZG10},
};
use snarkvm_curves::PairingEngine;
use snarkvm_utilities::{FromBytes, ToBytes};
use anyhow::Result;
use std::{
borrow::Cow,
io::{Read, Result as IoResult, Write},
};
pub type PuzzleProof<N> = KZGProof<<N as Environment>::PairingCurve>;
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct PuzzleConfig {
pub degree: u32,
}
pub type CoinbaseVerifyingKey<N> = VerifierKey<<N as Environment>::PairingCurve>;
#[derive(Clone, Debug)]
pub struct CoinbaseProvingKey<N: Network> {
pub lagrange_basis_at_beta_g: Vec<<N::PairingCurve as PairingEngine>::G1Affine>,
pub product_domain: EvaluationDomain<<N::PairingCurve as PairingEngine>::Fr>,
pub fft_precomputation: FFTPrecomputation<<N::PairingCurve as PairingEngine>::Fr>,
pub product_domain_elements: Vec<<N::PairingCurve as PairingEngine>::Fr>,
pub verifying_key: CoinbaseVerifyingKey<N>,
}
impl<N: Network> CoinbaseProvingKey<N> {
pub fn lagrange_basis(&self) -> LagrangeBasis<N::PairingCurve> {
LagrangeBasis {
lagrange_basis_at_beta_g: Cow::Borrowed(self.lagrange_basis_at_beta_g.as_slice()),
powers_of_beta_times_gamma_g: Cow::Owned(vec![]),
domain: self.product_domain,
}
}
pub fn product_domain_elements(&self) -> &[<N::PairingCurve as PairingEngine>::Fr] {
&self.product_domain_elements
}
}