Skip to content

Commit

Permalink
Exponentiation using window=4.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Aug 26, 2020
1 parent 7cbff05 commit 4456729
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions internal/ted448/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,22 @@ func coremul(z64, x64, y64 *scalar64) {
func (z *Scalar) Inv(x *Scalar) {
var x64 scalar64
x64.fromScalar(x)

var T [16]scalar64
T[0] = scalar64{1}
for i := 1; i < 16; i++ {
coremul(&T[i], &T[i-1], &x64)
}

t := &scalar64{1}
for i := 8*len(orderMinusTwo) - 1; i >= 0; i-- {
for i := 8*len(orderMinusTwo) - 4; i >= 0; i -= 4 {
b := (orderMinusTwo[i/8] >> uint(i%8)) & 0xF
coremul(t, t, t)
coremul(t, t, t)
coremul(t, t, t)
coremul(t, t, t)
b := (orderMinusTwo[i/8] >> uint(i%8)) & 1
if b != 0 {
coremul(t, t, &x64)
coremul(t, t, &T[b])
}
}
t.modOrder()
Expand Down

0 comments on commit 4456729

Please sign in to comment.