The Builder struct is used to configure the parameters for a Noise handshake and construct a HandshakeState. You can specify cryptographic parameters, static keys, remote public keys, pre-shared keys (PSKs), and handshakes prologues.
Once configured, you call .build_initiator() to create a state for the side sending the first message, or .build_responder() for the side receiving the first message.
Note that many configuration methods can only be called once; attempting to overwrite a parameter (like local_private_key or prologue) will return an Error with InitStage::ParameterOverwrite.
# use snow::Builder;
# fn main() -> Result<(), Box<dyn std::error::Error>> {
let my_long_term_key = [0u8; 32];
let their_pub_key = [0u8; 32];
let noise = Builder::new("Noise_XX_25519_ChaChaPoly_BLAKE2s".parse()?)
.local_private_key(&my_long_term_key)?
.remote_public_key(&their_pub_key)?
.prologue("noise is just swell".as_bytes())?
.build_initiator()?;
# Ok(())
# }