Module irmaseal_core::kem::mr
source · [−]Expand description
This module contains a generic implementation shell around all three KEMs to use in a multi-recipient setting.
This feature requires the alloc
crate.
Example usage:
In this example we encapsulate a session key for two recipients.
use ibe::kem::IBKEM;
use ibe::kem::mr::{MultiRecipient, MultiRecipientCiphertext};
use ibe::kem::cgw_kv::CGWKV;
use ibe::Derive;
let mut rng = rand::thread_rng();
let ids = ["email:w.geraedts@sarif.nl", "email:l.botros@cs.ru.nl"];
let derived: Vec<<CGWKV as IBKEM>::Id> = ids.iter().map(|id| <CGWKV as IBKEM>::Id::derive_str(id)).collect();
// Create a master key pair.
let (pk, sk) = CGWKV::setup(&mut rng);
// Generate USKs for both identities.
let usk1 = CGWKV::extract_usk(None, &sk, &derived[0], &mut rng);
let usk2 = CGWKV::extract_usk(None, &sk, &derived[1], &mut rng);
// Encapsulate a single session key for two recipients.
let (cts, k) = CGWKV::multi_encaps(&pk, &derived[..], &mut rng);
// NOTE: Here we would send ciphertext over the network.
let k1 = CGWKV::multi_decaps(Some(&pk), &usk1, &cts[0]).unwrap();
let k2 = CGWKV::multi_decaps(Some(&pk), &usk2, &cts[1]).unwrap();
assert_eq!(k, k1);
assert_eq!(k, k2);
Structs
A multi-recipient ciphertext.
Traits
Trait that captures multi-recipient encapsulation/decapsulation.