Trait snarkvm_dpc::traits::posw::PoSWScheme
source · [−]pub trait PoSWScheme<N: Network>: Clone + Send + Sync {
fn setup<R: Rng + CryptoRng>(
srs: &mut SRS<'_, R, <<N as Network>::PoSWSNARK as SNARK>::UniversalSetupParameters>
) -> Result<Self, PoSWError>;
fn load(is_prover: bool) -> Result<Self, PoSWError>;
fn proving_key(&self) -> &Option<<N::PoSWSNARK as SNARK>::ProvingKey>;
fn verifying_key(&self) -> &<N::PoSWSNARK as SNARK>::VerifyingKey;
fn mine<R: Rng + CryptoRng>(
&self,
block_template: &BlockTemplate<N>,
terminator: &AtomicBool,
rng: &mut R
) -> Result<BlockHeader<N>, PoSWError>;
fn prove_once_unchecked<R: Rng + CryptoRng>(
&self,
circuit: &mut PoSWCircuit<N>,
block_template: &BlockTemplate<N>,
terminator: &AtomicBool,
rng: &mut R
) -> Result<PoSWProof<N>, PoSWError>;
fn verify_from_block_header(&self, block_header: &BlockHeader<N>) -> bool;
fn verify(
&self,
block_height: u32,
difficulty_target: u64,
inputs: &[N::InnerScalarField],
proof: &PoSWProof<N>
) -> bool;
}
Required methods
Sets up an instance of PoSW using an SRS.
Loads an instance of PoSW using stored parameters.
fn proving_key(&self) -> &Option<<N::PoSWSNARK as SNARK>::ProvingKey>
fn proving_key(&self) -> &Option<<N::PoSWSNARK as SNARK>::ProvingKey>
Returns a reference to the PoSW circuit proving key.
fn verifying_key(&self) -> &<N::PoSWSNARK as SNARK>::VerifyingKey
fn verifying_key(&self) -> &<N::PoSWSNARK as SNARK>::VerifyingKey
Returns a reference to the PoSW circuit verifying key.
fn mine<R: Rng + CryptoRng>(
&self,
block_template: &BlockTemplate<N>,
terminator: &AtomicBool,
rng: &mut R
) -> Result<BlockHeader<N>, PoSWError>
fn mine<R: Rng + CryptoRng>(
&self,
block_template: &BlockTemplate<N>,
terminator: &AtomicBool,
rng: &mut R
) -> Result<BlockHeader<N>, PoSWError>
Given the block template, compute a PoSW proof and nonce such that they are under the difficulty target.
fn prove_once_unchecked<R: Rng + CryptoRng>(
&self,
circuit: &mut PoSWCircuit<N>,
block_template: &BlockTemplate<N>,
terminator: &AtomicBool,
rng: &mut R
) -> Result<PoSWProof<N>, PoSWError>
fn prove_once_unchecked<R: Rng + CryptoRng>(
&self,
circuit: &mut PoSWCircuit<N>,
block_template: &BlockTemplate<N>,
terminator: &AtomicBool,
rng: &mut R
) -> Result<PoSWProof<N>, PoSWError>
Given the block template, compute a PoSW proof. WARNING - This method does not ensure the resulting proof satisfies the difficulty target.
fn verify_from_block_header(&self, block_header: &BlockHeader<N>) -> bool
fn verify_from_block_header(&self, block_header: &BlockHeader<N>) -> bool
Verifies the Proof of Succinct Work against the nonce, root, and difficulty target.