github.com/ronperry/cryptoedge@v0.0.0-20150815114006-cc363e290743/jjm/verify.go (about) 1 package jjm 2 3 /* 4 Verification phase: 5 Public: 6 curve.Verify 7 Input: 8 from Signer: SigPub 9 from Requestor: m, s, r, R 10 Calculation: 11 m x SugPub =? s x Generator + r x R 12 Output: true/false 13 */ 14 15 // Verify verifies that a signature does actually verify for a given message and signer public key 16 func (client BlindingClient) Verify(msg []byte, signature *SignatureInt) bool { 17 // m x SugPub =? s x Generator + r x R 18 lsP := client.curve.ScalarMult(client.PubKey, msg) // m x SugPub 19 rsP1 := client.curve.ScalarBaseMult(signature.ScalarS.Bytes()) // s x Generator 20 rsP2 := client.curve.ScalarMult(signature.PointR, signature.ScalarR.Bytes()) // r x R 21 rsP := client.curve.AddPoints(rsP1, rsP2) // (s x Generator) + (r x R) 22 if lsP.X.Cmp(rsP.X) == 0 && lsP.Y.Cmp(rsP.Y) == 0 { 23 return true 24 } 25 return false 26 }