Page Summary
-
Digital signatures ensure data integrity and authenticity by verifying that data hasn't been tampered with.
-
They use a pair of keys (public and private) for asymmetric signing and verification, allowing for secure distribution of the public key.
-
Tink provides two primitives for digital signatures:
PublicKeySignfor signing andPublicKeyVerifyfor verifying. -
ECDSA_P256 is generally recommended, with ED25519 offering better performance and RSA_SSA_PKCS1_3072_SHA256_F4 providing the fastest verification.
-
Digital signatures in Tink guarantee a minimum of 112-bit security and support data of any length.
The Digital Signature primitive lets you verify that no one has tampered with your data. It provides authenticity and integrity, but not secrecy, of the signed data. It is asymmetric, meaning it uses a pair of keys (public key and private key).
The Digital Signature primitive has the following properties:
- Authenticity: It is impossible to create a signature for which
PublicKeyVerify.Verify(signature, message)validates, unless you have the private key. - Asymmetric: Creating the signature uses a different key than verifying it. This lets you distribute the public key to verify signatures to parties that can't create signatures themselves.
If you don't need asymmetry, consider using the simpler and more efficient MAC primitive instead.
The functionality of digital signatures is represented in Tink as a pair of primitives:
- PublicKeySign for signing data
- PublicKeyVerify for verifying the signature
If the private key lives somewhere that the message can't easily be sent to, such as an HSM or a KMS, see Prehash and SignPrehash, which splits signing into a public-key-only hashing step and a private-key-only signing step.
Choose a key type
We recommend using ML_DSA_44 for most use cases where it is available.
- ML_DSA_44 is quantum safe and is recommended for programming languages where it is available.
Use the following classical algorithms only when ML-DSA is unavailable or classical interoperability is required, and expect to migrate them to post-quantum signatures in the future:
- ECDSA_P384_SHA384 (or ECDSA_P384_SHA512) is the recommended classical elliptic-curve option. Note that ECDSA signatures are malleable.
- RSA_SSA_PKCS1_3072_SHA256_F4 creates deterministic signatures and provides the best verification performance (but signing is much slower than ECDSA).
Minimal security guarantees
- Data to be signed can have arbitrary length
- 128-bit security level against adaptive chosen-message attacks for elliptic curve based schemes
- 112-bit security level against adaptive chosen-message attacks for RSA based schemes (allows 2048-bit keys)
Malleability
A signature scheme is malleable if an attacker can create a different valid signature for an already signed message. While this is not a problem for most scenarios, in some cases programmers implicitly assume that valid signatures are unique, and this can lead to unexpected results.
Example use case
See I want to digitally sign data.