Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

PB-662 simplify pet messages #383

Merged
merged 10 commits into from
Apr 21, 2020
613 changes: 283 additions & 330 deletions rust/src/coordinator.rs

Large diffs are not rendered by default.

59 changes: 58 additions & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(dead_code)]
#![allow(unused_imports)]
#![feature(or_patterns)]
#![feature(bool_to_option)]
#![feature(const_fn)]

#[macro_use]
extern crate tracing;
Expand All @@ -15,10 +15,67 @@ pub mod participant;
pub mod service;
pub mod utils;

use std::collections::HashMap;

use sodiumoxide::crypto::{box_, sign};

#[derive(Debug, PartialEq)]
/// PET protocol errors.
pub enum PetError {
InsufficientSystemEntropy,
InvalidMessage,
InsufficientParticipants,
AmbiguousMasks,
}

/// A public encryption key that identifies a coordinator.
type CoordinatorPublicKey = box_::PublicKey;

/// A secret encryption key that belongs to the public key of a coordinator.
type CoordinatorSecretKey = box_::SecretKey;

/// A public signature key that identifies a participant.
type ParticipantPublicKey = sign::PublicKey;

/// A secret signature key that belongs to the public key of a participant.
type ParticipantSecretKey = sign::SecretKey;

/// A public signature key that identifies a sum participant.
type SumParticipantPublicKey = ParticipantPublicKey;

/// A secret signature key that belongs to the public key of a sum participant.
type SumParticipantSecretKey = ParticipantSecretKey;

/// A public encryption key generated by a sum participant. It is used by the update participants to
/// encrypt their masking seed for each sum participant.
type SumParticipantEphemeralPublicKey = box_::PublicKey;

/// A secret signature key that belongs to the public key of a sum participant.
type SumParticipantEphemeralSecretKey = box_::SecretKey;

/// A public signature key that identifies an update participant.
type UpdateParticipantPublicKey = ParticipantPublicKey;

/// A secret signature key that belongs to the public key of an update participant.
type UpdateParticipantSecretKey = ParticipantSecretKey;

/// A signature to prove a participant's elligibility for a task.
type ParticipantTaskSignature = sign::Signature;

/// A dictionary created during the sum phase of the protocol. It maps the public key of every sum
/// participant to the ephemeral public key generated by that sum participant.
type SumDict = HashMap<SumParticipantPublicKey, SumParticipantEphemeralPublicKey>;

/// Local seed dictionaries are sent by update participants. They contain the participant's masking
/// seed, encrypted with the ephemeral public key of each sum participant.
type LocalSeedDict = HashMap<SumParticipantPublicKey, EncryptedMaskingSeed>;

/// A dictionary created during the update phase of the protocol. The global seed dictionary is
/// built from the local seed dictionaries sent by the update participants. It maps each sum
/// participant to the encrypted masking seeds of all the update participants.
type SeedDict =
HashMap<SumParticipantPublicKey, HashMap<UpdateParticipantPublicKey, EncryptedMaskingSeed>>;

/// Masking seed generated by an update participant, encrypted with the ephemeral public key of a
/// sum participant.
type EncryptedMaskingSeed = Vec<u8>;
Loading