sm9/bn256: gt use cyclo6 squaring

This commit is contained in:
Sun Yimin 2023-07-25 16:49:44 +08:00 committed by GitHub
parent ce07f3afc0
commit 49513c7420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -5,7 +5,7 @@
4.Wrap/Unwrap Key
5.Encryption/Decryption
## SM9 current performance:
## SM9 current performance (for reference only):
**SM9 Sign/Verify/Enc/Dec Benchmark**
@ -29,4 +29,3 @@
BenchmarkGenerateSignPrivKey-8 18608 65422 ns/op 944 B/op 14 allocs/op
BenchmarkGenerateEncryptPrivKey-8 8486 151201 ns/op 1072 B/op 14 allocs/op
To further improve `Verify()/Decrypt()` performance, need to improve `Pair()` method performance.

View File

@ -227,7 +227,7 @@ func GenerateGTFieldTable(basePoint *GT) *[32 * 2]GTFieldTable {
for j := 1; j < 15; j += 2 {
table[i][j] = &GT{}
table[i][j].p = &gfP12{}
table[i][j].p.SquareNC(table[i][j/2].p)
table[i][j].p.Cyclo6SquareNC(table[i][j/2].p)
table[i][j+1] = &GT{}
table[i][j+1].p = &gfP12{}
table[i][j+1].Add(table[i][j], base)
@ -274,7 +274,7 @@ func ScalarMultGT(a *GT, scalar []byte) (*GT, error) {
for i := 1; i < 15; i += 2 {
table[i] = &GT{}
table[i].p = &gfP12{}
table[i].p.SquareNC(table[i/2].p)
table[i].p.Cyclo6SquareNC(table[i/2].p)
table[i+1] = &GT{}
table[i+1].p = &gfP12{}
@ -289,12 +289,12 @@ func ScalarMultGT(a *GT, scalar []byte) (*GT, error) {
// No need to double on the first iteration, as p is the identity at
// this point, and [N]∞ = ∞.
if i != 0 {
e.p.Squares(e.p, 4)
e.p.Cyclo6Squares(e.p, 4)
}
windowValue := byte >> 4
table.Select(t, windowValue)
e.Add(e, t)
e.p.Squares(e.p, 4)
e.p.Cyclo6Squares(e.p, 4)
windowValue = byte & 0b1111
table.Select(t, windowValue)
e.Add(e, t)