Skip to content

Commit

Permalink
Poseidon version of SnapDeals (#1547)
Browse files Browse the repository at this point in the history
* feat: adds EmptySectorUpdate-Poseidon circuit and paramcache-id

Co-authored-by: DrPeterVanNostrand <jnz@riseup.net>
  • Loading branch information
Jakub Sztandera and DrPeterVanNostrand committed Jan 28, 2022
1 parent c836cab commit b72bc95
Show file tree
Hide file tree
Showing 13 changed files with 1,306 additions and 162 deletions.
22 changes: 22 additions & 0 deletions storage-proofs-update/src/challenges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ impl Challenges {
challenges_remaining: challenge_count,
}
}

pub fn new_poseidon(sector_nodes: usize, comm_r_new: TreeRDomain) -> Self {
let repeats = partition_count(sector_nodes);

let challenge_bit_len = sector_nodes.trailing_zeros() as usize;
let random_bits_per_challenge = challenge_bit_len;
let challenges_per_digest = Fr::CAPACITY as usize / random_bits_per_challenge;

let challenge_count = challenge_count(sector_nodes) * repeats;
let digest_index_all_partitions = 0;

Challenges {
comm_r_new,
partition_bits: 0,
random_bits_per_challenge,
challenges_per_digest,
digest_index_all_partitions,
i: 0,
digest_bits: Vec::with_capacity(Fr::NUM_BITS as usize),
challenges_remaining: challenge_count,
}
}
}

impl Iterator for Challenges {
Expand Down
6 changes: 6 additions & 0 deletions storage-proofs-update/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ where
TreeR: MerkleTreeTrait<Hasher = TreeRHasher>,
{
pub fn blank(pub_params: PublicParams) -> Self {
let sector_bytes = (pub_params.sector_nodes as u64) << 5;
assert_eq!(
PublicParams::from_sector_size(sector_bytes),
pub_params,
"invalid public-params for sector-size",
);
let pub_inputs = PublicInputs::empty();
let priv_inputs = PrivateInputs::<TreeR>::empty(pub_params.sector_nodes);
EmptySectorUpdateCircuit {
Expand Down
6 changes: 6 additions & 0 deletions storage-proofs-update/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ pub const fn challenge_count(sector_nodes: usize) -> usize {
}
}

// Number of challenges per EmtpySectorUpdate-Poseidon partition proof; note
// EmptySectorUpdate-Poseidon proofs are single partition.
pub const fn challenge_count_poseidon(sector_nodes: usize) -> usize {
challenge_count(sector_nodes) * partition_count(sector_nodes)
}

// Returns the `h` values allowed for the given sector-size. Each `h` value is a possible number of
// high bits taken from each challenge `c`. A single value of `h = hs[i]` is taken from `hs` for
// each proof; the circuit takes `h_select = 2^i` as a public input.
Expand Down
1 change: 1 addition & 0 deletions storage-proofs-update/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod circuit;
pub mod compound;
pub mod constants;
pub(crate) mod gadgets;
pub mod poseidon;
pub mod vanilla;

mod challenges;
Expand Down
Loading

0 comments on commit b72bc95

Please sign in to comment.