pub struct Uake {
pub shared_secret: SharedSecret,
/* private fields */
}
Expand description
Used for unilaterally authenticated key exchange between two parties.
let mut rng = rand::thread_rng();
let mut alice = Uake::new();
let mut bob = Uake::new();
let bob_keys = keypair(&mut rng)?;
let client_init = alice.client_init(&bob_keys.public, &mut rng)?;
let server_send = bob.server_receive(client_init, &bob_keys.secret, &mut rng)?;
let client_confirm = alice.client_confirm(server_send)?;
assert_eq!(alice.shared_secret, bob.shared_secret);
Fields§
The resulting shared secret from a key exchange
Implementations§
source§impl Uake
impl Uake
sourcepub fn client_init<R>(
&mut self,
pubkey: &PublicKey,
rng: &mut R
) -> Result<UakeSendInit, KyberError>where
R: CryptoRng + RngCore,
pub fn client_init<R>( &mut self, pubkey: &PublicKey, rng: &mut R ) -> Result<UakeSendInit, KyberError>where R: CryptoRng + RngCore,
Initiates a Unilaterally Authenticated Key Exchange.
let mut rng = rand::thread_rng();
let mut alice = Uake::new();
let bob_keys = keypair(&mut rng)?;
let client_init = alice.client_init(&bob_keys.public, &mut rng)?;
sourcepub fn server_receive<R>(
&mut self,
send_a: UakeSendInit,
secretkey: &SecretKey,
rng: &mut R
) -> Result<UakeSendResponse, KyberError>where
R: CryptoRng + RngCore,
pub fn server_receive<R>( &mut self, send_a: UakeSendInit, secretkey: &SecretKey, rng: &mut R ) -> Result<UakeSendResponse, KyberError>where R: CryptoRng + RngCore,
Handles the output of a client_init()
request
let mut alice = Uake::new();
let mut bob = Uake::new();
let mut bob_keys = keypair(&mut rng)?;
let client_init = alice.client_init(&bob_keys.public, &mut rng)?;
let server_send = bob.server_receive(client_init, &bob_keys.secret, &mut rng)?;
sourcepub fn client_confirm(
&mut self,
send_b: UakeSendResponse
) -> Result<(), KyberError>
pub fn client_confirm( &mut self, send_b: UakeSendResponse ) -> Result<(), KyberError>
Decapsulates and authenticates the shared secret from the output of
server_receive()
let client_init = alice.client_init(&bob_keys.public, &mut rng)?;
let server_send = bob.server_receive(client_init, &bob_keys.secret, &mut rng)?;
let client_confirm = alice.client_confirm(server_send)?;
assert_eq!(alice.shared_secret, bob.shared_secret);
Trait Implementations§
source§impl PartialEq<Uake> for Uake
impl PartialEq<Uake> for Uake
impl Eq for Uake
impl StructuralEq for Uake
impl StructuralPartialEq for Uake
Auto Trait Implementations§
impl RefUnwindSafe for Uake
impl Send for Uake
impl Sync for Uake
impl Unpin for Uake
impl UnwindSafe for Uake
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