arnaucube
arnaucube/go-iden3-cryptoPublic Self-hosted repository
Merge pull request #5 from iden3/decompress-modsqrt

return error if no ModSqrt(x, q) exist in babyjubjub decompress point
Eduard S eduard@iden3.io
Tue, 10 Sep 2019 10:48:18 +0200
commit

eb7d86c5b363cf4e56f76da9805ec6ef9d1724f4

parent

c95c95b7b161297df2940bd4eb19e36f43e4a07e

1 files changed, 4 insertions(+), 1 deletions(-)

jump to
M babyjub/babyjub.go → babyjub/babyjub.go

@@ -203,7 +203,10 @@ }

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) }