MCPcopy Create free account
hub / github.com/DOSNetwork/core / Verify

Function Verify

sign/bls/bls.go:39–50  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
39func 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.

Callers 3

TestBLSFunction · 0.70
TestBLSFailSigFunction · 0.70
TestBLSFailKeyFunction · 0.70

Calls 9

hashToPointFunction · 0.85
G1Method · 0.65
PairingCheckMethod · 0.65
G2Method · 0.65
NewMethod · 0.65
PointMethod · 0.45
UnmarshalBinaryMethod · 0.45
NegMethod · 0.45
BaseMethod · 0.45

Tested by 3

TestBLSFunction · 0.56
TestBLSFailSigFunction · 0.56
TestBLSFailKeyFunction · 0.56