-
-
Save obscuren/808a3da5350d91a097602a567dbab3da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exp sets z = x**y mod |fm| | |
func (z *Fq) Exp(x, y *Fq) *Fq { | |
load(z) | |
if y.abs.Cmp(bigZero) == 0 { | |
return z.SetInt64(0) | |
} else if y.abs.Cmp(bigOne) == 0 { | |
return z | |
} else if new(big.Int).Mod(y.abs, big.NewInt(2)).Cmp(bigZero) == 0 { | |
t := new(Fq).Div(y, NewField(2)) | |
z.Mul(x, x).Exp(z, t) | |
} else { | |
z.Mul(x, x) | |
t := new(Fq).Div(y, NewField(2)) | |
z.Exp(z, t) | |
z.Mul(z, x) | |
} | |
return z | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment