Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .claude/skills/sc-cli-reference/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,17 @@ cargo run --bin sc -- secret rotate <name> --identity <key> # same value, fre
cargo run --bin sc -- escrow set <pubkey-or-name> # break-glass recovery key
# (replace-with-one sugar, P17)
bash demo/run_lifecycle_demo.sh # rotation + escrow proof
cargo run --bin sc -- rewrap [--identity <key>] [--dry-run] # one-commit bulk reseal of all
cargo run --bin sc -- rewrap [--identity <key>] [--dry-run] [--rotate] # one-commit bulk reseal of all
# secrets + protected wrap lists to current
# recipient/escrow sets (skip-and-report;
# exits 1 when entries were skipped); also
# eagerly re-seals any still-CONVERGENT (pre-P33)
# protected blob RANDOMIZED (P33) — so a rewrap
# that upgrades content is no longer tree-identical,
# while a second rewrap over an all-randomized tip
# converges back to policy-only
# converges back to policy-only; --rotate also re-seals
# every protected blob under a FRESH key (ADR-0051), so
# a recipient with an old wrap cannot open the tip
cargo run --bin sc -- escrow add <pubkey-or-name> # append a break-glass key (list)
cargo run --bin sc -- escrow remove <id-or-name>
cargo run --bin sc -- escrow show # lists all escrow keys
Expand Down
8 changes: 5 additions & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,17 @@ is recovered via `--identity` and re-sealed. Recipients default to the
secret's current set (reverse `recipient_id` lookup against
`.sc/recipients.toml`), overridable with `--to`.

Rotation is **secrets-only**: pre-P33 protected paths used convergent
`sc secret rotate` rotates secrets. Protected paths could not be rotated before randomized sealing (P33): they used convergent
encryption (`DEK = HKDF(BLAKE3(plaintext))`), so a recipient who checked the
file out could re-derive the key — "rotating" a convergent path's DEK is either
dedup-breaking or security-meaningless. Path lifecycle stays on recipient
dedup-breaking or security-meaningless, so their lifecycle stayed on recipient
re-wrap (`grant`/`revoke`). `sc secret revoke` remains metadata-only and now
hints to run `rotate` for the actual cryptographic cutover. (**P33/ADR-0043:**
the security-meaningless objection dissolves for **randomized** content — a
random DEK is independent of the plaintext — so a genuine rotate-for-paths
cutover is now coherent and recorded as an unlocked follow-on, not yet built.)
cutover is coherent and is built as `sc rewrap --rotate` (ADR-0051): it
re-seals every protected blob under a fresh key, where a plain `sc rewrap`
only replaces wrap lists and keeps the key.)

`sc escrow set <pubkey-or-name>` / `sc escrow show` configure a single
break-glass recipient key (`[escrow]` in `.sc/recipients.toml`) that is
Expand Down
9 changes: 6 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,17 @@ transport-adjacent. The rest, imperatively:
their prior wrap list. Use `sc grant` (or `sc rewrap`) to add a recipient to
existing content. Fails safe: under-grants, never over-grants.
- **`sc rewrap` is content-changing when it upgrades** still-convergent blobs
to randomized; only a rewrap over an all-randomized tip is policy-only.
to randomized, or with `--rotate`; only a plain rewrap over an all-randomized
tip is policy-only.
- **`.sc/local-key` and the per-checkout protected caches
(`.sc/protected-cache`, `.sc/ws/cache-<i>`) are never committed and never
transferred.** Cache saves are best-effort and ordered after ref moves; a
cache failure may cause a spurious re-seal but never incorrectness.
- **Revoke is standing-only.** A revoked recipient keeps decrypting ciphertext
sealed before the revoke (they hold the old wraps); cryptographic cutover is
`sc rewrap` at the tip plus rotating the underlying credential.
`sc rewrap --rotate` at the tip (fresh key per protected blob; a plain
`sc rewrap` only replaces wrap lists) plus rotating the underlying credential.
History keeps the old ciphertext (rotation is not erasure).
- **The oplog is local-only** (like a reflog) — it never travels over
fetch/push/clone. `sc undo` twice = redo; undoing the initial commit is
refused.
Expand Down Expand Up @@ -260,7 +263,7 @@ transport-adjacent. The rest, imperatively:
Deferred work is tracked in **`ROADMAP.md` → Deferred** (single source of
truth — do not re-list items here). Notable standing entries: transparent
lazy-fetch for partial clones, per-case gap-tolerant merge/replay on partial
clones, rotate-for-paths (unlocked by P33, recorded not built), fd/stdin
clones, fd/stdin
secret injection, CA-path validation alongside TOFU pinning, and pin-management
UX (`sc tls`).

