Sfoglia il codice sorgente

Have collect_cind_points output the point names in sorted order

That way we choose deterministic ones for any generated Pedersen
commitments
Ian Goldberg 1 mese fa
parent
commit
617dd52355

+ 4 - 2
sigma-compiler-core/src/syntax.rs

@@ -197,7 +197,7 @@ pub fn taggedvardict_to_vardict(vd: &TaggedVarDict) -> VarDict {
 /// Collect the list of [`Point`](TaggedIdent::Point)s tagged `cind`
 /// Collect the list of [`Point`](TaggedIdent::Point)s tagged `cind`
 /// from the given [`TaggedVarDict`]
 /// from the given [`TaggedVarDict`]
 pub fn collect_cind_points(vars: &TaggedVarDict) -> Vec<Ident> {
 pub fn collect_cind_points(vars: &TaggedVarDict) -> Vec<Ident> {
-    vars.values()
+    let mut cind_points: Vec<Ident> = vars.values()
         .filter_map(|ti| {
         .filter_map(|ti| {
             if let TaggedIdent::Point(TaggedPoint {
             if let TaggedIdent::Point(TaggedPoint {
                 is_cind: true,
                 is_cind: true,
@@ -211,7 +211,9 @@ pub fn collect_cind_points(vars: &TaggedVarDict) -> Vec<Ident> {
                 None
                 None
             }
             }
         })
         })
-        .collect()
+        .collect();
+    cind_points.sort();
+    cind_points
 }
 }
 
 
 #[cfg(test)]
 #[cfg(test)]

+ 0 - 7
sigma-compiler-core/src/transform.rs

@@ -140,14 +140,7 @@ pub fn enforce_disjunction_invariant(
     // must be at least two of them in order to create Pedersen
     // must be at least two of them in order to create Pedersen
     // commitments.
     // commitments.
 
 
-    // If we're testing, sort cind_points so that we get a deterministic
-    // choice of cind_A and cind_B
-    #[cfg(not(test))]
     let cind_points = collect_cind_points(vars);
     let cind_points = collect_cind_points(vars);
-    #[cfg(test)]
-    let mut cind_points = collect_cind_points(vars);
-    #[cfg(test)]
-    cind_points.sort_unstable();
 
 
     // Extra statements to be added to the root disjunction branch
     // Extra statements to be added to the root disjunction branch
     let mut root_extra_statements: Vec<StatementTree> = Vec::new();
     let mut root_extra_statements: Vec<StatementTree> = Vec::new();