HorizenOfficial/zendoo-cctp-lib

Improve load_g_{1,2}_committer_key() and get_g_{1,2}_committer_key() logic

Closed this issue · 0 comments

Currently the behaviour of these two functions is as follows:

  • load_g_{1,2}_committer_key() can be called multiple times and it will always re-generate the keys and replace them with the (if) already existing ones;
  • get_g_{1,2}_committer_key() can do nothing more than retrieving the already initialized keys.

This behaviour is quite limited as:

  • It might often happen (and it's the case for our cctp) that there are multiple circuits of different size, for which the segment size used to generate the keys the first time might be too small or too big;
  • If someone needs a different segment size, it's allowed to re-generate and replace the previous existing dlog keys, and we want to avoid this as it might easily introduce bugs and unnecessary overheads.

Thus, I propose to change the logic of these two functions in the following way:

  • load_g_{1,2}_committer_key(): drop the supported_degree argument, we will always generate maximum sized keys; furthermore, once generated, they cannot be changed anymore: any further attempt to call these functions should result in an error;
  • get_g_{1,2}_committer_key(): we let these functions accept, as (optional) input, the segment size. If specified, and smaller than the size of the generated dlog keys, these will simply be trimmed to the input segment size and returned to the caller.