Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
api!: SAP refactor
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
refactor of SAP
removal of bls_signature_aggregator
rename Proof to Signed
  • Loading branch information
maqi authored and Yoga07 committed Jun 7, 2021
1 parent d060cca commit ae472fa
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 30 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Expand Up @@ -12,7 +12,6 @@ version = "31.0.0"
[dependencies]
bincode = "1.2.1"
bls_dkg = "~0.3.1"
bls_signature_aggregator = "~0.2.0"
bytes = "1.0.1"
cookie-factory = "0.3.1"
crdts = "6.3.2"
Expand Down
12 changes: 6 additions & 6 deletions src/node/agreement.rs
Expand Up @@ -9,8 +9,8 @@
use super::{
plain_message::PlainMessage,
section::{MemberInfo, SectionAuthorityProvider},
signed::Signed,
};
use bls_signature_aggregator::Proof;
use ed25519_dalek::{PublicKey, Signature};
use hex_fmt::HexFmt;
use secured_linked_list::SecuredLinkedList;
Expand Down Expand Up @@ -40,22 +40,22 @@ impl Debug for DkgKey {
}

#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
pub struct DkgFailureProof {
pub struct DkgFailureSigned {
pub public_key: PublicKey,
pub signature: Signature,
}

#[derive(Default, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
pub struct DkgFailureProofSet {
pub proofs: Vec<DkgFailureProof>,
pub struct DkgFailureSignedSet {
pub signeds: Vec<DkgFailureSigned>,
pub non_participants: BTreeSet<XorName>,
}

/// A value together with the proof that it was agreed on by the majority of the section elders.
/// A value together with the signed that it was agreed on by the majority of the section elders.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub struct Proven<T: Serialize> {
pub value: T,
pub proof: Proof,
pub signed: Signed,
}

impl<T> Borrow<Prefix> for Proven<T>
Expand Down
6 changes: 5 additions & 1 deletion src/node/mod.rs
Expand Up @@ -14,10 +14,12 @@ mod plain_message;
mod prefix_map;
mod relocation;
mod section;
mod signature_aggregator;
mod signed;
mod src_authority;
mod variant;

pub use agreement::{DkgFailureProof, DkgFailureProofSet, DkgKey, Proposal, Proven};
pub use agreement::{DkgFailureSigned, DkgFailureSignedSet, DkgKey, Proposal, Proven};
pub use network::{Network, OtherSection};
pub use node_msg::{
NodeCmd, NodeCmdError, NodeDataError, NodeDataQueryResponse, NodeEvent, NodeMsg, NodeQuery,
Expand All @@ -30,6 +32,8 @@ pub use relocation::{RelocateDetails, RelocatePayload, RelocatePromise, SignedRe
pub use section::{
ElderCandidates, MemberInfo, Peer, PeerState, Section, SectionAuthorityProvider, SectionPeers,
};
pub use signature_aggregator::{Error, SignatureAggregator};
pub use signed::{Signed, SignedShare};
pub use src_authority::SrcAuthority;
pub use variant::{JoinRequest, ResourceProofResponse, Variant};

Expand Down
11 changes: 6 additions & 5 deletions src/node/network.rs
Expand Up @@ -6,8 +6,9 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use super::{agreement::Proven, prefix_map::PrefixMap, section::SectionAuthorityProvider};
use bls_signature_aggregator::Proof;
use super::{
agreement::Proven, prefix_map::PrefixMap, section::SectionAuthorityProvider, signed::Signed,
};
use serde::{Deserialize, Serialize};
use std::borrow::Borrow;
use xor_name::Prefix;
Expand All @@ -21,11 +22,11 @@ pub struct Network {

#[derive(Clone, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)]
pub struct OtherSection {
// If this is signed by our section, then `key_proof` is `None`. If this is signed by our
// sibling section, then `key_proof` contains the proof of the signing key itself signed by our
// If this is signed by our section, then `key_signed` is `None`. If this is signed by our
// sibling section, then `key_signed` contains the proof of the signing key itself signed by our
// section.
pub section_auth: Proven<SectionAuthorityProvider>,
pub key_proof: Option<Proof>,
pub key_signed: Option<Signed>,
}

impl Borrow<Prefix> for OtherSection {
Expand Down
10 changes: 5 additions & 5 deletions src/node/section/section_authority_provider.rs
Expand Up @@ -14,7 +14,7 @@ use std::{
fmt::{self, Debug, Display, Formatter},
net::SocketAddr,
};
use threshold_crypto::{PublicKey as BlsPublicKey, PublicKeyShare};
use threshold_crypto::PublicKeySet;
use xor_name::{Prefix, XorName};

/// The information about elder candidates in a DKG round.
Expand All @@ -32,10 +32,10 @@ pub struct ElderCandidates {
pub struct SectionAuthorityProvider {
/// The section prefix. It matches all the members' names.
pub prefix: Prefix,
/// Public key of the section.
pub section_key: BlsPublicKey,
/// Public key set of the section.
pub public_key_set: PublicKeySet,
// The section's complete set of elders as a map from their name to their socket address.
pub elders: BTreeMap<XorName, (PublicKeyShare, SocketAddr)>,
pub elders: BTreeMap<XorName, SocketAddr>,
}

impl Borrow<Prefix> for SectionAuthorityProvider {
Expand All @@ -50,7 +50,7 @@ impl Debug for SectionAuthorityProvider {
formatter,
"SectionAuthorityProvider {{ prefix: ({:b}), section_key: {:?}, elders: {{{:?}}} }}",
self.prefix,
self.section_key,
self.public_key_set.public_key(),
self.elders.iter().format(", "),
)
}
Expand Down

0 comments on commit ae472fa

Please sign in to comment.