mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-28 05:06:18 +08:00
sm9/bn256: gt use cyclo6 squaring
This commit is contained in:
parent
ce07f3afc0
commit
49513c7420
@ -5,7 +5,7 @@
|
|||||||
4.Wrap/Unwrap Key
|
4.Wrap/Unwrap Key
|
||||||
5.Encryption/Decryption
|
5.Encryption/Decryption
|
||||||
|
|
||||||
## SM9 current performance:
|
## SM9 current performance (for reference only):
|
||||||
|
|
||||||
**SM9 Sign/Verify/Enc/Dec Benchmark**
|
**SM9 Sign/Verify/Enc/Dec Benchmark**
|
||||||
|
|
||||||
@ -29,4 +29,3 @@
|
|||||||
BenchmarkGenerateSignPrivKey-8 18608 65422 ns/op 944 B/op 14 allocs/op
|
BenchmarkGenerateSignPrivKey-8 18608 65422 ns/op 944 B/op 14 allocs/op
|
||||||
BenchmarkGenerateEncryptPrivKey-8 8486 151201 ns/op 1072 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.
|
|
||||||
|
@ -227,7 +227,7 @@ func GenerateGTFieldTable(basePoint *GT) *[32 * 2]GTFieldTable {
|
|||||||
for j := 1; j < 15; j += 2 {
|
for j := 1; j < 15; j += 2 {
|
||||||
table[i][j] = >{}
|
table[i][j] = >{}
|
||||||
table[i][j].p = &gfP12{}
|
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] = >{}
|
table[i][j+1] = >{}
|
||||||
table[i][j+1].p = &gfP12{}
|
table[i][j+1].p = &gfP12{}
|
||||||
table[i][j+1].Add(table[i][j], base)
|
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 {
|
for i := 1; i < 15; i += 2 {
|
||||||
table[i] = >{}
|
table[i] = >{}
|
||||||
table[i].p = &gfP12{}
|
table[i].p = &gfP12{}
|
||||||
table[i].p.SquareNC(table[i/2].p)
|
table[i].p.Cyclo6SquareNC(table[i/2].p)
|
||||||
|
|
||||||
table[i+1] = >{}
|
table[i+1] = >{}
|
||||||
table[i+1].p = &gfP12{}
|
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
|
// No need to double on the first iteration, as p is the identity at
|
||||||
// this point, and [N]∞ = ∞.
|
// this point, and [N]∞ = ∞.
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
e.p.Squares(e.p, 4)
|
e.p.Cyclo6Squares(e.p, 4)
|
||||||
}
|
}
|
||||||
windowValue := byte >> 4
|
windowValue := byte >> 4
|
||||||
table.Select(t, windowValue)
|
table.Select(t, windowValue)
|
||||||
e.Add(e, t)
|
e.Add(e, t)
|
||||||
e.p.Squares(e.p, 4)
|
e.p.Cyclo6Squares(e.p, 4)
|
||||||
windowValue = byte & 0b1111
|
windowValue = byte & 0b1111
|
||||||
table.Select(t, windowValue)
|
table.Select(t, windowValue)
|
||||||
e.Add(e, t)
|
e.Add(e, t)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user