github.com/cloudflare/circl@v1.5.0/abe/cpabe/tkn20/internal/tkn/pairAccum.go (about) 1 package tkn 2 3 import ( 4 "fmt" 5 6 pairing "github.com/cloudflare/circl/ecc/bls12381" 7 ) 8 9 type pairAccum struct { 10 as []*pairing.G1 11 bs []*pairing.G2 12 scalars []int 13 } 14 15 func (pairs *pairAccum) addDuals(m1 *matrixG1, m2 *matrixG2, n int) { 16 if m1.cols != 1 || m2.cols != 1 { 17 panic(fmt.Sprintf("misuse of addDuals: m1: %d x %d m2: %d x %d\n", m1.rows, m1.cols, m2.rows, m2.cols)) 18 } 19 for k := 0; k < m1.rows; k++ { 20 pairs.as = append(pairs.as, &m1.entries[k]) 21 pairs.bs = append(pairs.bs, &m2.entries[k]) 22 pairs.scalars = append(pairs.scalars, n) 23 } 24 } 25 26 func (pairs *pairAccum) eval() *pairing.Gt { 27 return pairing.ProdPairFrac(pairs.as, pairs.bs, pairs.scalars) 28 }