pub fn encode_message_2<B: AsRef<[u8]>>(&mut self, payload: B) -> OckamResult<Vec<u8>> {
        let t = &mut self.0;
        let static_secret = t
            .identity_key
            .take()
            .ok_or_else(|| Error::InvalidState.into())?;
        let static_public = t
            .identity_public_key
            .clone()
            .ok_or_else(|| Error::InvalidState.into())?;
        let ephemeral_key_pair = t
            .ephemeral_key_pair
            .take()
            .ok_or_else(|| Error::InvalidState.into())?;
        let remote_ephemeral_public_key = t
            .remote_ephemeral_public_key
            .take()
            .ok_or_else(|| Error::InvalidState.into())?;

        t.mix_hash(ephemeral_key_pair.public_key.as_ref())?;
        t.dh(
            &ephemeral_key_pair.secret_handle,
            remote_ephemeral_public_key.as_ref(),
        )?;

        let mut encrypted_s_and_tag = t.encrypt_and_mix_hash(static_public.as_ref())?;
        t.dh(&static_secret, remote_ephemeral_public_key.as_ref())?;
        t.remote_ephemeral_public_key = Some(remote_ephemeral_public_key);
        t.identity_key = Some(static_secret);
        let mut encrypted_payload_and_tag = t.encrypt_and_mix_hash(payload)?;

        let mut output = ephemeral_key_pair.public_key.as_ref().to_vec();
        t.ephemeral_key_pair = Some(ephemeral_key_pair);
        output.append(&mut encrypted_s_and_tag);
        output.append(&mut encrypted_payload_and_tag);
        Ok(output)
    }
/// Encode the second message to be sent
Encode the second message to be sent
Encode the second message to be sent
pub fn encode_message_2<B: AsRef<[u8]>>(&mut self, payload: B) -> OckamResult<Vec<u8>> {
        let t = &mut self.0;
        let static_secret = t
            .identity_key
            .take()
            .ok_or_else(|| Error::InvalidState.into())?;
        let static_public = t
            .identity_public_key
            .clone()
            .ok_or_else(|| Error::InvalidState.into())?;
        let ephemeral_key_pair = t
            .ephemeral_key_pair
            .take()
            .ok_or_else(|| Error::InvalidState.into())?;
        let remote_ephemeral_public_key = t
            .remote_ephemeral_public_key
            .take()
            .ok_or_else(|| Error::InvalidState.into())?;
        t.mix_hash(ephemeral_key_pair.public_key.as_ref())?;
        t.dh(
            &ephemeral_key_pair.secret_handle,
            remote_ephemeral_public_key.as_ref(),
        )?;
        let mut encrypted_s_and_tag = t.encrypt_and_mix_hash(static_public.as_ref())?;
        t.dh(&static_secret, remote_ephemeral_public_key.as_ref())?;
        t.remote_ephemeral_public_key = Some(remote_ephemeral_public_key);
        t.identity_key = Some(static_secret);
        let mut encrypted_payload_and_tag = t.encrypt_and_mix_hash(payload)?;
        let mut output = ephemeral_key_pair.public_key.as_ref().to_vec();
        t.ephemeral_key_pair = Some(ephemeral_key_pair);
        output.append(&mut encrypted_s_and_tag);
        output.append(&mut encrypted_payload_and_tag);
        Ok(output)
    }
pub fn encode_message_2 < B : AsRef < [ u8 ] > > ( & mut self , payload : B ) -> OckamResult < Vec < u8 > > { let t = & mut self . 0 ; let static_secret = t . identity_key . take ( ) . ok_or_else ( | | Error :: InvalidState . into ( ) ) ? ; let static_public = t . identity_public_key . clone ( ) . ok_or_else ( | | Error :: InvalidState . into ( ) ) ? ; let ephemeral_key_pair = t . ephemeral_key_pair . take ( ) . ok_or_else ( | | Error :: InvalidState . into ( ) ) ? ; let remote_ephemeral_public_key = t . remote_ephemeral_public_key . take ( ) . ok_or_else ( | | Error :: InvalidState . into ( ) ) ? ; t . mix_hash ( ephemeral_key_pair . public_key . as_ref ( ) ) ? ; t . dh ( & ephemeral_key_pair . secret_handle , remote_ephemeral_public_key . as_ref ( ) , ) ? ; let mut encrypted_s_and_tag = t . encrypt_and_mix_hash ( static_public . as_ref ( ) ) ? ; t . dh ( & static_secret , remote_ephemeral_public_key . as_ref ( ) ) ? ; t . remote_ephemeral_public_key = Some ( remote_ephemeral_public_key ) ; t . identity_key = Some ( static_secret ) ; let mut encrypted_payload_and_tag = t . encrypt_and_mix_hash ( payload ) ? ; let mut output = ephemeral_key_pair . public_key . as_ref ( ) . to_vec ( ) ; t . ephemeral_key_pair = Some ( ephemeral_key_pair ) ; output . append ( & mut encrypted_s_and_tag ) ; output . append ( & mut encrypted_payload_and_tag ) ; Ok ( output ) }
Encode the second message to be sent
Encode the second message to be sent
&mut self
payload
B
&mut self
payload
B