From 2340ad388c7179de515dec1c58ce9c92f0825f91 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 14 May 2019 22:47:03 -0700 Subject: [PATCH] btcec/btcec: deprecate QPlus1Div4() in favor of Q() The previous naming suggested that the value ((P+1)/4+1)/4 was being returned, when in fact the returned value is simply (P+1)/4. The old method is superseded by Q(). --- btcec/btcec.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/btcec/btcec.go b/btcec/btcec.go index 2cb1d929..de93a255 100644 --- a/btcec/btcec.go +++ b/btcec/btcec.go @@ -886,12 +886,22 @@ func (curve *KoblitzCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int) { return curve.fieldJacobianToBigAffine(qx, qy, qz) } -// QPlus1Div4 returns the Q+1/4 constant for the curve for use in calculating -// square roots via exponention. +// QPlus1Div4 returns the (P+1)/4 constant for the curve for use in calculating +// square roots via exponentiation. +// +// DEPRECATED: The actual value returned is (P+1)/4, where as the original +// method name implies that this value is (((P+1)/4)+1)/4. This method is kept +// to maintain backwards compatibility of the API. Use Q() instead. func (curve *KoblitzCurve) QPlus1Div4() *big.Int { return curve.q } +// Q returns the (P+1)/4 constant for the curve for use in calculating square +// roots via exponentiation. +func (curve *KoblitzCurve) Q() *big.Int { + return curve.q +} + var initonce sync.Once var secp256k1 KoblitzCurve