Unverified Commit ae93a37a authored by Erin Swenson-Healey's avatar Erin Swenson-Healey Committed by GitHub
Browse files

feat(challenges): configurable challenge count (#54)

parent 24aaedac
...@@ -232,6 +232,7 @@ func VerifyPoSt( ...@@ -232,6 +232,7 @@ func VerifyPoSt(
sectorSize uint64, sectorSize uint64,
sectorInfo SortedSectorInfo, sectorInfo SortedSectorInfo,
challengeSeed [32]byte, challengeSeed [32]byte,
challengeCount uint64,
proof []byte, proof []byte,
winners []Candidate, winners []Candidate,
proverID [32]byte, proverID [32]byte,
...@@ -277,6 +278,7 @@ func VerifyPoSt( ...@@ -277,6 +278,7 @@ func VerifyPoSt(
resPtr := C.sector_builder_ffi_reexported_verify_post( resPtr := C.sector_builder_ffi_reexported_verify_post(
C.uint64_t(sectorSize), C.uint64_t(sectorSize),
(*[CommitmentBytesLen]C.uint8_t)(challengeSeedCBytes), (*[CommitmentBytesLen]C.uint8_t)(challengeSeedCBytes),
C.uint64_t(challengeCount),
sectorIdsPtr, sectorIdsPtr,
sectorIdsSize, sectorIdsSize,
(*C.uint8_t)(flattenedCommRsCBytes), (*C.uint8_t)(flattenedCommRsCBytes),
...@@ -668,6 +670,7 @@ func GenerateCandidates( ...@@ -668,6 +670,7 @@ func GenerateCandidates(
sectorBuilderPtr unsafe.Pointer, sectorBuilderPtr unsafe.Pointer,
sectorInfo SortedSectorInfo, sectorInfo SortedSectorInfo,
challengeSeed [CommitmentBytesLen]byte, challengeSeed [CommitmentBytesLen]byte,
challengeCount uint64,
faults []uint64, faults []uint64,
) ([]Candidate, error) { ) ([]Candidate, error) {
defer elapsed("GenerateCandidates")() defer elapsed("GenerateCandidates")()
...@@ -700,6 +703,7 @@ func GenerateCandidates( ...@@ -700,6 +703,7 @@ func GenerateCandidates(
(*C.uint8_t)(cflattened), (*C.uint8_t)(cflattened),
C.size_t(len(flattened)), C.size_t(len(flattened)),
(*[CommitmentBytesLen]C.uint8_t)(challengeSeedPtr), (*[CommitmentBytesLen]C.uint8_t)(challengeSeedPtr),
C.uint64_t(challengeCount),
faultsPtr, faultsPtr,
faultsSize, faultsSize,
) )
...@@ -717,6 +721,7 @@ func GeneratePoSt( ...@@ -717,6 +721,7 @@ func GeneratePoSt(
sectorBuilderPtr unsafe.Pointer, sectorBuilderPtr unsafe.Pointer,
sectorInfo SortedSectorInfo, sectorInfo SortedSectorInfo,
challengeSeed [CommitmentBytesLen]byte, challengeSeed [CommitmentBytesLen]byte,
challengeCount uint64,
winners []Candidate, winners []Candidate,
) ([]byte, error) { ) ([]byte, error) {
defer elapsed("GeneratePoSt")() defer elapsed("GeneratePoSt")()
...@@ -749,6 +754,7 @@ func GeneratePoSt( ...@@ -749,6 +754,7 @@ func GeneratePoSt(
(*C.uint8_t)(cflattened), (*C.uint8_t)(cflattened),
C.size_t(len(flattened)), C.size_t(len(flattened)),
(*[CommitmentBytesLen]C.uint8_t)(challengeSeedPtr), (*[CommitmentBytesLen]C.uint8_t)(challengeSeedPtr),
C.uint64_t(challengeCount),
winnersPtr, winnersPtr,
winnersSize, winnersSize,
) )
......
...@@ -178,15 +178,15 @@ func TestSectorBuilderLifecycle(t *testing.T) { ...@@ -178,15 +178,15 @@ func TestSectorBuilderLifecycle(t *testing.T) {
CommR: statusA.CommR, CommR: statusA.CommR,
}) })
candidates, err := sb.GenerateCandidates(ptr, sectorInfo, [32]byte{}, []uint64{}) candidates, err := sb.GenerateCandidates(ptr, sectorInfo, [32]byte{}, 2, []uint64{})
require.NoError(t, err) require.NoError(t, err)
// generate a PoSt // generate a PoSt
proofs, err := sb.GeneratePoSt(ptr, sectorInfo, [32]byte{}, candidates) proofs, err := sb.GeneratePoSt(ptr, sectorInfo, [32]byte{}, 2, candidates)
require.NoError(t, err) require.NoError(t, err)
// verify the PoSt // verify the PoSt
isValid, err = sb.VerifyPoSt(1024, sectorInfo, [32]byte{}, proofs, candidates, proverID) isValid, err = sb.VerifyPoSt(1024, sectorInfo, [32]byte{}, 2, proofs, candidates, proverID)
require.NoError(t, err) require.NoError(t, err)
require.True(t, isValid) require.True(t, isValid)
......
Subproject commit 9a0fe0dee0f1e56ab853c331ffa6a3017dbf2acd Subproject commit 89f194c6ea5e745dd36ed30d67e3685ceb3c65aa
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment