paulmillr / noble-curves

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

H2CPoint to ProjectivePoint #131

Closed CluEleSsUK closed 3 months ago

CluEleSsUK commented 3 months ago

I was wondering if there's a convenient way to turn an H2CPoint into a ProjectivePoint for pairing?

The following works but requires a transition to affine in between:

    const Qid = PointG1.ProjectivePoint.fromAffine(PointG1.hashToCurve(ID, {DST: dst}).toAffine())
    const m = PointG2.ProjectivePoint.fromHex(master)
    const Gid = bls12_381.pairing(Qid, m)
paulmillr commented 3 months ago

H2CPoint is just an interface to which projectivepoint conforms. there is no separate H2CPoint class. so what you’re doing in this code is converting projective point to projective point.

paulmillr commented 3 months ago

If a simple solution doesn’t work, perhaps there is a type error somewhere. You can use “as unknown as any” as workaround and see if that works (if using typescript)