@@ -958,36 +958,6 @@ namespace fc::proofs {
958
958
return res_ptr->is_valid ;
959
959
}
960
960
961
- outcome::result<Bytes> ProofEngineImpl::generateUpdateProof (
962
- RegisteredUpdateProof proof_type,
963
- const CID &old_sealed_cid,
964
- const CID &new_sealed_cid,
965
- const CID &unsealed_cid,
966
- const std::string &new_replica_path,
967
- const std::string &new_replica_cache_path,
968
- const std::string §or_key_path,
969
- const std::string §or_key_cache_path) {
970
- OUTCOME_TRY (ffi_update_proof_type, cRegisteredUpdateProof (proof_type));
971
- OUTCOME_TRY (comm_r_old, CIDToReplicaCommitmentV1 (old_sealed_cid));
972
- OUTCOME_TRY (comm_r_new, CIDToReplicaCommitmentV1 (new_sealed_cid));
973
- OUTCOME_TRY (comm_d, CIDToDataCommitmentV1 (unsealed_cid));
974
- const auto res_ptr{ffi::wrap (
975
- fil_generate_empty_sector_update_proof (ffi_update_proof_type,
976
- c32ByteArray (comm_r_old),
977
- c32ByteArray (comm_r_new),
978
- c32ByteArray (comm_d),
979
- sector_key_path.c_str (),
980
- sector_key_cache_path.c_str (),
981
- new_replica_path.c_str (),
982
- new_replica_cache_path.c_str ()),
983
- fil_destroy_empty_sector_update_generate_proof_response)};
984
- PROOFS_TRY (" generateUpdateProof" );
985
-
986
- const auto proof =
987
- gsl::span (res_ptr->proof_ptr , gsl::narrow<int64_t >(res_ptr->proof_len ));
988
- return Bytes (proof.begin (), proof.end ());
989
- }
990
-
991
961
outcome::result<bool > ProofEngineImpl::verifyUpdateProof (
992
962
const ReplicaUpdateInfo &info) {
993
963
OUTCOME_TRY (ffi_update_proof_type,
@@ -1133,4 +1103,117 @@ namespace fc::proofs {
1133
1103
1134
1104
ProofEngineImpl::ProofEngineImpl ()
1135
1105
: logger_{common::createLogger (" proofs" )} {}
1106
+
1107
+ outcome::result<SealedAndUnsealedCID> ProofEngineImpl::updateSeal (
1108
+ RegisteredUpdateProof type,
1109
+ const std::string &path_update,
1110
+ const std::string &path_update_cache,
1111
+ const std::string &path_sealed,
1112
+ const std::string &path_cache,
1113
+ const std::string &path_unsealed,
1114
+ gsl::span<const PieceInfo> pieces) {
1115
+ OUTCOME_TRY (c_type, cRegisteredUpdateProof (type));
1116
+ OUTCOME_TRY (c_pieces, cPublicPieceInfos (pieces));
1117
+ const auto res_ptr{
1118
+ ffi::wrap (fil_empty_sector_update_encode_into (c_type,
1119
+ path_update.c_str (),
1120
+ path_update_cache.c_str (),
1121
+ path_sealed.c_str (),
1122
+ path_cache.c_str (),
1123
+ path_unsealed.c_str (),
1124
+ c_pieces.data (),
1125
+ c_pieces.size ()),
1126
+ fil_destroy_empty_sector_update_encode_into_response)};
1127
+ PROOFS_TRY (" updateSeal" );
1128
+ SealedAndUnsealedCID result;
1129
+ OUTCOME_TRYA (result.sealed_cid ,
1130
+ replicaCommitmentV1ToCID (res_ptr->comm_r_new ));
1131
+ OUTCOME_TRYA (result.unsealed_cid ,
1132
+ dataCommitmentV1ToCID (res_ptr->comm_d_new ));
1133
+ return result;
1134
+ }
1135
+
1136
+ outcome::result<void > ProofEngineImpl::updateUnseal (
1137
+ RegisteredUpdateProof type,
1138
+ const std::string &path_unsealed,
1139
+ const std::string &path_update,
1140
+ const std::string &path_sealed,
1141
+ const std::string &path_cache,
1142
+ const CID &cid_unsealed) {
1143
+ OUTCOME_TRY (c_type, cRegisteredUpdateProof (type));
1144
+ OUTCOME_TRY (c_unsealed, CIDToDataCommitmentV1 (cid_unsealed));
1145
+ const auto res_ptr{
1146
+ ffi::wrap (fil_empty_sector_update_decode_from (c_type,
1147
+ path_unsealed.c_str (),
1148
+ path_update.c_str (),
1149
+ path_sealed.c_str (),
1150
+ path_cache.c_str (),
1151
+ c32ByteArray (c_unsealed)),
1152
+ fil_destroy_empty_sector_update_decode_from_response)};
1153
+ PROOFS_TRY (" updateUnseal" );
1154
+ return outcome::success ();
1155
+ }
1156
+
1157
+ outcome::result<UpdateProofs1> ProofEngineImpl::updateProve1 (
1158
+ RegisteredUpdateProof type,
1159
+ const CID &cid_sealed_old,
1160
+ const CID &cid_sealed,
1161
+ const CID &cid_unsealed,
1162
+ const std::string &path_update,
1163
+ const std::string &path_update_cache,
1164
+ const std::string &path_sealed,
1165
+ const std::string &path_cache) {
1166
+ OUTCOME_TRY (c_type, cRegisteredUpdateProof (type));
1167
+ OUTCOME_TRY (c_sealed_old, CIDToReplicaCommitmentV1 (cid_sealed_old));
1168
+ OUTCOME_TRY (c_sealed, CIDToReplicaCommitmentV1 (cid_sealed));
1169
+ OUTCOME_TRY (c_unsealed, CIDToDataCommitmentV1 (cid_unsealed));
1170
+ const auto res_ptr{ffi::wrap (
1171
+ fil_generate_empty_sector_update_partition_proofs (
1172
+ c_type,
1173
+ c32ByteArray (c_sealed_old),
1174
+ c32ByteArray (c_sealed),
1175
+ c32ByteArray (c_unsealed),
1176
+ path_sealed.c_str (),
1177
+ path_cache.c_str (),
1178
+ path_update.c_str (),
1179
+ path_update_cache.c_str ()),
1180
+ fil_destroy_generate_empty_sector_update_partition_proof_response)};
1181
+ PROOFS_TRY (" updateProve1" );
1182
+ const auto c_proofs{
1183
+ gsl::make_span (res_ptr->proofs_ptr , res_ptr->proofs_len )};
1184
+ UpdateProofs1 result;
1185
+ result.reserve (c_proofs.size ());
1186
+ for (const auto &c_proof : c_proofs) {
1187
+ result.push_back (copy (BytesIn (c_proof.proof_ptr , c_proof.proof_len )));
1188
+ }
1189
+ return result;
1190
+ }
1191
+
1192
+ outcome::result<Bytes> ProofEngineImpl::updateProve2 (
1193
+ RegisteredUpdateProof type,
1194
+ const CID &cid_sealed_old,
1195
+ const CID &cid_sealed,
1196
+ const CID &cid_unsealed,
1197
+ UpdateProofs1 proofs1) {
1198
+ OUTCOME_TRY (c_type, cRegisteredUpdateProof (type));
1199
+ OUTCOME_TRY (c_sealed_old, CIDToReplicaCommitmentV1 (cid_sealed_old));
1200
+ OUTCOME_TRY (c_sealed, CIDToReplicaCommitmentV1 (cid_sealed));
1201
+ OUTCOME_TRY (c_unsealed, CIDToDataCommitmentV1 (cid_unsealed));
1202
+ std::vector<fil_PartitionProof> c_proofs;
1203
+ c_proofs.reserve (proofs1.size ());
1204
+ for (const auto &proof : proofs1) {
1205
+ c_proofs.push_back ({proof.size (), proof.data ()});
1206
+ }
1207
+ const auto res_ptr{
1208
+ ffi::wrap (fil_generate_empty_sector_update_proof_with_vanilla (
1209
+ c_type,
1210
+ c_proofs.data (),
1211
+ c_proofs.size (),
1212
+ c32ByteArray (c_sealed_old),
1213
+ c32ByteArray (c_sealed),
1214
+ c32ByteArray (c_unsealed)),
1215
+ fil_destroy_empty_sector_update_generate_proof_response)};
1216
+ PROOFS_TRY (" updateProve2" );
1217
+ return copy (BytesIn (res_ptr->proof_ptr , res_ptr->proof_len ));
1218
+ }
1136
1219
} // namespace fc::proofs
0 commit comments