sm9: need to further check 0 handling

This commit is contained in:
emmansun 2023-04-29 13:47:58 +08:00
parent 13ddfad8e4
commit bf17ff1a4d

View File

@ -256,9 +256,7 @@ func (e *G1) UnmarshalCompressed(data []byte) ([]byte, error) {
e.p.x.Unmarshal(data[1:])
montEncode(&e.p.x, &e.p.x)
x3 := e.p.polynomial(&e.p.x)
if !Sqrt(&e.p.y, x3) {
return nil, errors.New("sm9.G1: invalid compressed point encoding")
}
e.p.y.Sqrt(x3)
montDecode(x3, &e.p.y)
if byte(x3[0]&1) != data[0]&1 {
gfpNeg(&e.p.y, &e.p.y)