diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/federation/party.rs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/federation/party.rs b/src/federation/party.rs index d302612..9a74556 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -12,9 +12,7 @@ //! * `write PATH VALUE`: writes `VALUE` (JSON) at `PATH`; //! * `keys KEY...`, `nodes NODE...`: writes the party's key set (`authorized_keys` lines, //! each one argument, their comments left out) or node list (node IDs); with `--add` and -//! `--remove`, the set or list as it counts at the node, changed. Signed with a key the -//! current version names for the party, which the client checks first: where its key -//! isn't one, only a version naming the party's keys or list anew changes them; +//! `--remove`, the set or list as it counts at the node, changed; //! * `next`: the version after the current one, to change and propose: the current one //! numbered on, naming its hash, without its checkpoint (JSON), to standard output; //! * `propose FILE`: proposes the version `FILE` holds (JSON), where it changes the @@ -36,6 +34,10 @@ //! * `check FILE`: what the node finds of the fork whose root `FILE` holds: whether it //! builds it, what it holds that its heads lack, and the parties whose keys it gives //! otherwise. +//! +//! Votes, proposals, key sets and node lists are signed with a key the current version +//! names for the party, which the client checks first (`Signer::named_by`): where its key +//! isn't one, only a version naming the party's keys or list anew changes them. use std::collections::BTreeSet; use std::path::{Path, PathBuf}; @@ -380,6 +382,7 @@ pub(crate) async fn main() -> Result<()> { ("propose", sub) => { let version = version_in(sub.get_one::<String>("file").expect("required"))?; let current = node.current().await?; + signer.named_by(¤t)?; let proposed = Version::read(&version) .and_then(|proposed| proposed.changes_validly(Some(¤t)).map(|()| proposed)) .map_err(|why| { @@ -570,8 +573,8 @@ impl Signer { } /// Refuses where `current` doesn't name the key it signs with for its party: only those - /// sign the party's key set and node list, and otherwise only a version naming the - /// party's keys or list anew, by the parties' votes, changes them. + /// sign the party's votes, proposals, key set and node list, and otherwise only a + /// version naming the party's keys or list anew, by the parties' votes, changes them. fn named_by(&self, current: &Version) -> Result<()> { let (party, number) = (&self.party, current.number); let Some(given) = current.parties.get(party) else { @@ -583,9 +586,9 @@ impl Signer { if !given.keys.contains(&self.line()) { bail!( "version {number} doesn't name the key --key gives for {party}: only the keys it \ - names sign {party}'s key set and node list. A version naming its keys or its \ - list anew changes them: a party proposes it (continuum-party next, then \ - propose), and the parties pass it" + names sign {party}'s votes, proposals, key set and node list. A version naming \ + its keys or its list anew changes them: another party proposes it \ + (continuum-party next, then propose), and the parties pass it" ); } Ok(()) @@ -634,6 +637,7 @@ async fn vote( ) -> Result<()> { let counts = node.counts().await?; let current = current(&counts)?; + signer.named_by(¤t)?; let ballots = &counts["proposals"]; let ids = |hash: &Id, what: &str| -> Vec<Id> { ballots[hash.to_string()][what] @@ -995,10 +999,11 @@ mod tests { assert!(changed_by(&[], &[], &["c"]).is_err()); } - /// A key set or node list is signed with a key the current version names for its - /// party; another key, or a party the version doesn't have, is refused before signing. + /// Votes, proposals, key sets and node lists are signed with a key the current version + /// names for their party; another key, or a party the version doesn't have, is refused + /// before signing. #[test] - fn a_key_set_or_node_list_is_signed_with_a_key_the_version_names() { + fn what_only_a_versions_keys_sign_is_signed_with_one() { use super::{Signer, Signing}; use crate::federation::harness::{Party, Spec}; use crate::federation::version::Version; |
