tink-crypto / tink-go

Go implementation of Tink
https://developers.google.com/tink
Apache License 2.0
89 stars 4 forks source link

Google Pay decryption in Go language #12

Open issatayev opened 3 years ago

issatayev commented 3 years ago

Currently I am implementing the Google Pay and stuck at the decryption part. I want to implement the Google Pay payment token decryption in Go language, but I couldn't find an example on how to use already generated private key with the Tink library. A private key is base64-encoded in PKCS tink-crypto/tink#8 format. In Google Pay documentation, there is an example in Java, where you can directly use a private key (https://developers.google.com/pay/api/processors/guides/implementation/using-tink). Below is an example:

String decryptedMessage = new PaymentMethodTokenRecipient.Builder() .fetchSenderVerifyingKeysWith( GooglePaymentsPublicKeysManager.INSTANCE_PRODUCTION) .recipientId("gateway:processorname") // This guide applies only to protocolVersion = ECv2 .protocolVersion("ECv2") // Multiple private keys can be added to support graceful // key rotations. .addRecipientPrivateKey(PrivateKey1) .addRecipientPrivateKey(PrivateKey2) .build() .unseal(encryptedMessage);

Can you please help me to figure out how to properly implement the decryption part? Is the only way is to work with keysets? If so, in order to decrypt using Tink, should I use hybrid decryption?

Sorry if it is a straightforward or basic question. Any examples/help/guidelines will be much appreciated.

SarahChenJieyi commented 2 years ago

Did you figure out how to decrypt with golang?

zhumango commented 2 years ago

I also ran into this problem, I can't find examples of how to do it, although I've read all the code in this library. If there is someone who has implemented, please give an example

tholenst commented 1 year ago

At the moment, we do not support this. This is considered a feature request for this.

qoyanchoz commented 11 months ago

Hi! Can anyone give feedback on whether tink is currently supported? If yes, can you please tell me how to properly decrypt Google Pay payload? Using Golang of course :) Thanks!