Verify checks the given BLS signature S on the message m using the public key X by verifying that the equality e(H(m), X) == e(H(m), x*B2) == e(x*H(m), B2) == e(S, B2) holds where e is the pairing operation and B2 is the base point from curve G2.
(suite suites.Suite, X kyber.Point, msg, sig []byte)
| 37 | // e(x*H(m), B2) == e(S, B2) holds where e is the pairing operation and B2 is |
| 38 | // the base point from curve G2. |
| 39 | func Verify(suite suites.Suite, X kyber.Point, msg, sig []byte) error { |
| 40 | HM := hashToPoint(suite, msg) |
| 41 | s := suite.G1().Point() |
| 42 | if err := s.UnmarshalBinary(sig); err != nil { |
| 43 | return err |
| 44 | } |
| 45 | s.Neg(s) |
| 46 | if !suite.PairingCheck([]kyber.Point{s, HM}, []kyber.Point{suite.G2().Point().Base(), X}) { |
| 47 | return errors.New("bls: invalid signature") |
| 48 | } |
| 49 | return nil |
| 50 | } |
| 51 | |
| 52 | // hashToPoint hashes a message to a point on curve G1. XXX: This should be replaced |
| 53 | // eventually by a proper hash-to-point mapping like Elligator. |