remove lazy computation of QPlus1Div4 and do at init time.

Should shut up the race detector (thought this should be harmless)
This commit is contained in:
Owain G. Ainsworth 2013-11-21 18:59:15 +00:00
parent a97fd5fe2c
commit 95b3c063e3

View file

@ -235,9 +235,6 @@ func (curve *KoblitzCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int) {
// QPlus1Div4 returns the Q+1/4 constant for the curve for use in calculating // QPlus1Div4 returns the Q+1/4 constant for the curve for use in calculating
// square roots via exponention. // square roots via exponention.
func (curve *KoblitzCurve) QPlus1Div4() *big.Int { func (curve *KoblitzCurve) QPlus1Div4() *big.Int {
if curve.q == nil {
curve.q = new(big.Int).Div(new(big.Int).Add(secp256k1.P, big.NewInt(1)), big.NewInt(4))
}
return curve.q return curve.q
} }
@ -258,6 +255,8 @@ func initS256() {
secp256k1.Gx, _ = new(big.Int).SetString("79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", 16) secp256k1.Gx, _ = new(big.Int).SetString("79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", 16)
secp256k1.Gy, _ = new(big.Int).SetString("483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8", 16) secp256k1.Gy, _ = new(big.Int).SetString("483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8", 16)
secp256k1.BitSize = 256 secp256k1.BitSize = 256
secp256k1.q = new(big.Int).Div(new(big.Int).Add(secp256k1.P,
big.NewInt(1)), big.NewInt(4))
} }
// S256 returns a Curve which implements secp256k1. // S256 returns a Curve which implements secp256k1.