From a60e154d860f36847d2518983b4f412a85989453 Mon Sep 17 00:00:00 2001 From: arnaucube Date: Tue, 10 Sep 2019 00:36:54 +0200 Subject: [PATCH] return error if no ModSqrt(x, q) exist in babyjubjub decompress point --- babyjub/babyjub.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/babyjub/babyjub.go b/babyjub/babyjub.go index b53d148..26fa214 100644 --- a/babyjub/babyjub.go +++ b/babyjub/babyjub.go @@ -203,7 +203,10 @@ func (p *Point) Decompress(leBuf [32]byte) (*Point, error) { xb.ModInverse(xb, constants.Q) p.X.Mul(xa, xb) // xa / xb p.X.Mod(p.X, constants.Q) - p.X.ModSqrt(p.X, constants.Q) + noSqrt := p.X.ModSqrt(p.X, constants.Q) + if noSqrt == nil { + return nil, fmt.Errorf("x is not a square mod q") + } if (sign && !PointCoordSign(p.X)) || (!sign && PointCoordSign(p.X)) { p.X.Mul(p.X, constants.MinusOne) }