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
26 changes: 18 additions & 8 deletions ecc/bls12-377/internal/fptower/e12.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bls12-377/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
result.FrobeniusSquare(&t[0]).
Mul(&result, &t[0])

var one GT
one.SetOne()
if result.Equal(&one) {
return result
}

// Hard part (up to permutation)
// Daiki Hayashida, Kenichiro Hayasaka and Tadanori Teruya
// https://eprint.iacr.org/2020/875.pdf
Expand Down
26 changes: 18 additions & 8 deletions ecc/bls12-378/internal/fptower/e12.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bls12-378/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
result.FrobeniusSquare(&t[0]).
Mul(&result, &t[0])

var one GT
one.SetOne()
if result.Equal(&one) {
return result
}

// Hard part (up to permutation)
// Daiki Hayashida, Kenichiro Hayasaka and Tadanori Teruya
// https://eprint.iacr.org/2020/875.pdf
Expand Down
26 changes: 18 additions & 8 deletions ecc/bls12-381/internal/fptower/e12.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ecc/bls12-381/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
result.FrobeniusSquare(&t[0]).
Mul(&result, &t[0])

var one GT
one.SetOne()
if result.Equal(&one) {
return result
}

// Hard part (up to permutation)
// Daiki Hayashida, Kenichiro Hayasaka and Tadanori Teruya
// https://eprint.iacr.org/2020/875.pdf
Expand Down
18 changes: 8 additions & 10 deletions ecc/bls24-315/internal/fptower/e24.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Code generated by consensys/gnark-crypto DO NOT EDIT

package fptower

import (
"errors"
"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark-crypto/ecc/bls24-315/fr"
"math/big"
"sync"

"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark-crypto/ecc/bls24-315/fr"
)

var bigIntPool = sync.Pool{
Expand Down Expand Up @@ -229,15 +228,16 @@ func (z *E24) DecompressKarabina(x *E24) *E24 {
var one E4
one.SetOne()

// g3 == 0
if x.D1.C0.IsZero() {
if x.D1.C0.IsZero() /* g3 == 0 */ {
t[0].Mul(&x.D0.C1, &x.D1.C2).
Double(&t[0])
// t1 = g2
t[1].Set(&x.D0.C2)

// g3 != 0
} else {
if t[1].IsZero() /* g2 == g3 == 0 */ {
return z.SetOne()
}
} else /* g3 != 0 */ {
// t0 = g1^2
t[0].Square(&x.D0.C1)
// t1 = 3 * g1^2 - 2 * g2
Expand Down Expand Up @@ -744,7 +744,6 @@ func (z *E24) Bytes() (r [SizeOfGT]byte) {

buf = z.D1.C2.B1.A1.Bytes()
copy(r[offset:offset+sizeOfFp], buf[:])
offset += sizeOfFp

return
}
Expand Down Expand Up @@ -803,7 +802,6 @@ func (z *E24) SetBytes(e []byte) error {
z.D1.C2.B1.A0.SetBytes(e[offset : offset+sizeOfFp])
offset += sizeOfFp
z.D1.C2.B1.A1.SetBytes(e[offset : offset+sizeOfFp])
offset += sizeOfFp

return nil
}
Expand Down
2 changes: 0 additions & 2 deletions ecc/bls24-315/internal/fptower/e24_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Code generated by consensys/gnark-crypto DO NOT EDIT

package fptower

import (
Expand Down
6 changes: 6 additions & 0 deletions ecc/bls24-315/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
result.FrobeniusQuad(&t[0]).
Mul(&result, &t[0])

var one GT
one.SetOne()
if result.Equal(&one) {
return result
}

// Hard part (up to permutation)
// Daiki Hayashida and Kenichiro Hayasaka
// and Tadanori Teruya
Expand Down
2 changes: 0 additions & 2 deletions ecc/bls24-317/internal/fptower/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Code generated by consensys/gnark-crypto DO NOT EDIT

package fptower

import "golang.org/x/sys/cpu"
Expand Down
2 changes: 0 additions & 2 deletions ecc/bls24-317/internal/fptower/asm_noadx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Code generated by consensys/gnark-crypto DO NOT EDIT

package fptower

// note: this is needed for test purposes, as dynamically changing supportAdx doesn't flag
Expand Down
Loading