Skip to content

Commit c795248

Browse files
committed
feat: niporep
1 parent ba920ec commit c795248

File tree

6 files changed

+80
-18
lines changed

6 files changed

+80
-18
lines changed

Diff for: cgo/const.go

+20-15
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,26 @@ const (
1616
)
1717

1818
const (
19-
RegisteredSealProofStackedDrg2KiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1
20-
RegisteredSealProofStackedDrg8MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1
21-
RegisteredSealProofStackedDrg512MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1
22-
RegisteredSealProofStackedDrg32GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1
23-
RegisteredSealProofStackedDrg64GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1
24-
RegisteredSealProofStackedDrg2KiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1
25-
RegisteredSealProofStackedDrg8MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1
26-
RegisteredSealProofStackedDrg512MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1
27-
RegisteredSealProofStackedDrg32GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1
28-
RegisteredSealProofStackedDrg64GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1
29-
RegisteredSealProofStackedDrg2KiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1__FEAT__SYNTHETIC_PO_REP
30-
RegisteredSealProofStackedDrg8MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP
31-
RegisteredSealProofStackedDrg512MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP
32-
RegisteredSealProofStackedDrg32GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP
33-
RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP
19+
RegisteredSealProofStackedDrg2KiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1
20+
RegisteredSealProofStackedDrg8MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1
21+
RegisteredSealProofStackedDrg512MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1
22+
RegisteredSealProofStackedDrg32GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1
23+
RegisteredSealProofStackedDrg64GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1
24+
RegisteredSealProofStackedDrg2KiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1
25+
RegisteredSealProofStackedDrg8MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1
26+
RegisteredSealProofStackedDrg512MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1
27+
RegisteredSealProofStackedDrg32GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1
28+
RegisteredSealProofStackedDrg64GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1
29+
RegisteredSealProofStackedDrg2KiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1__FEAT__SYNTHETIC_PO_REP
30+
RegisteredSealProofStackedDrg8MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP
31+
RegisteredSealProofStackedDrg512MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP
32+
RegisteredSealProofStackedDrg32GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP
33+
RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP
34+
RegisteredSealProofStackedDrg2KiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
35+
RegisteredSealProofStackedDrg8MiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
36+
RegisteredSealProofStackedDrg512MiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
37+
RegisteredSealProofStackedDrg32GiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
38+
RegisteredSealProofStackedDrg64GiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
3439
)
3540

