LLFourn / secp256kfun

A pure-rust secp256k1 library optimised for fun
BSD Zero Clause License
102 stars 29 forks source link

Use procedural macro for `g!` and `s!` macros #170

Closed LLFourn closed 9 months ago

LLFourn commented 1 year ago

This gives us much more expressivity in the macros:

  1. No more {..} when you need to call methods or access tuple or array elements.
  2. New .* dot product operator which replaces manually called op::lincomb.
  3. New scalar division operator / (mostly for fun -- it's used in one place in ecdsa_fun).

RIP macro_rules stack machine.

In order to design the thing correctly I also tried to make everything copy (#146) to maintain backwards compat with omitting &. In the end I didn't really use that but instead just allowed you to pass a reference to most of the functions in op which also fixes #125.

This is probably a breaking change due to some slight changes in the way some parts of the expressions are interpreted.

I've done benchmarks to confirm that there's no performance regression in terms of what is produced.

Fixes #146 #125 #6

nickfarrow commented 1 year ago

Changes look great to me, looked at FROST changes specifically and skimmed most of the other code (though i'm lacking skills to to review the macros themselves yet)