Avalanche uses a variety of cryptographic primitives for its different functions. This file summarizes the type and kind of cryptography used at the network and blockchain layers.
Cryptography in the Network Layer
Avalanche uses Transport Layer Security, TLS, to protect node-to-node communications from eavesdroppers. TLS combines the practicality of public-key cryptography with the efficiency of symmetric-key cryptography. This has resulted in TLS becoming the standard for internet communication. Whereas most classical consensus protocols employ public-key cryptography to prove receipt of messages to third parties, the novel Snow* consensus family does not require such proofs. This enables Avalanche to employ TLS in authenticating stakers, and eliminates the need for costly public-key cryptography for signing network messages.
Avalanche does not rely on any centralized third-parties, and in particular, it does not use certificates issued by third party authenticators. All certificates used within the network layer to identify endpoints are self-signed, thus creating a self-sovereign identity layer. No third parties are ever involved.
To avoid posting the full TLS certificate to the Platform chain, the certificate is first hashed. For consistency, Avalanche employs the same hashing mechanism for the TLS certificates as is used in Bitcoin. Namely, the DER representation of the certificate is hashed with sha256, and the result is then hashed with ripemd160 to yield a 20-byte identifier for stakers.
Cryptography in the Avalanche Virtual Machine
The Avalanche virtual machine uses elliptic curve cryptography, specifically
secp256k1, for its signatures on the blockchain.
Avalanche follows the exact same approach as Bitcoin and hashes the ECDSA public key. First the 33-byte compressed representation of the public key is hashed with sha256, then the result is hashed with ripemd160 to yield a 20-byte address for each user.
Secp256k1 Recoverable Signatures
Recoverable signatures are stored as the 65-byte
[R || S || V] where
V is 0 or 1 to allow quick public key recoverability.
S must be in the lower half of the possible range to prevent signature malleability. Before signing a message, the message is hashed using sha256.
Suppose Rick and Morty are setting up a secure communication channel. Morty creates a new public private key pair.
Public Key (33-byte compressed):
Because of Rick’s infinite wisdom, he doesn’t trust himself with carrying around Morty’s public key, so he only asks for Morty’s address. Morty follows the instructions, SHA256’s his public key, and then ripemd160’s that result to product an address.
Morty is quite confused, because a public key should be safe to be public knowledge. Rick belches, and explains that hashing the public key protects the private key owner from potential future security flaws in elliptic curve cryptography. In the event cryptography is broken and a private key can be derived from a public key, users can transfer their funds to an address that has never signed a transaction before, preventing their funds from being compromised by an attacker. This enables coin owners to be protected while the cryptography is upgraded across the clients.
Later, once Morty has learned more about Rick’s backstory, Morty attempts to send Rick a message. Morty knows that Rick will only read the message if he can verify it was from him, so he signs the message with his private key.
Morty was never seen again.
Cryptography in Ethereum Virtual Machine
Avalanche nodes support the full Ethereum virtual machine, and precisely duplicate all of the cryptographic constructs used in Ethereum. This includes the Keccak hash function, and the other mechanisms used for cryptographic security in the EVM.
Cryptography in Other Virtual Machines
Since Avalanche is an extensible platform, we expect that people will add additional cryptographic primitives to the system over time.