diff options
| -rw-r--r-- | docs/guides/federation/proposing-and-voting.md | 3 | ||||
| -rw-r--r-- | src/federation/party.rs | 27 |
2 files changed, 18 insertions, 12 deletions
diff --git a/docs/guides/federation/proposing-and-voting.md b/docs/guides/federation/proposing-and-voting.md index 08fead9..9ec014b 100644 --- a/docs/guides/federation/proposing-and-voting.md +++ b/docs/guides/federation/proposing-and-voting.md @@ -59,7 +59,8 @@ The client proposes only a version changing the current one, as a version must ( is on the current version, and its hash is the version's: the node shows it under that hash (`proposals` in `GET /events/counts`), with the events proposing it. Several parties proposing the same version make one proposal. The key a party proposes -and votes with is one the current version names for it, not one of its key set. +and votes with is one the current version names for it, not one of its key set: the +client checks that before it signs, and records nothing otherwise. A proposal lapses, with the votes on it, once its version isn't current any more: when another proposal on it passed. 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; |
