Noise is a framework for crypto protocols based on Diffie-Hellman key agreement. Noise can describe protocols that consist of a single message as well as interactive protocols.
A Noise protocol begins with two parties exchanging handshake messages. During this handshake phase the parties exchange DH public keys and perform a sequence of DH operations, hashing the DH results into a shared secret key. After the handshake phase each party can use this shared key to send encrypted transport messages.
The Noise framework supports handshakes where each party has a long-term static key pair and/or an ephemeral key pair. A Noise handshake is described by a simple language. This language consists of tokens which are arranged into message patterns. Message patterns are arranged into handshake patterns.
A message pattern is a sequence of tokens that specifies the DH public keys that comprise a handshake message, and the DH operations that are performed when sending or receiving that message. A handshake pattern specifies the sequential exchange of messages that comprise a handshake.
A handshake pattern can be instantiated by DH functions, cipher functions, and a hash function to give a concrete Noise protocol.
The core of Noise is a set of variables maintained by each party during a handshake, and rules for sending and receiving handshake messages by sequentially processing the tokens from a message pattern.
Each party maintains the following variables:
s, e: The local party's static and ephemeral key pairs (which may be empty).
rs, re: The remote party's static and ephemeral public keys (which may be empty).
h: A handshake hash value that hashes all the handshake data that's been sent and received.
ck: A chaining key that hashes all previous DH outputs. Once the handshake completes, the chaining key will be used to derive the encryption keys for transport messages.
k, n: An encryption key
k (which may be empty) and a counter-based nonce
n. Whenever a new DH output causes a new
ck to be calculated, a new
k is also calculated. The key
k and nonce
n are used to encrypt static public keys and handshake payloads. Encryption with
k uses some AEAD cipher mode (in the sense of Rogaway ) and includes the current
h value as "associated data" which is covered by the AEAD authentication. Encryption of static public keys and payloads provides some confidentiality and key confirmation during the handshake phase.
A handshake message consists of some DH public keys followed by a payload. The payload may contain certificates or other data chosen by the application. To send a handshake message, the sender specifies the payload and sequentially processes each token from a message pattern. The possible tokens are:
"e": The sender generates a new ephemeral key pair and stores it in the
e variable, writes the ephemeral public key as cleartext into the message buffer, and hashes the public key along with the old
h to derive a new
"s": The sender writes its static public key from the
s variable into the message buffer, encrypting it if
k is non-empty, and hashes the output along with the old
h to derive a new
"ee", "se", "es", "ss": A DH is performed between the initiator's key pair (whether static or ephemeral is determined by the first letter) and the responder's key pair (whether static or ephemeral is determined by the second letter). The result is hashed along with the old
ck to derive a new
n is set to zero.
After processing the final token in a handshake message, the sender then writes the payload into the message buffer, encrypting it if
k is non-empty, and hashes the output along with the old
h to derive a new
As a simple example, an unauthenticated DH handshake is described by the handshake pattern:
-> e <- e, ee
The initiator sends the first message, which is simply an ephemeral public key. The responder sends back its own ephemeral public key. Then a DH is performed and the output is hashed into a shared secret key.
Note that a cleartext payload is sent in the first message, after the cleartext ephemeral public key, and an encrypted payload is sent in the response message, after the cleartext ephemeral public key. The application may send whatever payloads it wants.
The responder can send its static public key (under encryption) and authenticate itself via a slightly different pattern:
-> e <- e, ee, s, es
In this case, the final
k values are a hash of both DH results. Since the
es token indicates a DH between the initiator's ephemeral key and the responder's static key, successful decryption by the initiator of the second message's payload serves to authenticate the responder to the initiator.
Note that the second message's payload may contain a zero-length plaintext, but the payload ciphertext will still contain authentication data (such as an authentication tag or "synthetic IV"), since encryption is with an AEAD mode. The second message's payload can also be used to deliver certificates for the responder's static public key.
The initiator can send its static public key (under encryption), and authenticate itself, using a handshake pattern with one additional message:
-> e <- e, ee, s, es -> s, se
The following sections flesh out the details, and add some complications. However, the core of Noise is this simple system of variables, tokens, and processing rules, which allow concise expression of a range of protocols.
All Noise messages are less than or equal to 65535 bytes in length. Restricting message size has several advantages:
Simpler testing, since it's easy to test the maximum sizes.
Reduces the likelihood of errors in memory handling, or integer overflow.
Enables support for streaming decryption and random-access decryption of large data streams.
Enables higher-level protocols that encapsulate Noise messages to use an efficient standard length field of 16 bits.
All Noise messages can be processed without parsing, since there are no type or length fields. Of course, Noise messages might be encapsulated within a higher-level protocol that contains type and length information. Noise messages might encapsulate payloads that require parsing of some sort, but payloads are handled by the application, not by Noise.
A Noise transport message is simply an AEAD ciphertext that is less than or equal to 65535 bytes in length, and that consists of an encrypted payload plus 16 bytes of authentication data. The details depend on the AEAD cipher function, e.g. AES256-GCM, or ChaCha20-Poly1305, but typically the authentication data is either a 16-byte authentication tag appended to the ciphertext, or a 16-byte synthetic IV prepended to the ciphertext.
A Noise handshake message is also less than or equal to 65535 bytes. It begins with a sequence of one or more DH public keys, as determined by its message pattern. Following the public keys will be a single payload which can be used to convey certificates or other handshake data, but can also contain a zero-length plaintext.
Static public keys and payloads will be in cleartext if they are sent in a handshake prior to a DH operation, and will be AEAD ciphertexts if they occur after a DH operation. (If Noise is being used with pre-shared symmetric keys, this rule is different: all static public keys and payloads will be encrypted; see Section 7). Like transport messages, AEAD ciphertexts will expand each encrypted field (whether static public key or payload) by 16 bytes.
For an example, consider the handshake pattern:
-> e <- e, ee, s, es -> s, se
The first message consists of a cleartext public key (
"e") followed by a cleartext payload (remember that a payload is implicit at the end of each message pattern). The second message consists of a cleartext public key (
"e") followed by an encrypted public key (
"s") followed by an encrypted payload. The third message consists of an encrypted public key (
"s") followed by an encrypted payload.
Assuming each payload contains a zero-length plaintext, and DH public keys are 56 bytes, the message sizes will be:
If pre-shared symmetric keys are used, the first message grows in size to 72 bytes, since the first payload becomes encrypted.
A Noise protocol is instantiated with a concrete set of DH functions, cipher functions, and a hash function. The signature for these functions is defined below. Some concrete functions are defined in Section 10.
The following notation will be used in algorithm pseudocode:
||operator concatenates byte sequences.
byte()function constructs a single byte.
Noise depends on the following DH functions (and an associated constant):
GENERATE_KEYPAIR(): Generates a new DH key pair. A DH key pair consists of
private_key elements. A
public_key represents an encoding of a DH public key into a byte sequence of length
public_key encoding details are specific to each set of DH functions.
DH(key_pair, public_key): Performs a DH calculation between the private key in
public_key and returns an output sequence of bytes of length
DHLEN. If the function detects an invalid
public_key, the output may be all zeros or any other value that doesn't leak information about the private key. For reasons discussed in Section 9.1 it is recommended for the function to have a null public key value that always yields the same output, regardless of private key. For example, the DH functions in Section 10 always map a DH public key of all zeros to an output of all zeros.
DHLEN = A constant specifying the size in bytes of public keys and DH outputs. For security reasons,
DHLEN must be 32 or greater.
Noise depends on the following cipher functions:
ENCRYPT(k, n, ad, plaintext): Encrypts
plaintext using the cipher key
k of 32 bytes and an 8-byte unsigned integer nonce
n which must be unique for the key
k. Returns the ciphertext. Encryption must be done with an "AEAD" encryption mode with the associated data
ad (using the terminology from ) and returns a ciphertext that is the same size as the plaintext plus 16 bytes for authentication data. The entire ciphertext must be indistinguishable from random if the key is secret.
DECRYPT(k, n, ad, ciphertext): Decrypts
ciphertext using a cipher key
k of 32 bytes, an 8-byte unsigned integer nonce
n, and associated data
ad. Returns the plaintext, unless authentication fails, in which case an error is signaled to the caller.
Noise depends on the following hash function (and associated constants):
HASH(data): Hashes some arbitrary-length data with a collision-resistant cryptographic hash function and returns an output of
HASHLEN = A constant specifying the size in bytes of the hash output. Must be 32 or 64.
BLOCKLEN = A constant specifying the size in bytes that the hash function uses internally to divide its input for iterative processing. This is needed to use the hash function with HMAC (
B in ).
Noise defines additional functions based on the above
HMAC-HASH(key, data): Applies
HMAC from  using the
HASH() function. This function is only called as part of
HKDF(chaining_key, input_key_material): Takes a
chaining_keybyte sequence of length
HASHLEN, and an
input_key_materialbyte sequence with length either zero bytes, 32 bytes, or
DHLENbytes. Returns two byte sequences of length
HASHLEN, as follows:
temp_key = HMAC-HASH(chaining_key, input_key_material).
output1 = HMAC-HASH(temp_key, byte(0x01)).
output2 = HMAC-HASH(temp_key, output1 || byte(0x02)).
output2 are all
HASHLEN bytes in length. Also note that the
HKDF() function is simply
HKDF from  with the
chaining_key as HKDF
salt, and zero-length HKDF
To precisely define the processing rules we adopt an object-oriented terminology, and present three "objects" which encapsulate state variables and provide "methods" which implement processing logic. These three objects are presented as a hierarchy: each higher-layer object includes one instance of the object beneath it. From lowest-layer to highest, the objects are:
CipherState object contains
n variables, which it uses to encrypt and decrypt ciphertexts. During the handshake phase each party has a single
CipherState, but during the transport phase each party has two
CipherState objects: one for sending, and one for receiving.
SymmetricState object contains a
h variables. It is so-named because it encapsulates all the "symmetric crypto" used by Noise. During the handshake phase each party has a single
SymmetricState, which can be deleted once the handshake is finished.
HandshakeState object contains a
SymmetricState plus DH variables
(s, e, rs, re) and a variable representing the handshake pattern. During the handshake phase each party has a single
HandshakeState, which can be deleted once the handshake is finished.
To execute a Noise protocol you
HandshakeState. During initialization you specify the handshake pattern, any local key pairs, and any public keys for the remote party you have knowledge of. After
Initialize() you call
ReadMessage() on the
HandshakeState to process each handshake message. If a decryption error occurs the handshake has failed and the
HandshakeState is deleted without sending further messages.
Processing the final handshake message returns two
CipherState objects, the first for encrypting transport messages from initiator to responder, and the second for messages in the other direction. At that point the
HandshakeState may be deleted. Transport messages are then encrypted and decrypted by calling
DecryptWithAd() on the relevant
CipherState with zero-length associated data.
The below sections describe these objects in detail.
CipherState can encrypt and decrypt data based on its
k: A cipher key of 32 bytes (which may be
Empty is a special value which indicates
k has not yet been initialized.
n: An 8-byte (64-bit) unsigned integer nonce.
CipherState responds to the following methods. The
++ post-increment operator applied to
n means "use the current
n value, then increment it". The maximum
n value (264-1) is reserved for future use and must not be used. If incrementing
n results in 264-1 (the maximum value), then any further
DecryptWithAd() calls will signal an error to the caller.
k = key. Sets
n = 0.
HasKey(): Returns true if
k is non-empty, false otherwise.
EncryptWithAd(ad, plaintext): If
k is non-empty returns
ENCRYPT(k, n++, ad, plaintext). Otherwise returns
DecryptWithAd(ad, ciphertext): If
k is non-empty returns
DECRYPT(k, n++, ad, ciphertext). Otherwise returns
ciphertext. If an authentication failure occurs in
DECRYPT() the error is signaled to the caller.
SymmetricState object contains a
CipherState plus the following variables:
ck: A chaining key of
h: A hash output of
SymmetricState responds to the following methods:
InitializeSymmetric(protocol_name): Takes an arbitrary-length
protocol_name byte sequence (see Section 11). Executes the following steps:
protocol_name is less than or equal to
HASHLEN bytes in length, sets
h equal to
protocol_name with zero bytes appended to make
HASHLEN bytes. Otherwise sets
h = HASH(protocol_name).
ck = h.
ck, temp_k = HKDF(ck, input_key_material). If
HASHLEN is 64, then truncates
temp_k to 32 bytes. Calls
h = HASH(h || data).
ciphertext = EncryptWithAd(h, plaintext), calls
MixHash(ciphertext), and returns
ciphertext. Note that if
EncryptWithAd() call will set
ciphertext equal to
plaintext = DecryptWithAd(h, ciphertext), calls
MixHash(ciphertext), and returns
plaintext. Note that if
DecryptWithAd() call will set
plaintext equal to
Split(): Returns a pair of
CipherStateobjects for encrypting transport messages. Executes the following steps, where
zerolenis a zero-length byte sequence:
temp_k1, temp_k2 = HKDF(ck, zerolen).
HASHLENis 64, then truncates
temp_k2to 32 bytes.
HandshakeState object contains a
SymmetricState plus the following variables, any of which may be
Empty is a special value which indicates the variable has not yet been initialized.
s: The local static key pair
e: The local ephemeral key pair
rs: The remote party's static public key
re: The remote party's ephemeral public key
HandshakeState also has variables to track its role, and the remaining portion of the handshake pattern:
initiator: A boolean indicating the initiator or responder role.
message_patterns: A sequence of message patterns. Each message pattern is a sequence of tokens from the set
("s", "e", "ee", "es", "se", "ss").
HandshakeState responds to the following methods:
Initialize(handshake_pattern, initiator, prologue, s, e, rs, re): Takes a valid
handshake_pattern (see Section 8) and an
initiator boolean specifying this party's role as either initiator or responder.
prologue byte sequence which may be zero-length, or which may contain context information that both parties want to confirm is identical (see Section 6).
Takes a set of DH key pairs
(s, e) and public keys
(rs, re) for initializing local variables, any of which may be empty. Public keys are only passed in if the
handshake_pattern uses pre-messages (see Section 8). The ephemeral values
(e, re) are typically left empty, since they are created and exchanged during the handshake; but there are exceptions (see Section 9.2).
protocol_name byte sequence by combining the names for the handshake pattern and crypto functions, as specified in Section 11. Calls
re variables to the corresponding arguments.
MixHash() once for each public key listed in the pre-messages from
handshake_pattern, with the specified public key as input (see Section 8 for an explanation of pre-messages). If both initiator and responder have pre-messages, the initiator's public keys are hashed first.
message_patterns to the message patterns from
WriteMessage(payload, message_buffer): Takes a
payload byte sequence which may be zero-length, and a
message_buffer to write the output into.
Fetches and deletes the next message pattern from
message_patterns, then sequentially processes each token from the message pattern:
e = GENERATE_KEYPAIR(), overwriting any previous value for
e.public_key to the buffer. Calls
EncryptAndHash(s.public_key) to the buffer.
MixKey(DH(x, ry)) if
EncryptAndHash(payload) to the buffer.
If there are no more message patterns returns two new
CipherState objects by calling
ReadMessage(message, payload_buffer): Takes a byte sequence containing a Noise handshake message, and a
payload_buffer to write the message's plaintext payload into.
Fetches and deletes the next message pattern from
message_patterns, then sequentially processes each token from the message pattern:
re to the next
DHLEN bytes from the message, overwriting any previous value for
temp to the next
DHLEN + 16 bytes of the message if
HasKey() == True, or to the next
DHLEN bytes otherwise. Sets
MixKey(DH(x, ry)) if
DecryptAndHash() on the remaining bytes of the message and stores the output into
If there are no more message patterns returns two new
CipherState objects by calling
Noise protocols have a prologue input which allows arbitrary data to be hashed into the
h variable. If both parties do not provide identical prologue data, the handshake will fail due to a decryption error. This is useful when the parties engaged in negotiation prior to the handshake and want to ensure they share identical views of that negotiation.
For example, suppose Bob communicates to Alice a list of Noise protocols that he is willing to support. Alice will then choose and execute a single protocol. To ensure that a "man-in-the-middle" did not edit Bob's list to remove options, Alice and Bob could include the list as prologue data.
Note that while the parties confirm their prologues are identical, they don't mix prologue data into encryption keys. If an input contains secret data that's intended to strengthen the encryption, a "PSK" handshake should be used instead (see next section).
Noise provides an optional pre-shared symmetric key or PSK mode to support protocols where both parties already have a shared secret key. When using pre-shared symmetric keys, the following changes are made:
Protocol names (Section 11) use the prefix
"NoisePSK_" instead of
Initialize() takes an additional
psk argument, which is a sequence of 32 bytes. Immediately after
MixHash(prologue) it sets
ck, temp = HKDF(ck, psk), then calls
MixHash(temp). This mixes the pre-shared key into the chaining key, and also mixes a one-way function of the pre-shared key into the
h value to ensure that
h is a function of all handshake inputs.
ReadMessage() are modified when processing the
"e" token to call
MixKey(e.public_key) as the final step. Because the initial messages in a handshake pattern are required to start with
"e" (Section 8.1), this ensures
k is initialized from the pre-shared key. This also uses the ephemeral public key's value as a random nonce to prevent re-using the same
n for different messages.
Initialize() is modified when processing an
"e" pre-message token in a "dependent" handshake pattern (see Section 8.1) to call
MixKey() on the ephemeral public key immediately after calling
MixHash() on it. This accomplishes the same randomization as the previous bullet, but needs to be applied to pre-messages for dependent patterns.
A message pattern is some sequence of tokens from the set
("e", "s", "ee", "es", "se", "ss").
A handshake pattern consists of:
A pattern for the responder's pre-message that takes the same range of values as the initiator's pre-message.
A sequence of message patterns for the actual handshake messages
The pre-messages represent an exchange of public keys that was somehow performed prior to the handshake, so these public keys must be inputs to
Initialize() for the "recipient" of the pre-message.
The first actual handshake message is sent from the initiator to the responder, the next is sent by the responder, the next from the initiator, and so on in alternating fashion.
The following handshake pattern describes an unauthenticated DH handshake:
Noise_NN(): -> e <- e, ee
The handshake pattern name is
Noise_NN. This naming convention will be explained in Section 8.3. The empty parentheses indicate that neither party is initialized with any key pairs. The tokens
"e" inside the parentheses would indicate that the initiator is initialized with static and/or ephemeral key pairs. The tokens
"re" would indicate the same thing for the responder.
Pre-messages are shown as patterns prior to the delimiter "...", with a right-pointing arrow for the initiator's pre-message, and a left-pointing arrow for the responder's pre-message. If both parties have a pre-message, the initiator's is listed first (and hashed first). During
MixHash() is called on any pre-message public keys, as described in Section 5.3.
The following pattern describes a handshake where the initiator has pre-knowledge of the responder's static public key, and performs a DH with the responder's static public key as well as the responder's ephemeral public key. This pre-knowledge allows an encrypted payload to be sent in the first message, although full forward secrecy and replay protection is only achieved with the second message.
Noise_NK(rs): <- s ... -> e, es <- e, ee
Handshake patterns must be valid in the following senses:
Parties can only send a static public key if they were initialized with a static key pair, and can only perform DH between private keys and public keys they possess.
Parties must not send their static public key, or an ephemeral public key, more than once per handshake (i.e. ignoring the pre-messages, there must be no more than one occurrence of "e", and one occurrence of "s", in the messages sent by any party).
Parties must send an ephemeral public key at the start of the first message they send (i.e. the first token of the first message pattern in each direction must be
"e"). To support "compound protocols" (see Section 9.2) an exception is allowed if the party's ephemeral public key was used as a "pre-message". A handshake pattern that relies on this exception is a dependent pattern, and can only be used according to the rules in Section 9.2.
After performing a DH between a remote public key and any local private key that is not an ephemeral private key, the local party must not send any encrypted data unless they have also performed a DH between an ephemeral private key and the remote public key.
Patterns failing the first check are obviously nonsense.
The second check outlaws redundant transmission of values to simplify implementation and testing.
The third and fourth checks are necessary because Noise uses DH outputs involving ephemeral keys to randomize the shared secret keys. Noise also uses ephemeral public keys to randomize PSK-based encryption. Patterns failing these checks could result in subtle but catastrophic security flaws.
Users are recommended to only use the handshake patterns listed below, or other patterns that have been vetted by experts to satisfy the above checks.
The following example handshake patterns represent "one-way" handshakes supporting a one-way stream of data from a sender to a recipient. These patterns could be used to encrypt files, database records, or other non-interactive data streams.
Following a one-way handshake the sender can send a stream of transport messages, encrypting them using the first
CipherState returned by
Split(). The second
Split() is discarded - the recipient must not send any messages using it (as this would violate the rules in Section 8.1).
One-way patterns are named with a single character, which indicates the status of the sender's static key:
No static key for sender
K= Static key for sender
Known to recipient
X= Static key for sender
Xmitted ("transmitted") to recipient
Noise_N is a conventional DH-based public-key encryption. The other patterns add sender authentication, where the sender's public key is either known to the recipient beforehand (
Noise_K) or transmitted under encryption (
The following example handshake patterns represent interactive protocols.
Interactive patterns are named with two characters, which indicate the status of the initator and responder's static keys:
The first character refers to the initiator's static key:
No static key for initiator
K= Static key for initiator
Known to responder
X= Static key for initiator
Xmitted ("transmitted") to responder
I= Static key for initiator
Immediately transmitted to responder, despite reduced or absent identity hiding
The second character refers to the responder's static key:
No static key for responder
K= Static key for responder
Known to responder
X= Static key for responder
Xmitted ("transmitted") to initiator
Noise_XX pattern is the most generically useful, since it is efficient and supports mutual authentication and transmission of static public keys.
All interactive patterns allow some encryption of handshake payloads:
Patterns where the initiator has pre-knowledge of the responder's static public key (i.e. patterns ending in
"K") allow "zero-RTT" encryption, meaning the initiator can encrypt the first handshake payload.
All interactive patterns allow "half-RTT" encryption of the first response payload, but the encryption only targets an initiator static public key in patterns starting with "K" or "I".
The security properties for handshake payloads are usually weaker than the final security properties achieved by transport payloads, so these early encryptions must be used with caution.
In some patterns the security properties of transport payloads can also vary. In particular: patterns starting with "K" or "I" have the caveat that the responder is only guaranteed "weak" forward secrecy for the transport messages it sends until it receives a transport message from the initiator. After receiving a transport message from the initiator, the responder becomes assured of "strong" forward secrecy.
The next section provides more analysis of these payload security properties.
The following table lists the security properties for Noise handshake and transport payloads for all the named patterns in Section 8.2 and Section 8.3. Each payload is assigned an "authentication" property regarding the degree of authentication of the sender provided to the recipient, and a "confidentiality" property regarding the degree of confidentiality provided to the sender.
The authentication properties are:
No authentication. This payload may have been sent by any party, including an active attacker.
Sender authentication vulnerable to key-compromise impersonation (KCI). The sender authentication is based on a static-static DH (
"ss") involving both parties' static key pairs. If the recipient's long-term private key has been compromised, this authentication can be forged. Note that a future version of Noise might include signatures, which could improve this security property, but brings other trade-offs.
Sender authentication resistant to key-compromise impersonation (KCI). The sender authentication is based on an ephemeral-static DH (
"se") between the sender's static key pair and the recipient's ephemeral key pair. Assuming the corresponding private keys are secure, this authentication cannot be forged.
The confidentiality properties are:
No confidentiality. This payload is sent in cleartext.
Encryption to an ephemeral recipient. This payload has forward secrecy, since encryption involves an ephemeral-ephemeral DH (
"ee"). However, the sender has not authenticated the recipient, so this payload might be sent to any party, including an active attacker.
Encryption to a known recipient, forward secrecy for sender compromise only, vulnerable to replay. This payload is encrypted based only on DHs involving the recipient's static key pair. If the recipient's static private key is compromised, even at a later date, this payload can be decrypted. This message can also be replayed, since there's no ephemeral contribution from the recipient.
Encryption to a known recipient, weak forward secrecy. This payload is encrypted based on an ephemeral-ephemeral DH and also an ephemeral-static DH involving the recipient's static key pair. However, the binding between the recipient's alleged ephemeral public key and the recipient's static public key hasn't been verified by the sender, so the recipient's alleged ephemeral public key may have been forged by an active attacker. In this case, the attacker could later compromise the recipient's static private key to decrypt the payload. Note that a future version of Noise might include signatures, which could improve this security property, but brings other trade-offs.
Encryption to a known recipient, weak forward secrecy if the sender's private key has been compromised. This payload is encrypted based on an ephemeral-ephemeral DH, and also based on an ephemeral-static DH involving the recipient's static key pair. However, the binding between the recipient's alleged ephemeral public and the recipient's static public key has only been verified based on DHs involving both those public keys and the sender's static private key. Thus, if the sender's static private key was previously compromised, the recipient's alleged ephemeral public key may have been forged by an active attacker. In this case, the attacker could later compromise the intended recipient's static private key to decrypt the payload (this is a variant of a "KCI" attack enabling a "weak forward secrecy" attack). Note that a future version of Noise might include signatures, which could improve this security property, but brings other trade-offs.
Encryption to a known recipient, strong forward secrecy. This payload is encrypted based on an ephemeral-ephemeral DH as well as an ephemeral-static DH with the recipient's static key pair. Assuming the ephemeral private keys are secure, and the recipient is not being actively impersonated by an attacker that has stolen its static private key, this payload cannot be decrypted.
For one-way handshakes, the below-listed security properties apply to the handshake payload as well as transport payloads.
For interactive handshakes, security properties are listed for each handshake payload. Transport payloads are listed as arrows without a pattern. Transport payloads are only listed if they have different security properties than the previous handshake payload sent from the same party. If two transport payloads are listed, the security properties for the second only apply if the first was received.
The following table lists the identity hiding properties for all the named patterns in Section 8.2 and Section 8.3. Each pattern is assigned properties describing the confidentiality supplied to the initiator's static public key, and to the responder's static public key. The underlying assumptions are that ephemeral private keys are secure, and that parties abort the handshake if they receive a static public key from the other party which they don't trust.
This section only considers identity leakage through static public key fields in handshakes. Of course, the identities of Noise participants might be exposed through other means, including payload fields, traffic analysis, or metadata such as IP addresses.
The properties for the relevant public key are:
Transmitted in clear.
Encrypted with forward secrecy, but can be probed by an anonymous initiator.
Encrypted with forward secrecy, but sent to an anonymous responder.
Not transmitted, but a passive attacker can check candidates for the responder's private key and determine whether the candidate is correct.
Encrypted to responder's static public key, without forward secrecy. If an attacker learns the responder's private key they can decrypt the initiator's public key.
Not transmitted, but a passive attacker can check candidates for the responder's private key and initiator's public key and determine if both candidates are correct.
Encrypted but with weak forward secrecy. An active attacker who pretends to be the initiator without the initiator's static private key, then later learns the initiator private key, can then decrypt the responder's public key.
Not transmitted, but an active attacker who pretends to be the initator without the initiator's static private key, then later learns a candidate for the initiator private key, can then check whether the candidate is correct.
Encrypted with forward secrecy to an authenticated party.
The patterns in the previous sections are the best option for most scenarios.
However, to construct new patterns we can apply some transformation to an existing pattern, and name the resulting pattern by appending the transformation name to the existing pattern's name.
For example, if you don't care about identity hiding, you could apply a "noidh" transformation which moves static public keys earlier in messages, so they are sent in cleartext where possible. This transforms the patterns from the left column to the right column:
Other tranformations might add or remove
"ss" operations, or defer DH operations until later.
Consider a protocol where an initiator will authenticate herself if the responder requests it. This could be viewed as the initiator choosing between patterns like
Noise_XX based on some value inside the responder's first handshake payload.
Noise doesn't directly support this. Instead, this could be simulated by always executing
Noise_XX. The initiator can simulate the
Noise_NX case by sending a dummy static public key if authentication is not requested. The value of the dummy public key doesn't matter. For efficiency, the initiator can send a null public key value per Section 4 (e.g. an all-zeros
25519 value that is guaranteed to produce an all-zeros output).
This technique is simple, since it allows use of a single handshake pattern. It also doesn't reveal which option was chosen from message sizes. It could be extended to allow a
Noise_XX pattern to support any permutation of authentications (initiator only, responder only, both, or none).
Consider a protocol where the initiator can attempt zero-RTT encryption based on the responder's static public key. If the responder has changed his static public key, the parties will need to switch to a "fallback" handshake where the responder transmits the new static public key and the initiator resends the zero-RTT data.
This can be handled by both parties re-initializing their
HandshakeState and executing a different handshake. Using handshake re-initialization to switch from one "simple" Noise protocol to another results in a compound protocol.
Public keys that were exchanged in the first handshake can be represented as pre-messages in the second handshake. If an ephemeral public key was sent in the first handshake and used as a pre-message in the second handshake, that party can avoid sending a new ephemeral by using a "dependent" pattern (see Section 8.1).
Re-initializing with a dependent pattern is only allowed if the new handshake and old handshake have different protocol names (see Section 11) and the rules for handling PSKs are followed (see Section 7).
If any negotiation occurred in the first handshake, the first handshake's
h variable should be provided as prologue to the second handshake.
By way of example, this section defines the Noise Pipe compound protocol. This protocol uses three handshake patterns - two defined in the previous section, and a new one:
Noise_XX is used for an initial full handshake if the parties haven't communicated before, after which the initiator can cache the responder's static public key.
Noise_IK is used for a zero-RTT abbreviated handshake.
If the responder fails to decrypt the first
Noise_IK message (perhaps due to changing his static key), the responder will initiate a new fallback handshake using the
Noise_XXfallback pattern which is identical to
Noise_XX except re-using the ephemeral public key from the first
Noise_IK message as a pre-message public key (thus is a "dependent" pattern).
Below are the three patterns used for Noise Pipes:
Noise_XX(s, rs): -> e <- e, ee, s, es -> s, se Noise_IK(s, rs): <- s ... -> e, es, s, ss <- e, ee, se Noise_XXfallback(s, rs, re): <- e ... -> e, ee, s, se <- s, es
Note that in the fallback case, the initiator and responder roles are switched: If Alice initiates a
Noise_IK handshake with Bob, Bob might initiate a
There needs to be some way for the recipient of a message to distinguish whether it's the next message in the current handshake pattern, or requires re-initialization for a new pattern. For example, each handshake message could be preceded by a
type byte (see Section 12). This byte is not part of the Noise message proper, but simply signals when re-initialization is needed. It could have the following meanings:
type == 0 in the initiator's first message then the initiator is performing a
Noise_XX handshake (full handshake).
type == 1 in the initiator's first message then the initiator is performing a
Noise_IK handshake (attempted abbreviated handshake).
type == 0 in the responder's first
Noise_IK response then the responder accepted the
Noise_IK message (successful abbreviated handshake).
type == 1 in the responder's first
Noise_IK response then the responder failed to authenticate the initiator's
Noise_IK message and is performing a
Noise_XXfallback handshake, using the initiator's ephemeral public key as a pre-message (fallback handshake).
Note that the
type byte doesn't need to be explicitly authenticated (as prologue, or additional AEAD data), since it's implicitly authenticated if the message is processed succesfully.
Parties may wish to hide what protocol they are executing from an eavesdropper. For example, suppose parties are using Noise Pipes, and want to hide whether they are performing a full handshake, abbreviated handshake, or fallback handshake.
This is fairly easy:
The first three messages can have their payloads padded with random bytes to a constant size, regardless of which handshake is executed.
Instead of a
type byte, the responder can use trial decryption to differentiate between an initial message using
Instead of a
type byte, an initiator who sent a
Noise_IK initial message can use trial decryption to differentiate between a response using
This leaves the Noise ephemerals in the clear, so an eavesdropper might suspect the parties are using Noise, even if it can't distinguish the handshakes. To make the ephemerals indistinguishable from random, techniques like Elligator  could be used.
Parties may wish to execute a Noise protocol, then perform authentication at the application layer using signatures, passwords, or something else.
To support this, Noise libraries should expose the final value of
h to the application as a handshake hash which uniquely identifies the Noise session.
Parties can then sign the handshake hash, or hash it along with their password, to get an authentication token which has a "channel binding" property: the token can't be used by the receiving party with a different sesssion.
GENERATE_KEYPAIR(): Returns a new Curve25519 key pair.
DH(keypair, public_key): Executes the Curve25519 DH function (aka "X25519" in . The null public key value is all zeros, which will always produce an output of all zeros. Other invalid public key values will also produce an output of all zeros.
DHLEN = 32
GENERATE_KEYPAIR(): Returns a new Curve448 key pair.
DH(keypair, public_key): Executes the Curve448 DH function (aka "X448" in . The null public key value is all zeros, which will always produce an output of all zeros. Other invalid public key values will also produce an output of all zeros.
DHLEN = 56
ENCRYPT(k, n, ad, plaintext)/
DECRYPT(k, n, ad, ciphertext):
AEAD_CHACHA20_POLY1305from . The 96-bit nonce is formed by encoding 32 bits of zeros followed by little-endian encoding of
n. (Earlier implementations of ChaCha20 used a 64-bit nonce; with these implementations it's compatible to encode
ndirectly into the ChaCha20 nonce without the 32-bit zero prefix).
ENCRYPT(k, n, ad, plaintext)/
DECRYPT(k, n, ad, ciphertext): AES256 with GCM from  with a 128-bit tag appended to the ciphertext. The 96-bit nonce is formed by encoding 32 bits of zeros followed by big-endian encoding of
BLAKE2sfrom  with digest length 32.
BLAKE2bfrom  with digest length 64.
To produce a Noise protocol name for
Initialize() you concatenate the ASCII names for the handshake pattern, the DH functions, the cipher functions, and the hash function, with underscore separators. For example:
If a pre-shared symmetric key is in use, then the prefix
"NoisePSK_" is used instead of
An application built on Noise must consider several issues:
Choosing crypto functions: The
25519 DH functions are recommended for typical uses, though the
448 DH functions might offer some extra security in case a cryptanalytic attack is developed against elliptic curve cryptography. The
448 DH functions should be used with a 512-bit hash like
25519 DH functions may be used with a 256-bit hash like
BLAKE2s, though a 512-bit hash might offer some extra security in case a cryptanalytic attack is developed against the smaller hash functions.
Extensibility: Applications are recommended to use an extensible data format for the payloads of all messages (e.g. JSON, Protocol Buffers). This ensures that fields can be added in the future which are ignored by older implementations.
Padding: Applications are recommended to use a data format for the payloads of all encrypted messages that allows padding. This allows implementations to avoid leaking information about message sizes. Using an extensible data format, per the previous bullet, will typically suffice.
Session termination: Applications must consider that a sequence of Noise transport messages could be truncated by an attacker. Applications should include explicit length fields or termination signals inside of transport payloads to signal the end of an interactive session, or the end of a one-way stream of transport messages.
Length fields: Applications must handle any framing or additional length fields for Noise messages, considering that a Noise message may be up to 65535 bytes in length. If an explicit length field is needed, applications are recommended to add a 16-bit big-endian length field prior to each message.
Type fields: Applications are recommended to include a single-byte type field prior to each Noise handshake message (and prior to the length field, if one is included). A recommended idiom is for the value zero to indicate no change from the current Noise protocol, and for applications to reject messages with an unknown value. This allows future protocol versions to specify handshake re-initialization or any other compatibility-breaking change (protocol extensions that don't break compatibility can be handled within Noise payloads).
This section collects various security considerations:
Session termination: Preventing attackers from truncating a stream of transport messages is an application responsibility. See previous section.
Rollback: If parties decide on a Noise protocol based on some previous negotiation that is not included as prologue, then a rollback attack might be possible. This is a particular risk with handshake re-initialization, and requires careful attention if a Noise handshake is preceded by communication between the parties.
Misusing public keys as secrets: It might be tempting to use a pattern with a pre-message public key and assume that a successful handshake implies the other party's knowledge of the public key. Unfortunately, this is not the case, since setting public keys to invalid values might cause predictable DH output. For example, a
Noise_NK_25519 initiator might send an invalid ephemeral public key to cause a known DH output of all zeros, despite not knowing the responder's static public key. If the parties want to authenticate with a shared secret, it must be passed in as a PSK.
Channel binding: Depending on the DH functions, it might be possible for a malicious party to engage in multiple sessions that derive the same shared secret key by setting public keys to invalid values that cause predictable DH output (as in previous bullet). This is why a higher-level protocol should use the handshake hash (
h) for a unique channel binding, instead of
ck, as explained in Section 9.4.
Incrementing nonces: Reusing a nonce value for
n with the same key
k for encryption would be catastrophic. Implementations must carefully follow the rules for nonces. Nonces are not allowed to wrap back to zero due to integer overflow, and the maximum nonce value is reserved for future use. This means parties are not allowed to send more than 264-1 transport messages.
Fresh ephemerals: Every party in a Noise protocol should send a new ephemeral public key and perform a DH with it prior to sending any encrypted data. Otherwise replay of a handshake message could trigger catastrophic key reuse. This is one rationale behind the patterns in Section 8, and the validity rules in Section 8.1. It's also the reason why one-way handshakes only allow transport messages from the sender, not the recipient.
Protocol names: The protocol name used with
Initialize() must uniquely identify the combination of handshake pattern and crypto functions for every key it's used with (whether ephemeral key pair, static key pair, or PSK). If the same secret key was reused with the same protocol name but a different set of cryptographic operations then bad interactions could occur.
Pre-shared symmetric keys: Pre-shared symmetric keys must be secret values with 256 bits of entropy.
Data volumes: The
AESGCM cipher functions suffer a gradual reduction in security as the volume of data encrypted under a single key increases. Due to this, parties should not send more than 256 bytes (roughly 72 petabytes) encrypted by a single key. If sending such large volumes of data is a possibility, different cipher functions should be chosen.
Hash collisions: If an attacker can find hash collisions on prologue data or the handshake hash, they may be able to perform "transcript collision" attacks that trick the parties into having different views of handshake data. It is important to use Noise with collision-resistant hash functions, and replace the hash function at any sign of weakness.
Implementation fingerprinting: If this protocol is used in settings with anonymous parties, care should be taken that implementations behave identically in all cases. This may require mandating exact behavior for handling of invalid DH public keys.
This section collects various design rationale:
Nonces are 64 bits in length because:
The recommended hash function families are SHA2 and BLAKE2 because:
Hash output lengths of both 256 bits and 512 bits are supported because:
Cipher keys and pre-shared symmetric keys are 256 bits because:
The authentication data in a ciphertext is 128 bits because:
The GCM security limit is 256 bytes because:
Big-endian length fields are recommended because:
Cipher nonces are big-endian for AES-GCM, and little-endian for ChaCha20, because:
MixKey() design uses
MixKey()input. This "extra" hashing might mitigate the impact of hash function weakness.
MixHash() is used instead of sending all inputs through
MixHash()is more efficient than
MixHash()avoids any IPR concerns regarding mixing identity data into session keys (see KEA+).
MixHash()produces a non-secret
hvalue that might be useful to higher-level protocols, e.g. for channel-binding.
h value hashes handshake ciphertext instead of plaintext because:
his a non-secret value that can be used for channel-binding or other purposes without leaking secret information.
Session termination is left to the application because:
Explicit random nonces (like TLS "Random" fields) are not used because:
The Noise specification (this document) is hereby placed in the public domain.
Noise is inspired by:
General feedback on the spec and design came from: Moxie Marlinspike, Jason Donenfeld, Rhys Weatherley, Tiffany Bennett, Jonathan Rudenberg, Stephen Touset, Tony Arcieri, and Alex Wied.
Thanks to Tom Ritter, Karthikeyan Bhargavan, David Wong, and Klaus Hartke for editorial feedback.
Moxie Marlinspike, Hugo Krawczyk, Samuel Neves, Christian Winnerlein, J.P. Aumasson, and Jason Donenfeld provided helpful input and feedback on the key derivation design.
The BLAKE2 team (in particular J.P. Aumasson, Samuel Neves, and Zooko) provided helpful discussion on using BLAKE2 with Noise.
Jeremy Clark, Thomas Ristenpart, and Joe Bonneau gave feedback on much earlier versions.
 P. Rogaway, “Authenticated-encryption with Associated-data,” in Proceedings of the 9th ACM Conference on Computer and Communications Security, 2002. http://web.cs.ucdavis.edu/~rogaway/papers/ad.pdf
 H. Krawczyk, M. Bellare, and R. Canetti, “HMAC: Keyed-Hashing for Message Authentication.” Internet Engineering Task Force; RFC 2104 (Informational); IETF, Feb-1997. http://www.ietf.org/rfc/rfc2104.txt
 H. Krawczyk and P. Eronen, “HMAC-based Extract-and-Expand Key Derivation Function (HKDF).” Internet Engineering Task Force; RFC 5869 (Informational); IETF, May-2010. http://www.ietf.org/rfc/rfc5869.txt
 D. J. Bernstein, M. Hamburg, A. Krasnova, and T. Lange, “Elligator: Elliptic-curve points indistinguishable from uniform random strings.” Cryptology ePrint Archive, Report 2013/325, 2013. http://eprint.iacr.org/2013/325
 A. Langley, M. Hamburg, and S. Turner, “Elliptic Curves for Security.” Internet Engineering Task Force; RFC 7748 (Informational); IETF, Jan-2016. http://www.ietf.org/rfc/rfc7748.txt
 Y. Nir and A. Langley, “ChaCha20 and Poly1305 for IETF Protocols.” Internet Engineering Task Force; RFC 7539 (Informational); IETF, May-2015. http://www.ietf.org/rfc/rfc7539.txt
 M. J. Dworkin, “SP 800-38D. Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC,” National Institute of Standards & Technology, Gaithersburg, MD, United States, 2007. http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
 NIST, “FIPS 180-4. Secure Hash Standard (SHS),” National Institute of Standards & Technology, Gaithersburg, MD, United States, 2012. http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
 M.-J. Saarinen and J.-P. Aumasson, “The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC).” Internet Engineering Task Force; RFC 7693 (Informational); IETF, Nov-2015. http://www.ietf.org/rfc/rfc7693.txt
 D. J. Bernstein, T. Lange, and P. Schwabe, “NaCl: Networking and Cryptography Library.”. https://nacl.cr.yp.to/
 D. J. Bernstein, “CurveCP: Usable security for the Internet.”. https://curvecp.org
 H. Krawczyk, “SIGMA: The ‘SIGn-and-MAc’ Approach to Authenticated Diffie-Hellman and Its Use in the IKE Protocols,” in Advances in Cryptology - CRYPTO 2003, 2003. http://webee.technion.ac.il/~hugo/sigma.html
 S. Halevi and H. Krawczyk, “One-Pass HMQV and Asymmetric Key-Wrapping.” Cryptology ePrint Archive, Report 2010/638, 2010. http://eprint.iacr.org/2010/638
 I. Goldberg, D. Stebila, and B. Ustaoglu, “Anonymity and One-way Authentication in Key Exchange Protocols,” Design, Codes, and Cryptography, vol. 67, no. 2, May 2013. http://cacr.uwaterloo.ca/techreports/2011/cacr2011-11.pdf
 M. Di Raimondo, R. Gennaro, and H. Krawczyk, “Secure Off-the-record Messaging,” in Proceedings of the 2005 ACM Workshop on Privacy in the Electronic Society, 2005. http://www.dmi.unict.it/diraimondo/web/wp-content/uploads/papers/otr.pdf
 C. Kudla and K. G. Paterson, “Modular Security Proofs for Key Agreement Protocols,” in Advances in Cryptology - ASIACRYPT 2005: 11th International Conference on the Theory and Application of Cryptology and Information Security, 2005. http://www.isg.rhul.ac.uk/~kp/ModularProofs.pdf
 S. Blake-Wilson, D. Johnson, and A. Menezes, “Key agreement protocols and their security analysis,” in Crytography and Coding: 6th IMA International Conference Cirencester, UK, December 17–19, 1997 Proceedings, 1997. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.25.387