Skip to content

Commit dae3911

Browse files
committed
MultiPodBuilder: keep public sts order
1 parent bf56c86 commit dae3911

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/frontend/multi_pod/mod.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ pub struct SolvedMultiPod {
192192
input_pods: Vec<MainPod>,
193193
statements: Vec<Statement>,
194194
operations: Vec<Operation>,
195+
output_public_indices: Vec<usize>,
195196
operations_wildcard_values: Vec<Vec<(usize, Value)>>,
196197
solution: MultiPodSolution,
197198
deps: DependencyGraph,
@@ -265,16 +266,12 @@ impl SolvedMultiPod {
265266
let mut added_statements_by_content: HashMap<Statement, Statement> = HashMap::new();
266267

267268
for &stmt_idx in &statements_sorted {
268-
let is_public = public_set.contains(&stmt_idx);
269269
let original_stmt = self.statements[stmt_idx].clone();
270270

271271
// If this statement content was already built in this POD, reuse it instead
272272
// of replaying the operation. If any duplicate is public, reveal the
273273
// already-built statement.
274-
if let Some(existing_stmt) = added_statements_by_content.get(&original_stmt) {
275-
if is_public {
276-
builder.reveal(existing_stmt);
277-
}
274+
if let Some(_existing_stmt) = added_statements_by_content.get(&original_stmt) {
278275
continue;
279276
}
280277

@@ -293,11 +290,28 @@ impl SolvedMultiPod {
293290
}
294291
}
295292

296-
let stmt = builder.op(is_public, wildcard_values, op)?;
293+
let stmt = builder.op(false, wildcard_values, op)?;
297294

298295
added_statements_by_content.insert(original_stmt, stmt);
299296
}
300297

298+
// For the output pod, make statements public in the original order
299+
if pod_idx == solution.pod_count - 1 {
300+
for idx in &self.output_public_indices {
301+
let stmt = added_statements_by_content
302+
.get(&self.statements[*idx])
303+
.expect("exists");
304+
builder.reveal(stmt);
305+
}
306+
} else {
307+
for idx in public_set {
308+
let stmt = added_statements_by_content
309+
.get(&self.statements[*idx])
310+
.expect("exists");
311+
builder.reveal(stmt);
312+
}
313+
}
314+
301315
// Step 4: Prove the POD
302316
let pod = builder.prove(prover)?;
303317

@@ -612,6 +626,7 @@ impl MultiPodBuilder {
612626
input_pods: self.input_pods,
613627
statements: self.statements,
614628
operations: self.operations,
629+
output_public_indices: self.output_public_indices,
615630
operations_wildcard_values: self.operations_wildcard_values,
616631
solution,
617632
deps,

0 commit comments

Comments
 (0)