supranational / blst

Multilingual BLS12-381 signature library
Apache License 2.0
478 stars 180 forks source link

feat(bindings/rust): add constructor for affine points #208

Closed jacobkaufmann closed 6 months ago

jacobkaufmann commented 8 months ago

in the rust bindings, add a constructor for affine points (i.e. p1_affines and p2_affines) whose argument is a slice of affine points.

dot-asm commented 6 months ago

The trouble is that the data will be duplicated, which is likely undesirable. Because customarily you'd work with a larger number of points. One would rather want to borrow it. In other words the question is if it's possible to arrange it so that it's borrowed, or rather cow-ed...

jacobkaufmann commented 6 months ago

I agree that it would be better to avoid the allocation, but I would rather not alter the internal representation of the affine points to keep the change simple. the From performs an allocation, and that is the only way to construct e.g. p1_affines, so I assumed that the allocation would not be a blocker.

dot-asm commented 6 months ago

the From performs an allocation

It has to because it goes into a type with distinctly different memory layout, and it's computationally intensive in comparison to allocation, so it's justified. Affine to affine would be a pure waste. As for internal representation, it's not public, so it's not impossible to change it...

dot-asm commented 6 months ago

Have a look at #219.

dot-asm commented 6 months ago

219 is merged.