Skip to content

Conversation

@dfaranha
Copy link
Contributor

@dfaranha dfaranha commented Jun 4, 2025

What the title says. :) This version passes all tests and is approximately 2x faster in the benchmarks.
A shorter but slightly slower alternative can be found below. This is joint work with @aniagut.

// ProdPair calculates the product of pairings, i.e., \Prod_i pair(ni*Pi,Qi).
func ProdPair(P []*G1, Q []*G2, n []*Scalar) *Gt {
        if len(P) != len(Q) || len(P) != len(n) {
                panic("mismatch length of inputs")
        }

        mi := new(ff.Fp12)
        out := new(ff.Fp12)
        out.SetOne()

        affineP := affinize(P)
        for i := range affineP {
                affineP[i].ScalarMult(n[i], &affineP[i]);
                affineP[i].toAffine();
                miller(mi, &affineP[i], Q[i])
                out.Mul(out, mi)
        }

        e := &Gt{}
        finalExp(e, out)
        return e
}

@bwesterb bwesterb requested a review from armfazh June 4, 2025 15:44
@armfazh armfazh self-assigned this Jun 4, 2025
@armfazh armfazh merged commit acaa79c into cloudflare:main Jun 4, 2025
11 checks passed
@armfazh
Copy link
Contributor

armfazh commented Jun 4, 2025

Thanks @aniagut and @dfaranha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants