pub struct Initiator { /* private fields */ }
Implementations§
source§impl Initiator
impl Initiator
pub fn from_raw_k(key: [u8; 32]) -> Result<Box<Self>, Error>
pub fn without_pk() -> Result<Box<Self>, Error>
pub fn new(pk: Option<XOnlyPublicKey>) -> Box<Self>
sourcepub fn step_0(&mut self) -> Result<[u8; 64], Error>
pub fn step_0(&mut self) -> Result<[u8; 64], Error>
§4.5.1.1 Initiator
Initiator generates ephemeral keypair and sends the public key to the responder:
- initializes empty output buffer
- generates ephemeral keypair
e
, appendse.public_key
to the buffer (64 bytes plaintext public key encoded with ElligatorSwift) - calls
MixHash(e.public_key)
- calls
EncryptAndHash()
with empty payload and appends the ciphertext to the buffer (note that k is empty at this point, so this effectively reduces down toMixHash()
on empty data) - submits the buffer for sending to the responder in the following format
§Ephemeral public key message:
Field name | Description |
---|---|
PUBKEY | Initiator’s ephemeral public key |
Message length: 64 bytes
sourcepub fn step_2(&mut self, message: [u8; 234]) -> Result<NoiseCodec, Error>
pub fn step_2(&mut self, message: [u8; 234]) -> Result<NoiseCodec, Error>
§4.5.2.2 Initiator
- receives NX-handshake part 2 message
- interprets first 64 bytes as ElligatorSwift encoding of
re.public_key
- calls
MixHash(re.public_key)
- calls
MixKey(ECDH(e.private_key, re.public_key))
- decrypts next 80 bytes (64 bytes for ElligatorSwift encoded pubkey + 16 bytes MAC) with
DecryptAndHash()
and stores the results asrs.public_key
which is server’s static public key. - calls
MixKey(ECDH(e.private_key, rs.public_key)
- decrypts next 90 bytes with
DecryptAndHash()
and deserialize plaintext intoSIGNATURE_NOISE_MESSAGE
(74 bytes data + 16 bytes MAC) - return pair of CipherState objects, the first for encrypting transport messages from initiator to responder, and the second for messages in the other direction:
- sets
temp_k1, temp_k2 = HKDF(ck, zerolen, 2)
- creates two new CipherState objects
c1
andc2
- calls
c1.InitializeKey(temp_k1)
andc2.InitializeKey(temp_k2)
- returns the pair
(c1, c2)
- sets
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Initiator
impl Send for Initiator
impl Sync for Initiator
impl Unpin for Initiator
impl UnwindSafe for Initiator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more