aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/guides/federation/keys.md10
-rw-r--r--share/bash-completion/completions/continuum-party8
-rw-r--r--src/federation/party.rs36
3 files changed, 28 insertions, 26 deletions
diff --git a/docs/guides/federation/keys.md b/docs/guides/federation/keys.md
index f21171f..dcac7a2 100644
--- a/docs/guides/federation/keys.md
+++ b/docs/guides/federation/keys.md
@@ -19,15 +19,15 @@ So keep the keys a version names apart, offline, on one machine with the party's
```sh
ssh-keygen -t ed25519 -N '' -f laptop.key
continuum-party --node http://tv:secret@localhost:3000 --key tv.key --record tv.record \
- keys --set "$(cat laptop.key.pub)" "$(cat desk.key.pub)"
+ keys --set laptop.key.pub desk.key.pub
continuum-party --node http://tv:secret@localhost:3000 --key laptop.key \
--record tv.record write home/tv/motd '"from the laptop"'
```
-Each key goes as one argument, an `authorized_keys` line; its comment is left out.
-`--set` writes the set whole; `--add` and `--remove` write it as it counts at the node,
-with those keys added or taken off (`keys --add "$(cat phone.pub)"`); `keys` alone shows
-it. A set left empty, so that none of the party's writes count, is written with
+Each key goes as one argument, an `authorized_keys` line, or a file of such lines (a
+`.pub` file); comments are left out. `--set` writes the set whole; `--add` and `--remove`
+write it as it counts at the node, with those keys added or taken off (`keys --add
+phone.pub`); `keys` alone shows it. A set left empty, so that none of the party's writes count, is written with
`--force` only. A set holds up to 16 keys, signed with a key the current version names
for the party, which the client checks first. A node voting by itself keeps a key its version names on that
node (`--store-vote-key`), an Ed25519 key in a file: one stolen there votes for the
diff --git a/share/bash-completion/completions/continuum-party b/share/bash-completion/completions/continuum-party
index e79eee2..057e8a5 100644
--- a/share/bash-completion/completions/continuum-party
+++ b/share/bash-completion/completions/continuum-party
@@ -139,8 +139,12 @@ _continuum_party()
_continuum_party_words "$(_continuum_party_features)"
return
;;
- --node | --token | --unset | --nodes | --founder | --rule | --at | --add | --remove | \
- --set)
+ --add | --remove | --set)
+ # Keys, or files of them; nodes by ID.
+ [[ $command == keys ]] && _continuum_party_files
+ return
+ ;;
+ --node | --token | --unset | --nodes | --founder | --rule | --at)
return
;;
esac
diff --git a/src/federation/party.rs b/src/federation/party.rs
index 55ad5a5..492a76b 100644
--- a/src/federation/party.rs
+++ b/src/federation/party.rs
@@ -10,10 +10,11 @@
//! FILE`, from the file the store's swarm starts from, for a party that never voted in
//! it: the record casts on every version, the first too;
//! * `write PATH VALUE`: writes `VALUE` (JSON) at `PATH`;
-//! * `keys`, `nodes`: the party's key set (`authorized_keys` lines, each one argument,
-//! their comments left out) or node list (node IDs) as it counts at the node, one a line
-//! (`--list`); or written: with `--add` and `--remove`, the set or list as it counts,
-//! changed; with `--set`, set whole. One left empty is written with `--force` only;
+//! * `keys`, `nodes`: the party's key set (`authorized_keys` lines, each one argument, or
+//! files of them, their comments left out) or node list (node IDs) as it counts at the
+//! node, one a line (`--list`); or written: with `--add` and `--remove`, the set or list
+//! as it counts, changed; with `--set`, set whole. One left empty is written with
+//! `--force` only;
//! * `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 a party may back it
@@ -131,7 +132,7 @@ fn command() -> Command {
"The party's key set as it counts at the node, or written with keys added, \
taken off, or set whole",
)
- .args(changing("KEY", "keys", "key set"))
+ .args(changing("KEY|FILE", "keys", "key set"))
.group(changes()),
)
.subcommand(
@@ -843,16 +844,7 @@ pub(crate) async fn main() -> Result<()> {
}
("keys", sub) => {
// As the federation spells a key: without the line's comment.
- let spelled = |name: &str| {
- strings(sub, name)
- .iter()
- .map(|line| {
- Key::parse(line)
- .map(|key| key.line())
- .map_err(|why| anyhow!("{line:?}: {why}"))
- })
- .collect::<Result<Vec<String>>>()
- };
+ let spelled = |name: &str| keys_given(&strings(sub, name));
let counts = node.counts().await?;
signer.named_by(&current(&counts)?)?;
let party = &signer.party;
@@ -1059,8 +1051,17 @@ async fn proposal_version(node: &Node, counts: &JsonValue, proposal: Id) -> Resu
/// The keys `given` names, as the federation spells them (without comments): each an
/// `authorized_keys` line itself, or a file of such lines, blank ones and `#` comments
-/// left out; none twice.
+/// left out; none twice, one at least.
fn key_lines(given: &[String]) -> Result<Vec<String>> {
+ let lines = keys_given(given)?;
+ if lines.is_empty() {
+ bail!("no key given: a party signs with the keys a version names");
+ }
+ Ok(lines)
+}
+
+/// As `key_lines`, none too.
+fn keys_given(given: &[String]) -> Result<Vec<String>> {
let mut lines: Vec<String> = Vec::new();
for item in given {
let found = match Key::parse(item) {
@@ -1084,9 +1085,6 @@ fn key_lines(given: &[String]) -> Result<Vec<String>> {
lines.push(line);
}
}
- if lines.is_empty() {
- bail!("no key given: a party signs with the keys a version names");
- }
Ok(lines)
}