Expand Down
9 changes: 3 additions & 6 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,12 +778,9 @@ scale-&-reach horizon):
it: all new protected content seals under a fresh random DEK + nonce
(dual-read for pre-P33 convergent history; `sc rewrap` upgrades a tip on
demand). Moved from deferred to Done above.
- **Rotate-for-paths (P33 follow-on).** ADR-0019 declared per-path DEK rotation
"security-meaningless" under convergent encryption. That objection dissolves
for randomized content (a random DEK is independent of the plaintext), so a
`sc protect … rotate`-style genuine per-path cryptographic cutover — the
protected-path analogue of `sc secret rotate` — is now coherent. Recorded in
ADR-0043, not built.
- **Rotate-for-paths — shipped (ADR-0051).** `sc rewrap --rotate` re-seals every
protected blob at the tip under a fresh DEK (the path analogue of `sc secret
rotate`); history keeps the old ciphertext (rotation is not erasure).
- **`sc rewrap` on partial clones — refused (P37).** `Repo::rewrap` calls
`refuse_on_partial`; a paths-only/streaming rebuild that would lift the
refusal remains a possible follow-on.
Expand Down
29 changes: 25 additions & 4 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ enum Cmd {
/// Report what would be re-wrapped without committing.
#[arg(long)]
dry_run: bool,
/// Also re-seal every protected file under a fresh key, so a
/// recipient revoked earlier cannot open the tip with an old wrap.
/// Changes ciphertext ids (and the root tree); history is untouched.
#[arg(long)]
rotate: bool,
},
/// Revert the last operation (run again to redo).
Undo,
Expand Down Expand Up @@ -1038,7 +1043,11 @@ fn main() -> Result<()> {
include_encrypted,
} => run_export(to, r#ref, include_encrypted),
Cmd::Escrow { op } => run_escrow(op),
Cmd::Rewrap { identity, dry_run } => run_rewrap(identity, dry_run),
Cmd::Rewrap {
identity,
dry_run,
rotate,
} => run_rewrap(identity, dry_run, rotate),
Cmd::Undo => run_undo(),
Cmd::Oplog => run_oplog(),
Cmd::Sign { r#ref, identity } => run_sign(&r#ref, identity),
Expand Down Expand Up @@ -4246,7 +4255,7 @@ fn run_gc(prune_expire: &str) -> Result<()> {
Ok(())
}

fn run_rewrap(identity: Option<PathBuf>, dry_run: bool) -> Result<()> {
fn run_rewrap(identity: Option<PathBuf>, dry_run: bool, rotate: bool) -> Result<()> {
let repo = open_repo()?;
let sk = load_identity(identity)?;
let recipients_path = repo.layout().dot_sc.join("recipients.toml");
Expand All @@ -4267,7 +4276,7 @@ fn run_rewrap(identity: Option<PathBuf>, dry_run: bool) -> Result<()> {
known.push(me);
}

let report = repo.rewrap(&sk, &escrows, &known, dry_run)?;
let report = repo.rewrap_with(&sk, &escrows, &known, dry_run, rotate)?;
Comment thread
tonibergholm marked this conversation as resolved.
Resolved
let verb = if dry_run { "would rewrap" } else { "rewrapped" };
println!(
"{verb} {} secret(s), {} protected blob(s)",
Expand All @@ -4285,6 +4294,13 @@ fn run_rewrap(identity: Option<PathBuf>, dry_run: bool) -> Result<()> {
report.blobs_resealed
);
}
if report.blobs_rotated > 0 {
let rotate_verb = if dry_run { "would rotate" } else { "rotated" };
println!(
"{rotate_verb} {} protected blob(s) under fresh keys",
report.blobs_rotated
);
}
if let Some(id) = &report.commit {
println!("commit: {}", id.short());
}
Expand All @@ -4293,7 +4309,12 @@ fn run_rewrap(identity: Option<PathBuf>, dry_run: bool) -> Result<()> {
for (entry, reason) in &report.skipped {
eprintln!(" {entry}: {reason}");
}
eprintln!("re-run `sc rewrap` with an identity that can open them to complete the sweep");
let again = if rotate {
"sc rewrap --rotate"
} else {
"sc rewrap"
};
eprintln!("re-run `{again}` with an identity that can open them to complete the sweep");
}
eprintln!(
"note: rewrap cuts the live tip only — snapshots already in history keep \
Expand Down
Loading
Loading