Skip to main content

Module noise

Module noise 

Source
Expand description

Shared plumbing for handshakes based on the Noise-XX pattern.

The Noise static keys are generated per connection: they exist solely to give the pattern a channel to bind to, and are never persisted. Node identity remains the Aleo account key, which is bound to the session by signing the running Noise handshake hash - see binding_message.

Note that the transport keys a completed session yields are only used to carry the last handshake message, and are then dropped.

Structs§

NoiseSession
A Noise-XX session over a stream.
PendingSession
A stream whose first Noise message has been read but not yet processed.

Enums§

HandshakeProtocol
The handshake protocol a connection is speaking.
Role
The side of a Noise session; note that this is the side of the handshake, which for all current callers coincides with the side of the underlying TCP connection.

Constants§

HANDSHAKE_HASH_LEN
The length of the handshake hash, i.e. the digest length of the hash function in NOISE_PARAMS.
MAX_NOISE_MSG_LEN
The maximum length of a single Noise message, as mandated by the specification.
NOISE_MAGIC
The prefix that marks a stream as speaking the Noise handshake.
NOISE_PARAMS
The Noise handshake pattern used by snarkOS.

Functions§

binding_message
Returns the message that a party must sign with its Aleo account key in order to bind that identity to the Noise session identified by handshake_hash.
detect_handshake_protocol
Determines which handshake protocol the peer is speaking by consuming the first NOISE_MAGIC-sized chunk of the stream.
prepare_framed
Frames the given stream with the given codec, pre-populating the read buffer with bytes that were consumed from the stream before it was framed.
write_noise_magic
Announces to the peer that this side is about to perform a Noise handshake.