supranational / blst

Multilingual BLS12-381 signature library
Apache License 2.0
454 stars 171 forks source link

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

Closed jacobkaufmann closed 1 month ago

jacobkaufmann commented 4 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 2 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 2 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 2 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 1 month ago

Have a look at #219.

dot-asm commented 1 month ago

219 is merged.