paulmillr / noble-curves

Audited & minimal JS implementation of elliptic curve cryptography.
https://paulmillr.com/noble
MIT License
691 stars 63 forks source link

Signature export #7

Closed dhruvkelawala closed 1 year ago

dhruvkelawala commented 1 year ago

https://github.com/paulmillr/noble-curves/blob/65d7256b9e8ecffdf57bfe61b65158a21ac348c9/src/abstract/weierstrass.ts#L767

Why are we exporting Signature of type SignatureConstructor and not Signature class?

https://github.com/paulmillr/noble-curves/blob/65d7256b9e8ecffdf57bfe61b65158a21ac348c9/src/abstract/weierstrass.ts#L928

This breaks the type inference (when being explicit) using sign method in stark.ts because it returns SignatureType which needs to be imported from weierstrass.ts. I think Signature Class should be exported from weierstrass.ts instead of SignatureConstructor

paulmillr commented 1 year ago

Class can't be exported. It's dynamically generated.

dhruvkelawala commented 1 year ago

But is it possible to export a better typing than SignatureConstructor?

paulmillr commented 1 year ago

Can you provide a code that shows how is it broken?

paulmillr commented 1 year ago
shot

Seems fine to me.

dhruvkelawala commented 1 year ago
Screenshot 2023-01-02 at 19 29 55

This is the issue when trying to be explicit about Signature return type