pub fn verify_window_post<Tree: 'static + MerkleTreeTrait>(
    post_config: &PoStConfig,
    randomness: &ChallengeSeed,
    replicas: &BTreeMap<SectorId, PublicReplicaInfo>,
    prover_id: ProverId,
    proof: &[u8],
) -> Result<bool> {
    info!("verify_window_post:start");

    ensure!(
        post_config.typ == PoStType::Window,
        "invalid post config type"
    );

    let randomness_safe = as_safe_commitment(randomness, "randomness")?;
    let prover_id_safe = as_safe_commitment(&prover_id, "prover_id")?;

    let vanilla_params = window_post_setup_params(&post_config);
    let partitions = get_partitions_for_window_post(replicas.len(), &post_config);

    let setup_params = compound_proof::SetupParams {
        vanilla_params,
        partitions,
        priority: false,
    };
    let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
        fallback::FallbackPoStCompound::setup(&setup_params)?;

    let pub_sectors: Vec<_> = replicas
        .iter()
        .map(|(sector_id, replica)| {
            let comm_r = replica.safe_comm_r().with_context(|| {
                format!("verify_window_post: safe_comm_r failed: {:?}", sector_id)
            })?;
            Ok(fallback::PublicSector {
                id: *sector_id,
                comm_r,
            })
        })
        .collect::<Result<_>>()?;

    let pub_inputs = fallback::PublicInputs {
        randomness: randomness_safe,
        prover_id: prover_id_safe,
        sectors: &pub_sectors,
        k: None,
    };

    let is_valid = {
        let verifying_key = get_post_verifying_key::<Tree>(&post_config)?;
        let multi_proof = MultiProof::new_from_reader(partitions, &proof[..], &verifying_key)?;

        fallback::FallbackPoStCompound::verify(
            &pub_params,
            &pub_inputs,
            &multi_proof,
            &fallback::ChallengeRequirements {
                minimum_challenge_count: post_config.challenge_count * post_config.sector_count,
            },
        )?
    };
    if !is_valid {
        return Ok(false);
    }

    info!("verify_window_post:finish");

    Ok(true)
}
/// Verifies a window proof-of-spacetime.
Verifies a window proof-of-spacetime.
Verifies a window proof - of - spacetime .
pub fn verify_window_post<Tree: 'static + MerkleTreeTrait>(
    post_config: &PoStConfig,
    randomness: &ChallengeSeed,
    replicas: &BTreeMap<SectorId, PublicReplicaInfo>,
    prover_id: ProverId,
    proof: &[u8],
) -> Result<bool> {
    info!("verify_window_post:start");
    ensure!(
        post_config.typ == PoStType::Window,
        "invalid post config type"
    );
    let randomness_safe = as_safe_commitment(randomness, "randomness")?;
    let prover_id_safe = as_safe_commitment(&prover_id, "prover_id")?;
    let vanilla_params = window_post_setup_params(&post_config);
    let partitions = get_partitions_for_window_post(replicas.len(), &post_config);
    let setup_params = compound_proof::SetupParams {
        vanilla_params,
        partitions,
        priority: false,
    };
    let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
        fallback::FallbackPoStCompound::setup(&setup_params)?;
    let pub_sectors: Vec<_> = replicas
        .iter()
        .map(|(sector_id, replica)| {
            let comm_r = replica.safe_comm_r().with_context(|| {
                format!("verify_window_post: safe_comm_r failed: {:?}", sector_id)
            })?;
            Ok(fallback::PublicSector {
                id: *sector_id,
                comm_r,
            })
        })
        .collect::<Result<_>>()?;
    let pub_inputs = fallback::PublicInputs {
        randomness: randomness_safe,
        prover_id: prover_id_safe,
        sectors: &pub_sectors,
        k: None,
    };
    let is_valid = {
        let verifying_key = get_post_verifying_key::<Tree>(&post_config)?;
        let multi_proof = MultiProof::new_from_reader(partitions, &proof[..], &verifying_key)?;
        fallback::FallbackPoStCompound::verify(
            &pub_params,
            &pub_inputs,
            &multi_proof,
            &fallback::ChallengeRequirements {
                minimum_challenge_count: post_config.challenge_count * post_config.sector_count,
            },
        )?
    };
    if !is_valid {
        return Ok(false);
    }
    info!("verify_window_post:finish");
    Ok(true)
}
pub fn verify_window_post < Tree : ' static + MerkleTreeTrait > ( post_config : & PoStConfig , randomness : & ChallengeSeed , replicas : & BTreeMap < SectorId , PublicReplicaInfo > , prover_id : ProverId , proof : & [ u8 ] , ) -> Result < bool > { info ! ( " " ) ; ensure ! ( post_config typ PoStType Window " " ) ; let randomness_safe = as_safe_commitment ( randomness , " " ) ? ; let prover_id_safe = as_safe_commitment ( & prover_id , " " ) ? ; let vanilla_params = window_post_setup_params ( & post_config ) ; let partitions = get_partitions_for_window_post ( replicas . len ( ) , & post_config ) ; let setup_params = compound_proof :: SetupParams { vanilla_params , partitions , priority : false , } ; let pub_params : compound_proof :: PublicParams < fallback :: FallbackPoSt < Tree > > = fallback :: FallbackPoStCompound :: setup ( & setup_params ) ? ; let pub_sectors : Vec < _ > = replicas . iter ( ) . map ( | ( sector_id , replica ) | { let comm_r = replica . safe_comm_r ( ) . with_context ( | | { format ! ( " " sector_id ) } ) ? ; Ok ( fallback :: PublicSector { id : * sector_id , comm_r , } ) } ) . collect :: < Result < _ > > ( ) ? ; let pub_inputs = fallback :: PublicInputs { randomness : randomness_safe , prover_id : prover_id_safe , sectors : & pub_sectors , k : None , } ; let is_valid = { let verifying_key = get_post_verifying_key :: < Tree > ( & post_config ) ? ; let multi_proof = MultiProof :: new_from_reader ( partitions , & proof [ .. ] , & verifying_key ) ? ; fallback :: FallbackPoStCompound :: verify ( & pub_params , & pub_inputs , & multi_proof , & fallback :: ChallengeRequirements { minimum_challenge_count : post_config . challenge_count * post_config . sector_count , } , ) ? } ; if ! is_valid { return Ok ( false ) ; } info ! ( " " ) ; Ok ( true ) }
Verifies a window proof-of-spacetime.
Verifies a window proof - of - spacetime .
post_config
&PoStConfig
randomness
&ChallengeSeed
replicas
&BTreeMap<SectorId, PublicReplicaInfo>
prover_id
ProverId
proof
&[u8]
post_config
&PoStConfig
randomness
&ChallengeSeed
replicas
&BTreeMap<SectorId, PublicReplicaInfo>
prover_id
ProverId
proof
&[u8]