AdamISZ / aut-ct

Anonymous usage tokens from curve trees
18 stars 3 forks source link

const L (branching factor of Curve Tree) needs to be editable in config #5

Closed AdamISZ closed 6 months ago

AdamISZ commented 6 months ago

Currently since the template parameter L for the CurveTree constructor is defined as const usize, we cannot read it in at runtime. Need a solution for this, as optimal tree structure depends on keyset size.

AdamISZ commented 6 months ago

This does not seem to be a simple matter. The usage of the L, defined as const at compile time, is needed to create array variables like [P1::BaseField; L] in several places in curve_tree.rs. I believe the changes needed would therefore not be minor, and I'm having doubts whether we might introduce performance overhead if we make this value non-const.

AdamISZ commented 6 months ago

Addressed in adbc57383cfd31375ee23a2fafb114136ecd01c0 - multiple different branching factors now configurable in config, without recompilation.

This fix is by no means perfect; it needs one function call per branching factor available (which is fine if suboptimal, since the user is restricted to values the developer allows; suboptimal but not at all terrible, as there are very few values of branching_factor that make any sense in practice), but the only really bad thing rn is that it required expanding out macros from toy_rpc because the Struct being expanded is parameterized by a const generic, which those macros somehow (I don't understand the details) don't support. (The macros in question are export_impl and export_method). See the comments in lib.rs for more.