Digital Signature
Stay organized with collections
Save and categorize content based on your preferences.
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
Choose a key type
We recommend using ECDSA_P256 for most use cases, but there are a variety of
options. In general, the following holds true:
- ECDSA_P256 is the most widely used option and a reasonable default. Note
though that ECDSA signatures are malleable.
- ED25519 creates deterministic signatures and provides better performance
than ECDSA_P256.
- RSA_SSA_PKCS1_3072_SHA256_F4 creates deterministic signatures and provides
the best verification performance (but signing is much slower than
ECDSA_P256 or ED25519).
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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-04 UTC.
[null,null,["Last updated 2025-03-04 UTC."],[[["\u003cp\u003eDigital signatures ensure data integrity and authenticity by verifying that data hasn't been tampered with.\u003c/p\u003e\n"],["\u003cp\u003eThey use a pair of keys (public and private) for asymmetric signing and verification, allowing for secure distribution of the public key.\u003c/p\u003e\n"],["\u003cp\u003eTink provides two primitives for digital signatures: \u003ccode\u003ePublicKeySign\u003c/code\u003e for signing and \u003ccode\u003ePublicKeyVerify\u003c/code\u003e for verifying.\u003c/p\u003e\n"],["\u003cp\u003eECDSA_P256 is generally recommended, with ED25519 offering better performance and RSA_SSA_PKCS1_3072_SHA256_F4 providing the fastest verification.\u003c/p\u003e\n"],["\u003cp\u003eDigital signatures in Tink guarantee a minimum of 112-bit security and support data of any length.\u003c/p\u003e\n"]]],["Digital signatures ensure data authenticity and integrity using asymmetric key pairs (public and private). `PublicKeySign` signs data, while `PublicKeyVerify` checks signatures. Key options include the widely used ECDSA_P256, faster ED25519, and high-verification-performance RSA_SSA_PKCS1_3072_SHA256_F4. Signatures offer 128-bit security (elliptic curves) or 112-bit security (RSA). ECDSA signatures are malleable, allowing attackers to forge valid signatures. If asymmetry is not needed consider using MAC.\n"],null,["# Digital Signature\n\nThe Digital Signature primitive lets you verify that no one has tampered with\nyour data. It provides authenticity and integrity, but not secrecy, of the\nsigned data. It is asymmetric, meaning it uses a pair of keys (public key and\nprivate key).\n\nThe Digital Signature primitive has the following properties:\n\n- **Authenticity** : It is impossible to create a signature for which `PublicKeyVerify.Verify(signature, message)` validates, unless you have the private key.\n- **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.\n\nIf you don't need asymmetry, consider using the simpler and more efficient\n[MAC](/tink/mac) primitive instead.\n\nThe functionality of digital signatures is represented in Tink as a pair of\nprimitives:\n\n- *PublicKeySign* for signing data\n- *PublicKeyVerify* for verifying the signature\n\n### Choose a key type\n\nWe recommend using **ECDSA_P256** for most use cases, but there are a variety of\noptions. In general, the following holds true:\n\n- ECDSA_P256 is the most widely used option and a reasonable default. Note though that ECDSA signatures are [malleable](#malleable).\n- ED25519 creates deterministic signatures and provides better performance than ECDSA_P256.\n- RSA_SSA_PKCS1_3072_SHA256_F4 creates deterministic signatures and provides the best verification performance (but signing is much slower than ECDSA_P256 or ED25519).\n\n### Minimal security guarantees\n\n- Data to be signed can have arbitrary length\n- 128-bit security level against adaptive chosen-message attacks for elliptic curve based schemes\n- 112-bit security level against adaptive chosen-message attacks for RSA based schemes (allows 2048-bit keys)\n\n### Malleability\n\nA signature scheme is malleable if an attacker can create a different valid\nsignature for an already signed message. While this is not a problem for most\nscenarios, in some cases programmers implicitly assume that valid signatures are\nunique, and this can lead to unexpected results.\n\n### Example use case\n\nSee I want to [digitally sign data](/tink/digitally-sign-data)."]]