|
|
@@ -324,13 +324,24 @@ impl<'a> CodeGen<'a> {
|
|
|
}
|
|
|
AExprType::Point { is_vec: false, .. } => {
|
|
|
if allocated_vars.insert(id.clone()) {
|
|
|
+ // sigma-proofs reserves element indices for the
|
|
|
+ // identity and the canonical group generator.
|
|
|
+ // Reuse them whenever a declared point has one of
|
|
|
+ // those values; otherwise keep the point as an
|
|
|
+ // ordinary instance element.
|
|
|
element_allocs = quote! {
|
|
|
#element_allocs
|
|
|
- let #id = #lr_var.allocate_element();
|
|
|
- };
|
|
|
- element_assigns = quote! {
|
|
|
- #element_assigns
|
|
|
- #lr_var.set_element(#id, #instance_var.#id);
|
|
|
+ let #id = if #instance_var.#id
|
|
|
+ == <Point as group::Group>::identity()
|
|
|
+ {
|
|
|
+ #lr_var.identity()
|
|
|
+ } else if #instance_var.#id
|
|
|
+ == <Point as group::Group>::generator()
|
|
|
+ {
|
|
|
+ #lr_var.generator()
|
|
|
+ } else {
|
|
|
+ #lr_var.allocate_element_with(#instance_var.#id)
|
|
|
+ };
|
|
|
};
|
|
|
}
|
|
|
Ok(quote! {#id})
|