ลายเซ็นดิจิทัล
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
องค์ประกอบพื้นฐานของลายเซ็นดิจิทัลช่วยให้คุณยืนยันได้ว่าไม่มีใครได้แทรกแซงข้อมูลของคุณ ซึ่งจะสร้างความน่าเชื่อถือและความสมบูรณ์ให้กับข้อมูลที่มีการเซ็นชื่อ แต่จะไม่รักษาความลับ ซึ่งเป็นแบบไม่สมมาตร ซึ่งหมายความว่าจะใช้คู่คีย์ (คีย์สาธารณะและคีย์ส่วนตัว)
องค์ประกอบพื้นฐานลายเซ็นดิจิทัลมีพร็อพเพอร์ตี้ต่อไปนี้
- ความถูกต้อง: การสร้างลายเซ็นที่
PublicKeyVerify.Verify(signature, message)
จะตรวจสอบได้นั้นเป็นไปไม่ได้ เว้นแต่คุณจะมีคีย์ส่วนตัว
- แบบไม่สมมาตร: การสร้างลายเซ็นใช้คีย์อื่นนอกเหนือจากการยืนยันลายเซ็น ซึ่งจะช่วยให้คุณแจกจ่ายคีย์สาธารณะเพื่อยืนยันลายเซ็นแก่บุคคลที่ไม่สามารถสร้างลายเซ็นได้
หากไม่ต้องการความไม่สมมาตร ให้พิจารณาใช้พรอมต์ MAC พื้นฐานที่ง่ายและมีประสิทธิภาพมากกว่าแทน
ฟังก์ชันการทำงานของลายเซ็นดิจิทัลจะแสดงใน Tink เป็นคู่ของพรอมิเตอต่อไปนี้
- PublicKeySign สําหรับการรับรองข้อมูล
- PublicKeyVerify สําหรับการยืนยันลายเซ็น
เลือกประเภทคีย์
เราขอแนะนำให้ใช้ ECDSA_P256 สำหรับกรณีการใช้งานส่วนใหญ่ แต่ก็มีตัวเลือกอื่นๆ อีกมากมาย โดยทั่วไปแล้ว ข้อมูลต่อไปนี้เป็นจริง
- ECDSA_P256 เป็นตัวเลือกที่ใช้กันอย่างแพร่หลายที่สุดและเป็นค่าเริ่มต้นที่เหมาะสม โปรดทราบว่าลายเซ็น ECDSA ปรับเปลี่ยนได้
- ED25519 จะสร้างลายเซ็นแบบกำหนดได้และมีประสิทธิภาพดีกว่า ECDSA_P256
- RSA_SSA_PKCS1_3072_SHA256_F4 จะสร้างลายเซ็นแบบกำหนดได้และให้การยืนยันประสิทธิภาพที่ดีที่สุด (แต่การรับรองจะช้ากว่า ECDSA_P256 หรือ ED25519 มาก)
การรับประกันความปลอดภัยขั้นต่ำ
- ข้อมูลที่จะเซ็นเซอร์มีความยาวเท่าใดก็ได้
- ระดับความปลอดภัย 128 บิตเพื่อป้องกันการโจมตีแบบเลือกข้อความแบบปรับเปลี่ยนได้สำหรับรูปแบบที่อิงตามรูปไข่
- ระดับความปลอดภัย 112 บิตเพื่อป้องกันการโจมตีแบบเลือกข้อความแบบปรับเปลี่ยนได้สำหรับรูปแบบที่อิงตาม RSA (อนุญาตคีย์ 2048 บิต)
ความสามารถในการปรับเปลี่ยน
รูปแบบลายเซ็นจะเปลี่ยนแปลงได้หากผู้โจมตีสร้างลายเซ็นที่ถูกต้องรูปแบบอื่นสำหรับข้อความที่ลงนามแล้วได้ แม้ว่านี่จะไม่ได้เป็นปัญหาสำหรับสถานการณ์ส่วนใหญ่ แต่ในบางกรณี นักเขียนโปรแกรมจะถือว่าลายเซ็นที่ถูกต้องนั้นไม่ซ้ำกันโดยปริยาย ซึ่งอาจทำให้เกิดผลลัพธ์ที่ไม่คาดคิด
ตัวอย่าง Use Case
ดูหัวข้อฉันต้องการเซ็นชื่อข้อมูลแบบดิจิทัล
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 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)."]]