payment-data-cryptography-dotnet icon indicating copy to clipboard operation
payment-data-cryptography-dotnet copied to clipboard

VerifyMessageECv2 return false

Open sajasbana opened this issue 2 years ago • 2 comments

Dear please I need help, I have issue in test file SignatureVerificationTest.cs I have this payload token and we tried it with our merchant ID but it returns false

please can you help where is issue in my method

this is the method

[Fact]
        public void TestVerifyMessageECv2New()
        {
            var keyProvider = new GoogleKeyProvider(true);

            var payload = new PaymentData()
            {
                Signature = "MEQCIHO0tKvzdtAlW97QodVUHFiAyYLwUkeflDxDjQEbaNNAAiBl4POFTtAAMVBJLfUlkoljhUJpLg2qk2MTfG2O5EARAg\u003d\u003d",
                IntermediateSigningKey = new SigningKey()
                {
                    SignedKey = "{\"keyValue\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE5Wq0wHGCfnmRs4I+biemX8PxXWXszbkYbk+VOK7p3vp5b7TvXun5AFu1IVwKlEke2Lie4xyCpfdjuNsrOnLNUw\\u003d\\u003d\",\"keyExpiration\":\"1674781891312\"}",
                    Signatures = new string[] { "MEQCIDwVjfQwdtH0hglpOS8G56+/Zn+zvqEWyFtMMMr+i9hDAiAKoHTNM8tiWxQBTJGHXSw983lGPLmfKUUmvkaYWGAAFg\u003d\u003d" }
                },
                ProtocolVersion = "ECv2",
                SignedMessage = "{\"encryptedMessage\":\"WcNkDyuJzpbQJTOJFlHVoeghSCyjWupqAOjcWNZVWH7xOt5Guj5S2yA3jndChQq3oTWYmqAvrIMWT/GJ+0ql7aejJOIEKBUuRJEBPlgI5De9mHlt4MagmrKoNHbSlidQM56g4mHpxwMgPrbpyzRxFzdhu+l0psHJRkJsrx//LYId53KD7YRY/zunIQvBd6AOgSTrZ148oAB1nPL26PEJaiAcGmsnOP0IACFx51ciNkvDIUuog7g+bVH6x7qAdX2v0WFbfA+KSGH4besDOXxNyUkvlboq7eoUks1t6D7d3pBJvntvKvLWBZVslccoFmyLvbtFObAuCIY3DYLxOYTMqp4FAuZXGd/FaBPAQwHVV3cTQhzIA1V7+zLuvpzAjNATPgOpIgHSLb7EsC7mIGyWibdU0Sa0R124V/Yj2hDMKUdzdXyQniltdTRpcJsn/YfhtHmZ+ogQK4/5xvoDwTiLbdurvPl3zHSF187zqhnYxEqE5WQKaxNDboswE8qEVqrP989M8i/Q4+WctzPmQt5TvDccESMKkrdEQDWsfbA7vAhU3eR3lhj3X+W4c0zrQykJCzB12gI56dFp\",\"ephemeralPublicKey\":\"BHt4yaMDJ3zOj95ZF3pNrxXKSeoG0Bp6azeot8sOwFkUuYtLyMBH1SuUkwmI7d8OLxbEIJyngEkuL31rb1G4J3s\\u003d\",\"tag\":\"cyF1Hgvx+HKoCIWYK7UcF6ssuRxneJM7NfKS2XQk/2k\\u003d\"}",
            };
            var signatureVerification = new SignatureVerification();
            Assert.True(signatureVerification.VerifyMessage(payload, "Google", "merchant:1234", keyProvider));
        }

sajasbana avatar Jan 22 '23 09:01 sajasbana

issue now is in this part it returns false

ECPublicKeyParameters signingKey = KeyParser.ParsePublicKeyDer(signedKey.KeyValue);
            return VerifySignature(signingKey, signedString, signature);

in method VerifyMessageECv2 in class SignatureVerification.cs

sajasbana avatar Jan 23 '23 06:01 sajasbana

Hello, were you able to resolve this because i am having the same bug

olufemitomilola004 avatar Aug 18 '24 12:08 olufemitomilola004

Hey, were you guys able to reslove this issue?

unzeitip avatar Oct 15 '24 15:10 unzeitip

Hey, were you guys able to reslove this issue?

Yes

olufemitomilola004 avatar Oct 15 '24 17:10 olufemitomilola004

Hey, were you guys able to reslove this issue?

Yes

May i ask you for the solution?

unzeitip avatar Oct 15 '24 17:10 unzeitip

Hey, were you guys able to reslove this issue?

Yes

May i ask you for the solution?

What is the error message you got

olufemitomilola004 avatar Oct 15 '24 18:10 olufemitomilola004

@olufemitomilola004 When I set the IsTest parametr to true, VerifyMessage simply returns false exactly as this issue descibe. When I set IsTest to false, I'm getting No valid signing keys found in payload.

unzeitip avatar Oct 15 '24 19:10 unzeitip

@olufemitomilola004 When I set the IsTest parametr to true, VerifyMessage simply returns false exactly as this issue descibe. When I set IsTest to false, I'm getting No valid signing keys found in payload.

Then kindly confirm with Google to know if your payload is still valid because they do expire after 5days I guess. Also be certain that you are inputting the right gatewayId

olufemitomilola004 avatar Oct 15 '24 20:10 olufemitomilola004

@olufemitomilola004 How did you fix your issue https://github.com/google-pay/payment-data-cryptography-dotnet/issues/16 ?

unzeitip avatar Oct 16 '24 07:10 unzeitip