Struct distributed_cards::Deck
source · [−]pub struct Deck { /* private fields */ }
Expand description
The Deck struct is the starting point to shuffle. It contains n cards. The deck doesn’t care what cards it represents.
Example
let rng = &mut thread_rng();
let primes = [Prime::random(128, rng), Prime::random(128, rng)]; // each participant contributes one prime
let rsa_parameter = RsaParameter::from_primes(&primes);
let uuid = Uuid::from_u128(0x_1905709b_e2ae_469c_9589_4e37dcf3e5bc); // must be unique and unpredictable for each shuffle
let deck = Deck::new(104, uuid);
let (encrypted_deck, key) = deck.shuffle_encrypt(&rsa_parameter, rng);
assert!(deck.is_shuffle_encrypt_valid(&key, &encrypted_deck));
Implementations
sourceimpl Deck
impl Deck
1st shuffling phase
pub fn shuffle_encrypt<Rng: CryptoRng + RngCore>(
&self,
rsa_parameter: &RsaParameter,
rng: &mut Rng
) -> (EncryptedDeck, Rsa)
pub fn is_shuffle_encrypt_valid(
&self,
key: &Rsa,
encrypted_deck: &EncryptedDeck
) -> bool
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Deck
impl<'de> Deserialize<'de> for Deck
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Deck
Auto Trait Implementations
impl RefUnwindSafe for Deck
impl Send for Deck
impl Sync for Deck
impl Unpin for Deck
impl UnwindSafe for Deck
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more