Babyjubjub separate PointFromSignAndY from p.Decompress

This commit is contained in:
arnaucube
2020-08-06 13:34:36 +02:00
parent 29a66457f0
commit 833f68a614
2 changed files with 23 additions and 1 deletions

View File

@@ -181,6 +181,14 @@ func (p *Point) Decompress(leBuf [32]byte) (*Point, error) {
leBuf[31] = leBuf[31] & 0x7F
}
utils.SetBigIntFromLEBytes(p.Y, leBuf[:])
return PointFromSignAndY(sign, p.Y)
}
// PointFromSignAndY returns a Point from a Sign and the Y coordinate
func PointFromSignAndY(sign bool, y *big.Int) (*Point, error) {
var p Point
p.X = big.NewInt(0)
p.Y = y
if p.Y.Cmp(constants.Q) >= 0 {
return nil, fmt.Errorf("p.y >= Q")
}
@@ -209,5 +217,5 @@ func (p *Point) Decompress(leBuf [32]byte) (*Point, error) {
}
p.X.Mod(p.X, constants.Q)
return p, nil
return &p, nil
}