mirror of https://github.com/poanetwork/hbbft.git
Merge pull request #327 from alyjak/issue326-rename-ThresholdDecryption
Rename `ThresholdDecryption` to `ThresholdDecrypt`
This commit is contained in:
commit
9d4a477835
|
@ -9,7 +9,7 @@ use serde::{de::DeserializeOwned, Serialize};
|
|||
|
||||
use super::{Change, ChangeState, DynamicHoneyBadger, JoinPlan, Result, Step, VoteCounter};
|
||||
use honey_badger::{HoneyBadger, SubsetHandlingStrategy};
|
||||
use threshold_decryption::EncryptionSchedule;
|
||||
use threshold_decrypt::EncryptionSchedule;
|
||||
use util::SubRng;
|
||||
use {Contribution, NetworkInfo, NodeIdT};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crypto::PublicKey;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use threshold_decryption::EncryptionSchedule;
|
||||
use threshold_decrypt::EncryptionSchedule;
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Hash, Debug)]
|
||||
pub enum NodeChange<N> {
|
||||
|
|
|
@ -19,7 +19,7 @@ use fault_log::{Fault, FaultKind, FaultLog};
|
|||
use honey_badger::{self, HoneyBadger, Message as HbMessage};
|
||||
|
||||
use sync_key_gen::{Ack, AckOutcome, Part, PartOutcome, SyncKeyGen};
|
||||
use threshold_decryption::EncryptionSchedule;
|
||||
use threshold_decrypt::EncryptionSchedule;
|
||||
use util::{self, SubRng};
|
||||
use {Contribution, DistAlgorithm, NetworkInfo, NodeIdT, Target};
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ use rand::Rand;
|
|||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use self::votes::{SignedVote, VoteCounter};
|
||||
use super::threshold_decryption::EncryptionSchedule;
|
||||
use super::threshold_decrypt::EncryptionSchedule;
|
||||
use honey_badger::Message as HbMessage;
|
||||
use sync_key_gen::{Ack, Part, SyncKeyGen};
|
||||
use {Epoched, NodeIdT};
|
||||
|
|
|
@ -22,7 +22,7 @@ pub enum FaultKind {
|
|||
InvalidCiphertext,
|
||||
/// `HoneyBadger` received a message with an invalid epoch.
|
||||
UnexpectedHbMessageEpoch,
|
||||
/// `ThresholdDecryption` received multiple shares from the same sender.
|
||||
/// `ThresholdDecrypt` received multiple shares from the same sender.
|
||||
MultipleDecryptionShares,
|
||||
/// `Broadcast` received a `Value` from a node other than the proposer.
|
||||
ReceivedValueFromNonProposer,
|
||||
|
|
|
@ -7,7 +7,7 @@ use serde::{de::DeserializeOwned, Serialize};
|
|||
|
||||
use super::HoneyBadger;
|
||||
use honey_badger::SubsetHandlingStrategy;
|
||||
use threshold_decryption::EncryptionSchedule;
|
||||
use threshold_decrypt::EncryptionSchedule;
|
||||
use util::SubRng;
|
||||
use {Contribution, NetworkInfo, NodeIdT};
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use serde_derive::Serialize;
|
|||
use super::{Batch, ErrorKind, MessageContent, Result, Step};
|
||||
use fault_log::{Fault, FaultKind, FaultLog};
|
||||
use subset::{self as cs, Subset, SubsetOutput};
|
||||
use threshold_decryption::{self as td, ThresholdDecryption};
|
||||
use threshold_decrypt::{self as td, ThresholdDecrypt};
|
||||
use {Contribution, DistAlgorithm, NetworkInfo, NodeIdT};
|
||||
|
||||
type CsStep<N> = cs::Step<N, EpochId>;
|
||||
|
@ -25,7 +25,7 @@ type CsStep<N> = cs::Step<N, EpochId>;
|
|||
#[derive(Debug)]
|
||||
enum DecryptionState<N> {
|
||||
/// Decryption is still ongoing; we are waiting for decryption shares and/or ciphertext.
|
||||
Ongoing(Box<ThresholdDecryption<N>>),
|
||||
Ongoing(Box<ThresholdDecrypt<N>>),
|
||||
/// Decryption is complete. This contains the plaintext.
|
||||
Complete(Vec<u8>),
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ impl<N> DecryptionState<N>
|
|||
where
|
||||
N: NodeIdT + Rand,
|
||||
{
|
||||
/// Creates a new `ThresholdDecryption` instance, waiting for shares and a ciphertext.
|
||||
/// Creates a new `ThresholdDecrypt` instance, waiting for shares and a ciphertext.
|
||||
fn new(netinfo: Arc<NetworkInfo<N>>) -> Self {
|
||||
DecryptionState::Ongoing(Box::new(ThresholdDecryption::new(netinfo)))
|
||||
DecryptionState::Ongoing(Box::new(ThresholdDecrypt::new(netinfo)))
|
||||
}
|
||||
|
||||
/// Handles a message containing a decryption share.
|
||||
|
@ -246,7 +246,7 @@ where
|
|||
self.subset.received_proposals()
|
||||
}
|
||||
|
||||
/// Handles a message for the Subset or a Threshold Decryption instance.
|
||||
/// Handles a message for the Subset or a Threshold Decrypt instance.
|
||||
pub fn handle_message_content(
|
||||
&mut self,
|
||||
sender_id: &N,
|
||||
|
@ -270,7 +270,7 @@ where
|
|||
entry.insert(DecryptionState::new(self.netinfo.clone()))
|
||||
}
|
||||
}.handle_message(sender_id, share)
|
||||
.map_err(ErrorKind::ThresholdDecryption)?;
|
||||
.map_err(ErrorKind::ThresholdDecrypt)?;
|
||||
self.process_decryption(proposer_id, td_step)
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ where
|
|||
Ok(step)
|
||||
}
|
||||
|
||||
/// Processes a Threshold Decryption step.
|
||||
/// Processes a Threshold Decrypt step.
|
||||
fn process_decryption(&mut self, proposer_id: N, td_step: td::Step<N>) -> Result<Step<C, N>> {
|
||||
let mut step = Step::default();
|
||||
let opt_output = step.extend_with(td_step, |share| {
|
||||
|
@ -374,7 +374,7 @@ where
|
|||
}
|
||||
|
||||
/// Given the output of the Subset algorithm, inputs the ciphertexts into the Threshold
|
||||
/// Decryption instances and sends our own decryption shares.
|
||||
/// Decrypt instances and sends our own decryption shares.
|
||||
fn send_decryption_share(&mut self, proposer_id: N, v: &[u8]) -> Result<Step<C, N>> {
|
||||
let ciphertext: Ciphertext = match bincode::deserialize(v) {
|
||||
Ok(ciphertext) => ciphertext,
|
||||
|
@ -391,7 +391,7 @@ where
|
|||
Err(td::Error::InvalidCiphertext(_)) => {
|
||||
Ok(Fault::new(proposer_id, FaultKind::InvalidCiphertext).into())
|
||||
}
|
||||
Err(err) => Err(ErrorKind::ThresholdDecryption(err).into()),
|
||||
Err(err) => Err(ErrorKind::ThresholdDecrypt(err).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use bincode;
|
|||
use failure::{Backtrace, Context, Fail};
|
||||
|
||||
use subset;
|
||||
use threshold_decryption;
|
||||
use threshold_decrypt;
|
||||
|
||||
/// Honey badger error variants.
|
||||
#[derive(Debug, Fail)]
|
||||
|
@ -18,7 +18,7 @@ pub enum ErrorKind {
|
|||
#[fail(display = "Failed to handle Subset message: {}", _0)]
|
||||
HandleSubsetMessage(subset::Error),
|
||||
#[fail(display = "Threshold decryption error: {}", _0)]
|
||||
ThresholdDecryption(threshold_decryption::Error),
|
||||
ThresholdDecrypt(threshold_decrypt::Error),
|
||||
#[fail(display = "Unknown sender")]
|
||||
UnknownSender,
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use super::{Batch, Error, ErrorKind, HoneyBadgerBuilder, Message, Result};
|
|||
use {util, Contribution, DistAlgorithm, Epoched, Fault, FaultKind, NetworkInfo, NodeIdT};
|
||||
|
||||
pub use super::epoch_state::SubsetHandlingStrategy;
|
||||
use threshold_decryption::EncryptionSchedule;
|
||||
use threshold_decrypt::EncryptionSchedule;
|
||||
|
||||
/// An instance of the Honey Badger Byzantine fault tolerant consensus algorithm.
|
||||
#[derive(Derivative)]
|
||||
|
|
|
@ -3,7 +3,7 @@ use rand_derive::Rand;
|
|||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use subset;
|
||||
use threshold_decryption;
|
||||
use threshold_decrypt;
|
||||
|
||||
use Epoched;
|
||||
|
||||
|
@ -15,7 +15,7 @@ pub enum MessageContent<N: Rand> {
|
|||
/// A decrypted share of the output of `proposer_id`.
|
||||
DecryptionShare {
|
||||
proposer_id: N,
|
||||
share: threshold_decryption::Message,
|
||||
share: threshold_decrypt::Message,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
//! receive a valid signature. The outcome cannot be known by the adversary before at least one
|
||||
//! correct node has provided input, and can be used as a source of pseudorandomness.
|
||||
//!
|
||||
//! [**Threshold Decryption**](threshold_decryption/index.html)
|
||||
//! [**Threshold Decrypt**](threshold_decrypt/index.html)
|
||||
//!
|
||||
//! Each node inputs the same ciphertext, encrypted to the public master key. Once _f + 1_
|
||||
//! validators have received input, all nodes output the decrypted data.
|
||||
|
@ -144,7 +144,7 @@ pub mod queueing_honey_badger;
|
|||
pub mod sender_queue;
|
||||
pub mod subset;
|
||||
pub mod sync_key_gen;
|
||||
pub mod threshold_decryption;
|
||||
pub mod threshold_decrypt;
|
||||
pub mod threshold_sign;
|
||||
pub mod transaction_queue;
|
||||
pub mod util;
|
||||
|
|
|
@ -65,10 +65,10 @@ pub type Result<T> = ::std::result::Result<T, Error>;
|
|||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Rand)]
|
||||
pub struct Message(pub DecryptionShare);
|
||||
|
||||
/// A Threshold Decryption algorithm instance. If every node inputs the same data, encrypted to the
|
||||
/// A Threshold Decrypt algorithm instance. If every node inputs the same data, encrypted to the
|
||||
/// network's public key, every node will output the decrypted data.
|
||||
#[derive(Debug)]
|
||||
pub struct ThresholdDecryption<N> {
|
||||
pub struct ThresholdDecrypt<N> {
|
||||
netinfo: Arc<NetworkInfo<N>>,
|
||||
/// The encrypted data.
|
||||
ciphertext: Option<Ciphertext>,
|
||||
|
@ -80,9 +80,9 @@ pub struct ThresholdDecryption<N> {
|
|||
terminated: bool,
|
||||
}
|
||||
|
||||
pub type Step<N> = ::Step<ThresholdDecryption<N>>;
|
||||
pub type Step<N> = ::Step<ThresholdDecrypt<N>>;
|
||||
|
||||
impl<N: NodeIdT> DistAlgorithm for ThresholdDecryption<N> {
|
||||
impl<N: NodeIdT> DistAlgorithm for ThresholdDecrypt<N> {
|
||||
type NodeId = N;
|
||||
type Input = ();
|
||||
type Output = Vec<u8>;
|
||||
|
@ -106,10 +106,10 @@ impl<N: NodeIdT> DistAlgorithm for ThresholdDecryption<N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<N: NodeIdT> ThresholdDecryption<N> {
|
||||
/// Creates a new Threshold Decryption instance.
|
||||
impl<N: NodeIdT> ThresholdDecrypt<N> {
|
||||
/// Creates a new Threshold Decrypt instance.
|
||||
pub fn new(netinfo: Arc<NetworkInfo<N>>) -> Self {
|
||||
ThresholdDecryption {
|
||||
ThresholdDecrypt {
|
||||
netinfo,
|
||||
ciphertext: None,
|
||||
shares: BTreeMap::new(),
|
||||
|
@ -118,10 +118,10 @@ impl<N: NodeIdT> ThresholdDecryption<N> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Creates a new instance of `ThresholdDecryption`, including setting the ciphertext to
|
||||
/// Creates a new instance of `ThresholdDecrypt`, including setting the ciphertext to
|
||||
/// decrypt.
|
||||
pub fn new_with_ciphertext(netinfo: Arc<NetworkInfo<N>>, ct: Ciphertext) -> Result<Self> {
|
||||
let mut td = ThresholdDecryption::new(netinfo);
|
||||
let mut td = ThresholdDecrypt::new(netinfo);
|
||||
td.set_ciphertext(ct)?;
|
||||
Ok(td)
|
||||
}
|
|
@ -24,7 +24,7 @@ use rand::Rng;
|
|||
use hbbft::honey_badger::{Batch, HoneyBadger, MessageContent};
|
||||
use hbbft::sender_queue::{self, SenderQueue, Step};
|
||||
use hbbft::transaction_queue::TransactionQueue;
|
||||
use hbbft::{threshold_decryption, DistAlgorithm, Epoched, NetworkInfo, Target, TargetedMessage};
|
||||
use hbbft::{threshold_decrypt, DistAlgorithm, Epoched, NetworkInfo, Target, TargetedMessage};
|
||||
|
||||
use network::{
|
||||
Adversary, MessageScheduler, MessageWithSender, NodeId, RandomAdversary, SilentAdversary,
|
||||
|
@ -110,7 +110,7 @@ impl Adversary<UsizeHoneyBadger> for FaultyShareAdversary {
|
|||
Target::All.message(sender_queue::Message::Algo(
|
||||
MessageContent::DecryptionShare {
|
||||
proposer_id: NodeId(proposer_id),
|
||||
share: threshold_decryption::Message(share.clone()),
|
||||
share: threshold_decrypt::Message(share.clone()),
|
||||
}.with_epoch(*epoch),
|
||||
)),
|
||||
))
|
||||
|
|
Loading…
Reference in New Issue