Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions ecc/bls24-317/internal/fptower/e24_pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ func (z *E24) nSquareCompressed(n int) {
}
}

// Expt set z to x^t in E24 and return z (t is the seed of the curve)
// t = 3640754176
func (z *E24) Expt(x *E24) *E24 {
// ExptHalf set z to x^(t/2) in E24 and return z (t is the seed of the curve)
// t/2 = 1820377088
func (z *E24) ExptHalf(x *E24) *E24 {
// Expt computation is derived from the addition chain:
//
// _10 = 2*1
Expand All @@ -23,9 +23,9 @@ func (z *E24) Expt(x *E24) *E24 {
// _11000000 = _11000 << 3
// _11011000 = _11000 + _11000000
// _11011001 = 1 + _11011000
// return (_11011001 << 9 + _11) << 15
// return (_11011001 << 9 + _11) << 14
//
// Operations: 31 squares 4 multiplies
// Operations: 30 squares 4 multiplies
//
// Generated by github.com/mmcloughlin/addchain v0.4.0.

Expand Down Expand Up @@ -60,14 +60,22 @@ func (z *E24) Expt(x *E24) *E24 {
result.Mul(&result, &t0)

// Step 35: result = x^0xd9018000
result.nSquareCompressed(15)
result.nSquareCompressed(14)
result.DecompressKarabina(&result)

z.Set(&result)

return z
}

// Expt set z to x^t in E24 and return z (t is the seed of the curve)
// t = 3640754176
func (z *E24) Expt(x *E24) *E24 {
var result E24
result.ExptHalf(x)
return z.CyclotomicSquare(&result)
}

// MulBy014 multiplication by sparse element (c0, c1, 0, 0, c4, 0)
func (z *E24) MulBy014(c0, c1, c4 *E4) *E24 {

Expand Down
14 changes: 9 additions & 5 deletions ecc/bls24-317/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
// https://eprint.iacr.org/2020/875.pdf
// 3(p⁸ - p⁴ +1)/r = (x₀-1)² * (x₀+p) * (x₀²+p²) * (x₀⁴+p⁴-1) + 3
t[0].CyclotomicSquare(&result)
t[1].Expt(&result)
t[1].ExptHalf(&t[0])
t[2].InverseUnitary(&result)
t[1].Mul(&t[1], &t[2])
t[2].Expt(&t[1])
Expand All @@ -98,10 +98,14 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
t[2].Expt(&t[0])
t[0].FrobeniusSquare(&t[1])
t[2].Mul(&t[0], &t[2])
t[1].Expt(&t[2])
t[1].Expt(&t[1])
t[1].Expt(&t[1])
t[1].Expt(&t[1])
t[1].ExptHalf(&t[2])
t[1].ExptHalf(&t[1])
t[1].ExptHalf(&t[1])
t[1].ExptHalf(&t[1])
for s := 0; s < 4; s++ {
t[1].CyclotomicSquareCompressed(&t[1])
}
t[1].DecompressKarabina(&t[1])
t[0].FrobeniusQuad(&t[2])
t[0].Mul(&t[0], &t[1])
t[2].InverseUnitary(&t[2])
Expand Down