Skip to content

use a hashmap to represent linear combination

STEVAN Antoine requested to merge hashmap-linear-combination into main

this MR removes the LinearCombinationElement and changes Shard.linear_combination to be a HashMap<u32, E::ScalarField> instead of a Vec<LinearCombinationElement<E>>.

  • the u32 key is the index of the shard used in the linear combination
  • the E::ScalarField value is the corresponding coefficient in the linear combination

the main goal is to remove duplicates on the shard indices, see this test where the shard 0 is twice 😮

i had to

  • implement CanonicalSerialize, CanonicalDeserialize and Valid for Shard according to the Arkworks documentation (scroll a bit to "implement these traits manually")
  • add a test for the serialization
  • fix all the usages in lib.rs and main.rs

in the end, it's not too bad, i wanted to have your input on this @j.detchart 😇

Edited by STEVAN Antoine

Merge request reports