Google Tink is an open-source repository for the integration of cryptography methods. It uses best practices in order to reduce risks and also to simplify code integration. Currently it supports Golang Java, C++, Python and Objective-C. As Java is well supported on Android devices, the code has already been integrated into a wide range of applications, including Google Pay.
One of the standard methods that we use in cryptography is to sign a message with a private key, and to prove the signing with the public. Thus, if Bob has a key pair, he uses his private key to sign the message, and then Alice will prove that it was Bob who signed it, using Bob’s public key. It will also prove that the message has not been changed by Eve.
We use this method in many applications. An example is in Bitcoin transfers and where Bob signs a transaction to pay Alice a given number of bitcoins. He signs this transaction with his private key (which is in his wallet), and then adds it, with his public key, onto the blockchain. Anyone who wants to check the transfer will check the signature with Bob’s public key.
Now let’s look at how Google Tink generates digital signature codes. While we can use ECDSA, EdDSA and RSA with Google Tink, a post-quantum robust method uses ML-DSA. Specifically, it uses ML-DSA-65, which has a 192-bit security level. We can then use the private key of the key pair to sign a message with the sign() method:
params, _:= mldsa.NewParameters(mldsa.MLDSA65, mldsa.VariantNoPrefix)
manager := keyset.NewManager()
keyID,_ := manager.AddNewKeyFromParameters(params)
manager.SetPrimary(keyID)
privKey, _ := manager.Handle()
We can produce a new signer with the private key:
signer, _ := signature.NewSigner(privKey)
signatureBytes, _ := signer.Sign(message)
and then generate the public key, and verify the signature:
pubKey, _ := privKey.Public()
verifier, _:= signature.NewVerifier(pubKey)
A sample run which shows the signature for a message of “Testing 123” and for a truncated signature, is:
Message: Testing 123
Signature (truncated to 100 bytes): a56ea8ccb87de8db79e3cdfd06c6f99de36c67799d4ca4d04335306f08514852921b0b4e3654a0c62785ab5014f8c19f1b1916bcae53bc96a19b6e8197e640613faaa296457ae1daebbe572e7c894c71e5e9a2697ce99a1fe84dbd48f9ee6c85b60c0f9594abe75242b51a44c7a50401a01585f8253a8e0a4a0d6879861caa6ea3b215806b4287afded72407467612ab44fb3dce1d2ddb0ffec28485451b98ba0e2e57f7765ca39d4054af7096cb6b5618c6792bf3e93d76425aa24cd62732936b05cb11381f551d
Signature size: 3309 bytes
Private Key: primary_key_id:451338756 key_info:{type_url:"type.googleapis.com/google.crypto.tink.MlDsaPrivateKey" status:ENABLED key_id:451338756 output_prefix_type:RAW}
Public Key: primary_key_id:451338756 key_info:{type_url:"type.googleapis.com/google.crypto.tink.MlDsaPublicKey" status:ENABLED key_id:451338756 output_prefix_type:RAW}
We can see that the signature size of ML-DSA is 3,309 bytes. In terms of the key pair, we have our private key in a RAW format of:
Private Key (first 150 characters) [key_data:{
type_url:"type.googleapis.com/google.crypto.tink.MlDsaPrivateKey"
value:"\x12 \x8f\xb8dwHT\"\xf64\x0e\xbd\x17\xa9p9}~\xde\xc6??B\x87~\x99\xb2\x91C\xa7:b\x8d\x1a\xa7\x0f\x12\xa0\x0f\x9a\xd1D\xaf\x11%\x1e/%!\xdbNd\xf6/\x03\xbc\xbd\x870#.!\xabp\x9d\x8b~{\x8drE%\x1f\x00`i\xebzF\x16\x857m\xe4\x12;\x03ǝ\xe94Y\xde7\xbf\xefX^\x97\xcf15C\xa0L\x9f{\xbd\x92c\xd8-Q>\xbc\x9a<'\x97\xacA\x19\xe2\x92\x1avffL\xb7$`\xfe\x159S\xa4ȴB\xd7\xcej\xc0\xb1\x7f¸L\xe2p\x9a͖\x1d]\xc1Ԩ\xfa%\xe9\xc8md\xbc4~\xcd/`\xc3'\x0b\xa7\xba\x942tA\x93\xbc\xca\xf6\x87\x82s\xd6\xcf\x1c3'N\xe2S\x9b?\xacb\xb6\xfe\xdd6\xefm%\t\x12)\xc7\x14+OƖ:\xc8U顔\xa8\xady\xa5Ƅۯ\xee\x08:\x87\xa3M\x80\x07\xebђ\x88\x7f\xf2A\x07\x86}\x86\x94Z\xf9Ǡ4+\x1ag\"\x9f&\xb85\xbb\xe8\xce\x15\x97\xd6*\xb4\xa1\xe5\\1\xff\x95\xeeO]\xffݫg\x1d\xf9\xb7\x1a\xfdRf+\x90\x19\x96\xca\x14=\xbc\x95\xdc;\xef\x93\xc5Q\xae\x9c!\xcf'\x83)\xb3s\x81|o\xa7zo\x0b\xec\xc5\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М\xcc\xf0xQ@E\xe9\x1a\x02\x08\x01"
key_material_type:ASYMMETRIC_PRIVATE}
status:ENABLED key_id:113708819
output_prefix_type:RAW]:
and a public key of:
[key_data:{type_url:"type.googleapis.com/google.crypto.tink.MlDsaPublicKey"
value:"\x12\xa0\x0f\x9a\xd1D\xaf\x11%\x1e/%!\xdbNd\xf6/\x03\xbc\xbd\x870#.!\xabp\x9d\x8b~{\x8drE%\x1f\x00`i\xebzF\x16\x857m\xe4\x12;\x03ǝ\xe94Y\xde7\xbf\xefX^\x97\xcf15C\xa0L\x9f{\xbd\x92c\xd8-Q>\xbc\x9a<'\x97\xacA\x19\xe2\x92\x1avffL\xb7$`\xfe\x159S\xa4ȴB\xd7\xcej\xc0\xb1\x7f¸L\xe2p\x9a͖\x1d]\xc1Ԩ\xfa%\xe9\xc8md\xbc4~\xcd/`\xc3'\x0b\xa7\xba\x942tA\x93\xbc\xca\xf6\x87\x82s\xd6\xcf\x1c3'N\xe2S\x9b?\xacb\xb6\xfe\xdd6\xefm%\t\x12)\xc7\x14+OƖ:\xc8U顔\xa8\xady\xa5Ƅۯ\xee\x08:\x87\xa3M\x80\x07\xebђ\x88\x7f\xf2A\x07\x86}\x86\x94Z\xf9Ǡ4+\x1ag\"\x9f&\xb85\xbb\xe8\xce\x15\x97\xd6*\xb4\xa1\xe5\\1\xff\x95\xeeO]\xffݫg\x1d\xf9\xb7\x1a\xfdRf+\x90\x19\x96\xca\x14=\xbc\x95\xdc;\xef\x93\xc5Q\xae\x9c!\xcf'\x83)\xb3s\x81|o\xa7zo\x0b\xec\xc5\x14\xc6S:\x1b\x8c\xbe\xd2'\xc0\xd6d\x96pIF\x97\xa6l\x88\x0e\xa7\x1e\x02\r\x01L\x9c\xfb\rT\xef\xfffo\x8b^\xa6\xfcd+\x88\x7f\xe8E\x06\x93\xcc/Е\xb7\xf7\x17\x8c\xa5\xaf\x9f\x1bXZh\x985\x1cV\xfe\xce\xd4\x01\x98\x1f\xbe\x0fG\xc3%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