Try   HackMD

Synth-PoRep Spec

Notation & Constants

const NODE_SIZE=32 Bytes
Size in bytes of one node.

const SECTOR_SIZE{32GiB,64GiB}
The size in bytes of the sector being sealed.

const SECTOR_NODES=SECTOR_SIZE/NODE_SIZE
The size in 32-byte nodes of the sector being sealed.

type CommR:F=poseidon(CommCRootR)
A commitment to sealed data.
CommC
is the root of
TreeC
and
RootR
is the root of
TreeR
.

type ReplicaID:F
A unique identifier associated with a replica
R
of sector data
D
.


Challenge Counts:

const Nsyn=214=16,384
The number of synthetic challenges.

const N=176
The number of PoRep challenges.


Challenge Sets:

type Csyn:u32[Nsyn]=(cisyn)i[0,Nsyn)
The synthetic challenge set.

type C:u32[N]=(ci)i[0,N)
The PoRep challenge set.

Challenge Generation

SHA256

Function: gen_synth_challenges(ReplicaID)Csyn
for i:u32[0,Nsyn):

digest:u32[8]=sha256(le_bytes(ReplicaID)le_bytes(i))

bigint=u256::from_le_u32s(digest)

cisyn:u32=(bigint%(SECTOR_NODES1))+1


Function: gen_porep_challenges(ReplicaID,Csyn,rand:u8[32])C
for i:u32[0,N/8):

digest:u32[8]=sha256(le_bytes(ReplicaID)randle_bytes(i))

for j[0,8):

idx=digest[j]%Nsyn

c8i+j=cidxsyn


ChaCha20

const NONCE:u8[12]=0[12]
const EMPTY_BLOCK:u8[64]=0[64]

Function: gen_synth_challenges(ReplicaID)Csyn
key:u8[32]=le_bytes(ReplicaID)

stream=ChaCha20::new(key,NONCE)

for i[0,Nsyn/2):

block:u8[64]=stream.encrypt(EMPTY_BLOCK)

bigint1=u256::from_le_bytes(block[..32])

bigint2=u256::from_le_bytes(block[32..])

c2isyn:u32=(bigint1%(SECTOR_NODES1))+1

c2i+1syn:u32=(bigint2%(SECTOR_NODES1))+1


Function: gen_porep_challenges(ReplicaID,Csyn,rand:u8[32])C
key:u8[32]=sha256(le_bytes(ReplicaID)rand)

stream=ChaCha20::new(key,NONCE)

for i[0,N/16):

block:u8[64]=stream.encrypt(EMPTY_BLOCK)

for j[0,16):

idx=u32::from_le_bytes(block[4j..4j+4])%Nsyn

c16i+j=cidxsyn