[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003eTink aims for cross-language consistency, ensuring the same behavior for a given keyset if primitive creation succeeds in multiple languages.\u003c/p\u003e\n"],["\u003cp\u003eTink defines two types of consistency: Evaluation Consistency (primitives behave the same across languages) and Creation Consistency (primitive creation success aligns with supported key types).\u003c/p\u003e\n"],["\u003cp\u003eWhile Tink strives for consistency, exceptions exist due to language limitations or specific key type support, which are documented for transparency.\u003c/p\u003e\n"],["\u003cp\u003eTink prioritizes Evaluation Consistency, as mismatched encryption/decryption between languages would pose significant issues.\u003c/p\u003e\n"],["\u003cp\u003eKeyset parsing consistency is not guaranteed, with behaviors subject to change across minor versions.\u003c/p\u003e\n"]]],["Tink ensures consistent cryptographic behavior across languages through evaluation and creation consistency. Evaluation consistency guarantees that if a primitive is created from a keyset in multiple languages, it will function identically. Creation consistency ensures that if two languages support a specific key type, primitive creation will succeed or fail for the same set of keys. Tink uses cross-language tests to maintain these consistencies and documents limitations in supported key types.\n"],null,["# Consistency\n\nIt's important that Tink behaves \"the same\" in all programming languages.\nThis concept is not straightforward, but most crucially:\n| **Key Point:** Tink provides evaluation consistency: For a given keyset, if primitive creation succeeds in two languages, the primitive behaves the same.\n\nTo maintain consistency, Tink uses cross-language tests which\ncan be found in the [cross-language GitHub\nrepository](https://github.com/tink-crypto/tink-cross-lang-tests).\nThese tests verify the consistency and interoperability of different languages.\n\nHowever, defining consistency is not as straightforward as one would expect.\nHence, this page provides our working definition. Basically, Tink provides\ntwo types of consistency:\n\n- **[Evaluation consistency:](#evaluation_consistency)** For a given keyset^[1](#fn1)^, if creation of the primitive succeeds in two languages, they behave the same.\n- **[Creation consistency:](#creation_consistency)** Creation of a primitive succeeds in a language if the language supports all key types in a keyset, as documented in [our list of supported key types](/tink/supported-key-types).\n\nContext\n-------\n\nOn a high level, Tink provides the following APIs:\n\n- **Keyset manipulation:** Tink provides APIs to add new keys to a keyset,\n remove keys from a keyset, and change the primary key in a keyset.\n\n- **Keyset serialization:** Tink provides APIs to serialize a keyset to\n a sequence of bytes, and conversely parse a keyset from a sequence of bytes.\n\n- **Primitive creation:** Tink provides an API to create an interface for\n a primitive from a keyset. For example, to create an `Aead` object from a\n keyset in Java, the user calls `keysetHandle.getPrimitive(Aead.class, config)`.\n\n- **Primitive usage:** The interface produced in the primitive creation step\n provides an API to perform cryptographic operations.\n\nThere are two important questions to ask about these APIs:\n\n- **Creation:**\n For a given serialized keyset, language, and primitive,\n is it possible to create the primitive from this keyset in the language?\n\n- **Evaluation:**\n If a primitive can be created in some language from a given\n keyset, how does the primitive object behave?\n\nIt is important to note that Tink does not provide consistency when parsing a\nkeyset. For example, it is possible that Tink C++\n\n- successfully parses keysets containing CHACHA20-POLY1305 keys, even though CHACHA20-POLY1305 AEAD operations are not implemented in Tink;\n- successfully parses keysets with keys that have a length of 1-byte, which will fail in all cryptographic operations.\n\nThese behaviors may change in minor versions.\n\nEvaluation consistency\n----------------------\n\nConsistency of evaluation is more important than any consistency in the creation\nprocess: if an AEAD in Java cannot decrypt the encryption of the AEAD in C++,\nusers have a serious problem.\n\nIn general, Tink aims to be consistent in the obvious way for primitives. For\nexample, if a C++ binary computes a signature\nwith `public_key_sign-\u003eSign(data)`, the corresponding Java verification\ncall `publicKeyVerify.verify(signature, data)` is expected to succeed.\n\nHowever, even here there are some caveats. For example,\nthe return type of `aead.Encrypt` in Java is a `byte[]`.\nPer Java Language Specification (JLS) §10.7, the length of an array is of\ntype `int` which per §JLS 4.2.1 can be a maximum of 2147483647. Hence,\nencryption of an array with a length of 2147483647 fails in Java: encryption\nhas some overhead, meaning\nthe output would be too long. Nevertheless, in other languages encryption\nis allowed to succeed for such inputs.\n\nHence, Tink provides evaluation consistency:\nFor a given keyset, if creation of the primitive succeeds in\ntwo languages, they behave the same.\n\nThe exception is that some operations may fail in some exceptional\ncircumstances.\n\nCreation consistency\n--------------------\n\nCreation of primitives does not always succeed for all keysets. For example,\nTink does not allow users to create an AesSivKey if the key material has a\nlength of 128 bits.\n\nNevertheless, Tink provides consistency as follows: if two languages both\nsupport a key type, the set of keys for which the primitive can be created\ncoincides. Of course, if a language does not support a key type, then no\nprimitive object can be created.\n\nCreation consistency is less important than evaluation consistency, and\nthere are more exceptions to this rule than for evaluation consistency.\nThese limitations are documented on\n[our list of supported key types](/tink/supported-key-types).\nFor example, for key type ECIES Tink offers a choice of which elliptic curve\nto use for key agreement, but Java does not support X25519. Hence,\ncreation of a key using X25519 in Java fails. \n\n*** ** * ** ***\n\n1. In this document, we use the term `Keyset` to denote the object called\n `KeysetHandle` in most languages. [↩](#fnref1)"]]