SMap.Aggregation
This module is used to handle proof aggregation in Plonk The format of keys for aggregation is <circuit~proof~key>
applies the input function on the last part of the input string (parts are delimited by sep). update_key_name f ("hello" ^ sep ^ "world" ^ sep ^ "!!")
returns "hello" ^ sep ^ "world" ^ sep ^ (f "!!")
add_prefix ~n ~i ~shift prefix str
return idx^prefix^sep^str idx = i
+ shift
as a string, eventually padded with '0' before to allow a numbering until n
with the same number of caracters for instance, prefix ~n:11 ~i:5 ~shift:1 "hello" "world"
will return "06~hello~world" n
is zero by default, this means if no n
is specified, no idx will be added no_sep
is false by default ; if set to true, the separator before the string to prefix will be ommitted : prefix ~no_sep:true ~n:11 ~i:5 ~shift:1 "hello" "world"
will return "06~helloworld"
build_all_names prefix n k
build the list of all prefixed k
with n proofs : build_all_names "hello" 11 "world"
will return "hello~00~world" ; "hello~01~world" ; … ; "hello~10~world"
adds prefix to each key of str_map ; i
will be added as a string before the prefix For instance prefix_map ~n:3000 ~i:5 ~shift:1 "hello" map
will prefix all the keys of map
with "0006~hello~"
val of_list : ?n:int -> ?shift:int -> string -> string -> 'a list -> 'a t
Aggregation.of_list ~n ~shift s name l
is the same as of_list @@ List.mapi (fun i x -> Aggregation.add_prefix ~n ~i ~shift s name, x) l
"c1" -> {"a" ; "b"} ; "c2" -> {"a" ; "c"}
becomes {"c1~a" ; "c1~b" ; "c2~a" ; "c2~c"}
with the same values
Converts a map of list of map in a map, by merging each list of map in one map, prefixing all keys with their proof index, and then merging all the new maps into one prefixing the keys with the outside map’s keys. shifts_maps map outside key to pairs of integers. 'key1' -> (7, 20) means that 20 proofs will be produced for key1 in total and we should start from the 8th one, assuming 7 of them were done independently. (Note that we may not even finish the whole 20, this depends on the map_list length). For example, on input:
'circuit_foo' -> [ {'a' -> fa0; 'b' -> fb0; 'c' -> fc0};
{'a' -> fa1; 'b' -> fb1; 'c' -> fc1} ];
'circuit_bar' -> [ {'a' -> ga0; 'b' -> gb0; 'c' -> gc0} ];
outputs
'circuit_foo~0~a' -> fa0
'circuit_foo~0~b' -> fb0
'circuit_foo~0~c' -> fc0
'circuit_foo~1~a' -> fa1
'circuit_foo~1~b' -> fb1
'circuit_foo~1~c' -> fc1
'circuit_bar~0~a' -> ga0
'circuit_bar~0~b' -> gb0
'circuit_bar~0~c' -> gc0
Filter a map keeping the elements whose key corresponds to the given circuit name
select_answers_by_circuit circuit_name s_map_map
takes a circuit_name
and a map with the structure:
'x' -> { 'circuit_foo~0~a' -> [scalar] ;
'circuit_foo~0~b' -> [scalar] ;
...
}
and filters the keys of the inner map, keeping the elements whose key corresponds to the given circuit name.