@@ -914,6 +914,71 @@ fn seal_commit_phase2_inner<Tree: 'static + MerkleTreeTrait>(
914
914
} )
915
915
}
916
916
917
+ /// Generates zk-SNARK proof for sector replica. Must be called with output of [`seal_commit_phase1`].
918
+ ///
919
+ /// This variant of `seal_commit_phase2` is intended specifically for
920
+ /// returning the circuit proofs of a NonInteractivePoRep proof, such
921
+ /// that it can later be aggregated with other NonInteractivePoRep
922
+ /// proofs. Using it outside of this context may cause errors.
923
+ ///
924
+ /// # Arguments
925
+ ///
926
+ /// * `phase1_output` - Struct returned from [`seal_commit_phase1`] containing Merkle tree proof.
927
+ /// * `prover_id` - Unique ID of the storage provider.
928
+ /// * `sector_id` - ID of the sector, usually relative to the miner.
929
+ ///
930
+ /// Returns [`SealCommitPhase2Output`] struct containing vector of zk-SNARK proofs.
931
+ pub fn seal_commit_phase2_circuit_proofs (
932
+ phase1_output : SealCommitPhase1Output ,
933
+ sector_id : SectorId ,
934
+ ) -> Result < SealCommitPhase2Output > {
935
+ ensure ! (
936
+ phase1_output. registered_proof. major_version( ) == 1 ,
937
+ "unusupported version"
938
+ ) ;
939
+
940
+ with_shape ! (
941
+ u64 :: from( phase1_output. registered_proof. sector_size( ) ) ,
942
+ seal_commit_phase2_circuit_proofs_inner,
943
+ phase1_output,
944
+ sector_id,
945
+ )
946
+ }
947
+
948
+ fn seal_commit_phase2_circuit_proofs_inner < Tree : ' static + MerkleTreeTrait > (
949
+ phase1_output : SealCommitPhase1Output ,
950
+ sector_id : SectorId ,
951
+ ) -> Result < SealCommitPhase2Output > {
952
+ let SealCommitPhase1Output {
953
+ vanilla_proofs,
954
+ comm_r,
955
+ comm_d,
956
+ replica_id,
957
+ seed,
958
+ ticket,
959
+ registered_proof,
960
+ } = phase1_output;
961
+
962
+ let config = registered_proof. as_v1_config ( ) ;
963
+ let replica_id: Fr = replica_id. into ( ) ;
964
+
965
+ let co = filecoin_proofs_v1:: types:: SealCommitPhase1Output {
966
+ vanilla_proofs : vanilla_proofs. try_into ( ) ?,
967
+ comm_r,
968
+ comm_d,
969
+ replica_id : replica_id. into ( ) ,
970
+ seed,
971
+ ticket,
972
+ } ;
973
+
974
+ let output =
975
+ filecoin_proofs_v1:: seal_commit_phase2_circuit_proofs :: < Tree > ( & config, co, sector_id) ?;
976
+
977
+ Ok ( SealCommitPhase2Output {
978
+ proof : output. proof ,
979
+ } )
980
+ }
981
+
917
982
/// Given the specified arguments, this method returns the inputs that were used to
918
983
/// generate the seal proof. This can be useful for proof aggregation, as verification
919
984
/// requires these inputs.
0 commit comments