3641
const (

Diff for: cgo/proofs.go

+9
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ func SealCommitPhase2(sealCommitPhase1Output SliceRefUint8, sectorId uint64, pro
130130
return resp.value.copy(), nil
131131
}
132132

133+
func SealCommitPhase2CircuitProofs(sealCommitPhase1Output SliceRefUint8, sectorId uint64) ([]byte, error) {
134+
resp := C.seal_commit_phase2_circuit_proofs(sealCommitPhase1Output, C.uint64_t(sectorId))
135+
defer resp.destroy()
136+
if err := CheckErr(resp); err != nil {
137+
return nil, err
138+
}
139+
return resp.value.copy(), nil
140+
}
141+
133142
func AggregateSealProofs(registeredProof RegisteredSealProof, registeredAggregation RegisteredAggregationProof, commRs SliceRefByteArray32, seeds SliceRefByteArray32, sealCommitResponses SliceRefSliceBoxedUint8) ([]byte, error) {
134143
resp := C.aggregate_seal_proofs(registeredProof, registeredAggregation, commRs, seeds, sealCommitResponses)
135144
defer resp.destroy()

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/filecoin-project/go-address v1.1.0
77
github.com/filecoin-project/go-fil-commcid v0.1.0
8-
github.com/filecoin-project/go-state-types v0.13.1
8+
github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240611104512-19a29aa50e4a
99
github.com/ipfs/go-block-format v0.0.3
1010
github.com/ipfs/go-cid v0.3.2
1111
github.com/ipfs/go-ipfs-blockstore v1.2.0

Diff for: go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/filecoin-project/go-crypto v0.0.1 h1:AcvpSGGCgjaY8y1az6AMfKQWreF/pWO2
99
github.com/filecoin-project/go-crypto v0.0.1/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ=
1010
github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88OqLYEo6roi+GiIeOh8=
1111
github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ=
12-
github.com/filecoin-project/go-state-types v0.13.1 h1:4CivvlcHAIoAtFFVVlZtokynaMQu5XLXGoTKhQkfG1I=
13-
github.com/filecoin-project/go-state-types v0.13.1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
12+
github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240611104512-19a29aa50e4a h1:nMdbQ57jTYdJpygzRd/rfKt+unyUAmzK9DLgbOuUMwE=
13+
github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240611104512-19a29aa50e4a/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
1414
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
1515
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
1616
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=

Diff for: proofs.go

+18
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,13 @@ func SealCommitPhase2(
414414
return cgo.SealCommitPhase2(cgo.AsSliceRefUint8(phase1Output), uint64(sectorNum), &proverID)
415415
}
416416

417+
// SealCommitPhase2CircuitProofs runs a non-interactive proof and returns the circuit proof bytes
418+
// rather than the aggregated proof bytes. This is used to aggregate multiple non-interactive
419+
// proofs as the aggregated single proof outputs can't further be aggregated.
420+
func SealCommitPhase2CircuitProofs(phase1Output []byte, sectorNum abi.SectorNumber) ([]byte, error) {
421+
return cgo.SealCommitPhase2CircuitProofs(cgo.AsSliceRefUint8(phase1Output), uint64(sectorNum))
422+
}
423+
417424
// TODO AggregateSealProofs it only needs InteractiveRandomness out of the aggregateInfo.Infos
418425
func AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) (out []byte, err error) {
419426
sp, err := toFilRegisteredSealProof(aggregateInfo.SealProof)
@@ -1030,6 +1037,17 @@ func toFilRegisteredSealProof(p abi.RegisteredSealProof) (cgo.RegisteredSealProo
10301037
case abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep:
10311038
return cgo.RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep, nil
10321039

1040+
case abi.RegisteredSealProof_StackedDrg2KiBV1_2_Feat_NiPoRep:
1041+
return cgo.RegisteredSealProofStackedDrg2KiBV1_2_Feat_NonInteractivePoRep, nil
1042+
case abi.RegisteredSealProof_StackedDrg8MiBV1_2_Feat_NiPoRep:
1043+
return cgo.RegisteredSealProofStackedDrg8MiBV1_2_Feat_NonInteractivePoRep, nil
1044+
case abi.RegisteredSealProof_StackedDrg512MiBV1_2_Feat_NiPoRep:
1045+
return cgo.RegisteredSealProofStackedDrg512MiBV1_2_Feat_NonInteractivePoRep, nil
1046+
case abi.RegisteredSealProof_StackedDrg32GiBV1_2_Feat_NiPoRep:
1047+
return cgo.RegisteredSealProofStackedDrg32GiBV1_2_Feat_NonInteractivePoRep, nil
1048+
case abi.RegisteredSealProof_StackedDrg64GiBV1_2_Feat_NiPoRep:
1049+
return cgo.RegisteredSealProofStackedDrg64GiBV1_2_Feat_NonInteractivePoRep, nil
1050+
10331051
default:
10341052
return 0, errors.Errorf("no mapping to C.FFIRegisteredSealProof value available for: %v", p)
10351053
}

Diff for: rust/src/proofs/api.rs

+30
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,36 @@ fn seal_commit_phase2(
294294
})
295295
}
296296

297+
/// This function generates a variant of the circuit proof for the second phase of the sealing
298+
/// process. It takes as input the output from the first phase of the sealing process
299+
/// [`seal_commit_phase1`] and a sector ID.
300+
///
301+
/// This variant of `seal_commit_phase2` is intended specifically for returning the circuit proofs
302+
/// of a NonInteractivePoRep proof, such that it can later be aggregated with other
303+
/// NonInteractivePoRep proofs.
304+
///
305+
/// # Arguments
306+
///
307+
/// * `seal_commit_phase1_output` - A reference to a slice of bytes representing the output from the
308+
/// first phase of the sealing process.
309+
/// * `sector_id` - A 64-bit integer representing the sector ID.
310+
///
311+
/// # Returns
312+
/// This function returns a `SealCommitPhase2Response` wrapped in a `repr_c::Box`. This response
313+
/// includes the proof generated in this phase of the sealing process.
314+
#[ffi_export]
315+
fn seal_commit_phase2_circuit_proofs(
316+
seal_commit_phase1_output: c_slice::Ref<u8>,
317+
sector_id: u64,
318+
) -> repr_c::Box<SealCommitPhase2Response> {
319+
catch_panic_response("seal_commit_phase2_circuit_proofs", || {
320+
let scp1o = serde_json::from_slice(&seal_commit_phase1_output)?;
321+
let result = seal::seal_commit_phase2_circuit_proofs(scp1o, SectorId::from(sector_id))?;
322+
323+
Ok(result.proof.into_boxed_slice().into())
324+
})
325+
}
326+
297327
/// TODO: document
298328
#[ffi_export]
299329
fn generate_synth_proofs(

0 commit comments

Comments
 (0)