filecoin-project / ec-gpu

OpenCL code generator for finite-field arithmetic over arbitrary prime fields
Other
91 stars 61 forks source link

feat: re-organize ec-gpu traits #30

Closed vmx closed 2 years ago

vmx commented 2 years ago

The ec-gpu traits are re-organized.

BREAKING CHANGE: The GpuEngine trait is removed, as it was specific to pairing friendlt elliptic curves.

The GpuField trait gains a new method called sub_field_name, which only matters for extension fields. It has a default implementation, so existing implementations don't need to change.

A new trait called GpuName is introduced, which every GpuField needs to implement. It contains the name of the object it's implemented for, which is then used in the generated source code as identifier.

vmx commented 2 years ago

@dignifiedquire I'd like to get a review from you as you did the original work on this crate.

@DrPeterVanNostrand I'd like especially a review of the comments.

For both of you: the implementation of the traits for blstrs can be found here: https://github.com/filecoin-project/blstrs/pull/43, the pasta_curves one is at https://github.com/zcash/pasta_curves/pull/45.

vmx commented 2 years ago

I've pushed a new version, which I think is the best of the suggestions from @str4d and my idea. I found the macro a bit too magical. I prefer the code being more explicit and easy to grep. I updated the documentation, so that people know that they should use the ec_gpu::name() macro. @str4d what do you think?

vmx commented 2 years ago

I've squashed it into a single commit with an updated commit message.

@dignifiedquire it would be great if you could also review this code, as you are the maintainer of blstrs.

@DrPeterVanNostrand if you could have a look if I got the comments right, it would be great.

@str4d thanks once again for the thorough review, I'm really happy with the outcome.