pub fn generate_fallback_sector_challenges<Tree: 'static + MerkleTreeTrait>(
    post_config: &PoStConfig,
    randomness: &ChallengeSeed,
    pub_sectors: &[SectorId],
    _prover_id: ProverId,
) -> Result<BTreeMap<SectorId, Vec<u64>>> {
    info!("generate_sector_challenges:start");
    ensure!(
        post_config.typ == PoStType::Window || post_config.typ == PoStType::Winning,
        "invalid post config type"
    );

    let randomness_safe: <Tree::Hasher as Hasher>::Domain =
        as_safe_commitment(randomness, "randomness")?;

    let public_params = fallback::PublicParams {
        sector_size: u64::from(post_config.sector_size),
        challenge_count: post_config.challenge_count,
        sector_count: post_config.sector_count,
    };

    let mut sector_challenges: BTreeMap<SectorId, Vec<u64>> = BTreeMap::new();

    let num_sectors_per_chunk = post_config.sector_count;
    let partitions = match post_config.typ {
        PoStType::Window => match get_partitions_for_window_post(pub_sectors.len(), &post_config) {
            Some(x) => x,
            None => 1,
        },
        PoStType::Winning => 1,
    };

    for partition_index in 0..partitions {
        let sectors = pub_sectors
            .chunks(num_sectors_per_chunk)
            .nth(partition_index)
            .ok_or_else(|| anyhow!("invalid number of sectors/partition index"))?;

        for (i, sector) in sectors.iter().enumerate() {
            let mut challenges = Vec::new();

            for n in 0..post_config.challenge_count {
                let challenge_index = ((partition_index * post_config.sector_count + i)
                    * post_config.challenge_count
                    + n) as u64;
                let challenged_leaf = fallback::generate_leaf_challenge(
                    &public_params,
                    randomness_safe,
                    u64::from(*sector),
                    challenge_index,
                );
                challenges.push(challenged_leaf);
            }

            sector_challenges.insert(*sector, challenges);
        }
    }

    info!("generate_sector_challenges:finish");

    Ok(sector_challenges)
}
/// Generates the challenges per SectorId required for either a Window
/// proof-of-spacetime or a Winning proof-of-spacetime.
Generates the challenges per SectorId required for either a Window
proof-of-spacetime or a Winning proof-of-spacetime.
Generates the challenges per SectorId required for either a Window proof - of - spacetime or a Winning proof - of - spacetime .
pub fn generate_fallback_sector_challenges<Tree: 'static + MerkleTreeTrait>(
    post_config: &PoStConfig,
    randomness: &ChallengeSeed,
    pub_sectors: &[SectorId],
    _prover_id: ProverId,
) -> Result<BTreeMap<SectorId, Vec<u64>>> {
    info!("generate_sector_challenges:start");
    ensure!(
        post_config.typ == PoStType::Window || post_config.typ == PoStType::Winning,
        "invalid post config type"
    );
    let randomness_safe: <Tree::Hasher as Hasher>::Domain =
        as_safe_commitment(randomness, "randomness")?;
    let public_params = fallback::PublicParams {
        sector_size: u64::from(post_config.sector_size),
        challenge_count: post_config.challenge_count,
        sector_count: post_config.sector_count,
    };
    let mut sector_challenges: BTreeMap<SectorId, Vec<u64>> = BTreeMap::new();
    let num_sectors_per_chunk = post_config.sector_count;
    let partitions = match post_config.typ {
        PoStType::Window => match get_partitions_for_window_post(pub_sectors.len(), &post_config) {
            Some(x) => x,
            None => 1,
        },
        PoStType::Winning => 1,
    };
    for partition_index in 0..partitions {
        let sectors = pub_sectors
            .chunks(num_sectors_per_chunk)
            .nth(partition_index)
            .ok_or_else(|| anyhow!("invalid number of sectors/partition index"))?;
        for (i, sector) in sectors.iter().enumerate() {
            let mut challenges = Vec::new();
            for n in 0..post_config.challenge_count {
                let challenge_index = ((partition_index * post_config.sector_count + i)
                    * post_config.challenge_count
                    + n) as u64;
                let challenged_leaf = fallback::generate_leaf_challenge(
                    &public_params,
                    randomness_safe,
                    u64::from(*sector),
                    challenge_index,
                );
                challenges.push(challenged_leaf);
            }
            sector_challenges.insert(*sector, challenges);
        }
    }
    info!("generate_sector_challenges:finish");
    Ok(sector_challenges)
}
pub fn generate_fallback_sector_challenges < Tree : ' static + MerkleTreeTrait > ( post_config : & PoStConfig , randomness : & ChallengeSeed , pub_sectors : & [ SectorId ] , _prover_id : ProverId , ) -> Result < BTreeMap < SectorId , Vec < u64 > > > { info ! ( " " ) ; ensure ! ( post_config typ PoStType Window post_config typ PoStType Winning " " ) ; let randomness_safe : < Tree :: Hasher as Hasher > :: Domain = as_safe_commitment ( randomness , " " ) ? ; let public_params = fallback :: PublicParams { sector_size : u64 :: from ( post_config . sector_size ) , challenge_count : post_config . challenge_count , sector_count : post_config . sector_count , } ; let mut sector_challenges : BTreeMap < SectorId , Vec < u64 > > = BTreeMap :: new ( ) ; let num_sectors_per_chunk = post_config . sector_count ; let partitions = match post_config . typ { PoStType :: Window => match get_partitions_for_window_post ( pub_sectors . len ( ) , & post_config ) { Some ( x ) => x , None => 1 , } , PoStType :: Winning => 1 , } ; for partition_index in 0 .. partitions { let sectors = pub_sectors . chunks ( num_sectors_per_chunk ) . nth ( partition_index ) . ok_or_else ( | | anyhow ! ( " " ) ) ? ; for ( i , sector ) in sectors . iter ( ) . enumerate ( ) { let mut challenges = Vec :: new ( ) ; for n in 0 .. post_config . challenge_count { let challenge_index = ( ( partition_index * post_config . sector_count + i ) * post_config . challenge_count + n ) as u64 ; let challenged_leaf = fallback :: generate_leaf_challenge ( & public_params , randomness_safe , u64 :: from ( * sector ) , challenge_index , ) ; challenges . push ( challenged_leaf ) ; } sector_challenges . insert ( * sector , challenges ) ; } } info ! ( " " ) ; Ok ( sector_challenges ) }
Generates the challenges per SectorId required for either a Window
proof-of-spacetime or a Winning proof-of-spacetime.
Generates the challenges per SectorId required for either a Window proof - of - spacetime or a Winning proof - of - spacetime .
post_config
&PoStConfig
randomness
&ChallengeSeed
pub_sectors
&[SectorId]
_prover_id
ProverId
post_config
&PoStConfig
randomness
&ChallengeSeed
pub_sectors
&[SectorId]
_prover_id
ProverId