Clone this wiki locally
In the real world, signatures help uniquely identify people because everyone's signature is unique. Digital signatures work similarly in that they are unique to holders of a private key, but unlike real world signatures, digital signatures are unforgable.
Digital signatures allow you to publish a public key, then you can use your private signing key to sign messages. Others who have your public key can then use it to validate that your messages are actually authentic.
Signer's perspective (RbNaCl::SigningKey):
# Generate a new random signing key signing_key = RbNaCl::SigningKey.generate # Sign a message with the signing key signature = signing_key.sign(message) # Obtain the verify key for a given signing key verify_key = signing_key.verify_key # Convert the verify key to a string to send it to a third party verify_key.to_s
Verifier's perspective (RbNaCl::VerifyKey):
# Create a VerifyKey object from a public key verify_key = RbNaCl::VerifyKey.new(verify_key) # Check the validity of a message's signature # Will raise RbNaCl::BadSignatureError if the signature check fails verify_key.verify(signature, message)
- Small keys: Ed25519 keys are only 256-bits (32 bytes), making them small enough to easily copy and paste. Ed25519 also allows the public key to be derived from the private key, meaning that it doesn't need to be included in a serialized private key in cases you want both.
- Small signatures: Ed25519 signatures are only 512-bits (64 bytes), one of the smallest signature sizes available.
- Deterministic: Unlike (EC)DSA, Ed25519 does not rely on an entropy source when signing messages (which has lead to catastrophic private key compromises), but instead computes signature nonces from a combination of a hash of the signing key's "seed" and the message to be signed. This avoids using an entropy source for nonces, which can be a potential attack vector if the entropy source is not generating good random numbers. Even a single reused nonce can lead to a complete disclosure of the private key in these schemes, which Ed25519 avoids entirely by being deterministic instead of tied to an entropy source.
- Collision Resistant: Hash-function collisions do not break this system. This adds a layer of defense against the possibility of weakness in the selected hash function.
- Public Keys: Curve25519 high-speed elliptic curve cryptography
- Signatures: Ed25519 digital signature system
Algorithm diagram (Ed25519):
k: Ed25519 private key (passed into
- A: Ed25519 public key derived from k
- M: message to be signed
- R: a deterministic nonce value calculated from a combination of private key data RH and the message M
- S: Ed25519 signature