buzz icon indicating copy to clipboard operation
buzz copied to clipboard

RFC: Support keyless operation via a pluggable signer

Open jrobotham-square opened this issue 3 months ago • 6 comments

Summary

Decouple an agent's identity from its signing key so buzz can run an agent without the secret key ever residing on the host. Introduce a signer abstraction with two implementations — a local signer (holds the key, today's behavior) and a remote signer (delegates signing to an external service; the host holds only the public key).

Motivation

Today both the CLI and the agent harness hard-require the private key to be present locally. Identity and key custody are therefore inseparable: to run an agent, its secret must live on the host.

There are deployment and security scenarios where you want the opposite — running an agent in an ephemeral, shared, or less-trusted environment while the signing key stays under separate custody. Centralized custody also makes key rotation and revocation possible without touching every host. None of this is achievable while the key is a mandatory local input.

A remote signer also unlocks a stronger deployment: hosts with no direct route to the relay, able to reach it only through the signer. Beyond defense in depth, this is what makes keyless operation enforceable rather than merely available — if a host can reach the relay directly, nothing prevents falling back to a locally held key; remove that direct path and the signer becomes the only way through, leaving no local-key shortcut. The signer then doubles as a single mediated egress point for policy, auditing, and revocation.

Proposal

Introduce a signer interface that separates the two concerns:

  • Identity (public key) — needed pervasively (mention detection, thread self-detection, channel discovery, author filters). This should require only the agent's public key.
  • Signing (secret key) — needed at a small number of well-defined sites. Route these through the signer interface.

The abstraction belongs in the shared client layer that every consumer builds on, so the CLI, the agent harness, and any other programmatic user of the library inherit keyless support from a single change rather than each solving it independently. Covering only one consumer doesn't achieve the goal — if an agent's actions route through any key-holding component, it isn't keyless.

Two implementations:

  • Local — holds the keypair; current behavior and the default.
  • Remote — delegates every operation that needs the secret to an external signer. The host holds only the public key plus whatever credential authorizes calls to that signer.

Selection is a startup/config-time choice (an agent runs as one or the other for its lifetime), not runtime-dynamic. Local is the default, so existing users see no change. Configuring a remote signer is opt-in and takes precedence — any local credentials are ignored.

What this requires (high level)

  • Make the private key optional; require only the agent public key for identity operations.
  • Funnel the secret-dependent operations through the signer interface: event signing, relay auth (NIP-42), payload encrypt/decrypt (NIP-44), request auth (NIP-98), and encrypted-storage address derivation.
  • Treat relay authentication as a control-flow choice, not just a different signer — a remote signer may authenticate the relay leg itself, so the host should be able to skip local auth rather than perform it.
  • Do not assume direct relay connectivity. Every relay-touching operation — reads included — must be routable through the signer, so a deployment can remove a host's direct relay access entirely and make the signer its only path out.
  • Make non-essential signed housekeeping (presence, typing, reactions, etc.) skippable or offloadable, so an agent can run without a local key even if those are unavailable.
  • Ensure no secret can leak to child processes via inherited environment.

Scope / non-goals

  • This issue covers the interface and making the key optional within buzz.
  • The remote signer implementation (the service that holds the key and how it authenticates callers) is out of scope and deliberately left to implementers — the interface should not assume a particular backend.
  • The relay protocol is unchanged. Whether signing happens locally, via an inline proxy, or via an out-of-band signing service, the relay just sees a normal client — it never needs to know a remote signer exists.

Open questions

  • The exact shape of the signer abstraction (trait vs enum) and how far it threads through the CLI vs the harness.
  • Whether the remote path is best modeled per-operation or as a single "sign this" primitive plus a few protocol-specific helpers.
  • When a remote signer is configured, whether a local key that is still present in the environment should be tolerated, warned about, or refused — a present-but-unused key still contradicts the keyless intent.

Related work

  • #6123 (service-to-service auth for the HTTP bridge) addresses the same underlying concern — keeping the Nostr private key out of the caller — but from the relay side: mapping a standard credential to a Nostr identity so non-Nostr services can use the bridge. This RFC is the client-side complement: the client stays Nostr-native and delegates signing to a remote signer. The two are complementary.
  • #6281 (BUZZ_RELAY_URL conflates connection target, Host, and signed relay tag) is relevant to routing relay traffic through the signer and to the NIP-42 signing site this RFC takes over.

jrobotham-square avatar Aug 21 '26 06:08 jrobotham-square

Worth noting NIP-46 as an alternative.

loganj avatar Aug 21 '26 14:08 loganj

poked at this a bit and it seems that even with keyless mode and an auto-signing proxy, we might need NIP-46 to support git signing and maybe other things like NIP-44 encryption.

loganj avatar Aug 21 '26 14:08 loganj

Strong +1 on the abstraction, and a data point for @loganj's NIP-46 suggestion that I think settles the direction: the repo already ships the vocabulary.

crates/buzz-core/src/pairing/types.rs:66-68 declares PayloadType::Bunker ("NIP-46 bunker connection string") and PayloadType::Connect ("nostrconnect:// URI"), and buzz-pairing-cli maps both to wire strings. So NIP-AB pairing can already transport a remote-signer handle end to end — there is simply no consumer: nothing in the tree knows what to do with a bunker string. A NIP-46 signer behind this RFC's interface is the missing consumer of a payload type that already exists, rather than a new protocol surface.

Measuring the blast radius before proposing anything: the secret key is required across ~20 files — 14 in buzz-cli, 7 in buzz-acp, 1 in buzz-ws-client. buzz-ws-client itself is only ~560 lines, so the trait lands in a small place but the callers are the real work. That's too much for one reviewable PR, so a slicing proposal:

  1. Introduce the signer interface, no behaviour change. Signer trait + LocalSigner in buzz-ws-client; every current signing site routes through it. Pure refactor, LocalSigner is the default, nothing observable changes.
  2. Make the secret optional on the identity path. Identity operations (mention detection, self-detection, author filters) take the pubkey only; absence of a secret becomes an error at the signing sites, not at startup.
  3. NIP-46 remote signer behind the trait, consuming the bunker string the pairing flow already carries.
  4. Config/CLI wiring, plus the open question you raise about a local key that is present but unused.

Three questions before I write anything:

  • Is NIP-46 the intended remote protocol, or do you want the interface to stay protocol-agnostic with NIP-46 as one implementation?
  • Trait or enum? A trait keeps out-of-tree signers possible; an enum keeps the set closed and avoids async_trait in the hot path.
  • Is this already being picked up internally? Happy to take slice (1) if it's useful and to stay out of the way if it isn't — I'd rather ask than duplicate.

bonpiedlaroute avatar Aug 22 '26 20:08 bonpiedlaroute

@bonpiedlaroute

Is NIP-46 the intended remote protocol, or do you want the interface to stay protocol-agnostic with NIP-46 as one implementation?

Protocol-agnostic interface, with NIP-46 as the intended primary remote implementation. The abstraction should just be "Local vs. remote signer" so nothing's hard-wired to one protocol — NIP-46 is the first backend we'd build against that interface, not the interface itself.

Trait or enum? A trait keeps out-of-tree signers possible; an enum keeps the set closed and avoids async_trait in the hot path

Instinct is to reuse nostr's existing NostrSigner trait (which Keys already implements) rather than roll our own trait or enum — a remote signer's just another impl.

Is this already being picked up internally? Happy to take slice (1) if it's useful and to stay out of the way if it isn't — I'd rather ask than duplicate.

Thanks for digging in - the slicing you proposed makes sense to me. I'm just checking in with some internal teams on whether it's already being picked up. Can get back to you in the next few days before you sink time into it.

jrobotham-square avatar Aug 24 '26 07:08 jrobotham-square

I think the existing pairing work and the human login case sharpen this RFC in a few useful ways.

First, the repo already reserves a bootstrap envelope for NIP-46. crates/buzz-core/src/pairing/types.rs declares PayloadType::Bunker and PayloadType::Connect, and NIP-AB specifies their wire formats. Nothing currently produces or consumes those variants, so this is not remote-signing support yet, but it does mean Buzz-to-Buzz pairing was deliberately designed to carry a remote-signer handle without manual copy/paste.

Second, I think this RFC contains two separable abstractions:

  1. A cryptographic signer: public key, NIP-01 event signing, and NIP-44 encrypt/decrypt. Reusing nostr::NostrSigner looks like the right starting point, and NIP-46 is the natural first remote implementation.
  2. A relay transport/gateway: connect, authenticate, subscribe, query, and publish when the host has no direct relay route.

NIP-46 solves the first but does not by itself proxy relay reads. Keeping those boundaries explicit would avoid asking a signer trait to also become a network client, while preserving the RFC's stronger mediated-egress deployment.

The human case in #2700 should reuse the same signer boundary. PR #1758 was closed in favor of a comprehensive design for both humans and agents, including remote bunkers and live hardware signing, but this RFC is currently framed around agents. The threat models and UX differ, so they need not ship as one feature, but implementing independent signer foundations would repeat the most security-sensitive work.

Two constraints seem worth making explicit:

  • NIP-42 has a relay-side five-second authentication deadline. Remote signing therefore needs an end-to-end latency acceptance test. #4498's later investigation does not establish that NIP-46 would miss it: failing cold starts were observed with AUTH completing in 197–350 ms, and the original auth-race diagnosis was subsequently walked back. I would measure before adding a second HTTP signing transport solely for latency.
  • Standard NIP-46 cannot sign NIP-GS git objects. NIP-GS signs a domain-separated raw digest, while NIP-46 exposes sign_event, not raw-digest signing. That should be an explicit v1 limitation rather than a hidden blocker. Safer follow-ups include a scoped Git identity/NIP-OA path or a domain-specific sign_git_object operation; a general raw-digest oracle would bypass event-kind policy.

Suggested slicing:

  1. Route existing cryptographic operations through NostrSigner, preserving local behavior.
  2. Separate identity/pubkey state from local secret-key storage.
  3. Add NIP-46 plus connection persistence, permission display, revocation/logout, and failure handling.
  4. Add bootstrap UX: standard NIP-46 QR/deep links for ecosystem interoperability, with NIP-AB as an optional Buzz-to-Buzz convenience.
  5. Design the no-direct-relay gateway separately against the RFC's stronger egress requirements.

Keycast is one useful compatibility target because it already implements NIP-46 and the required NIP-44 operations, but it should fit as one provider rather than defining the interface. That keeps hardware, self-hosted, and third-party signers equally viable.

NotThatKindOfDrLiz avatar Aug 24 '26 15:08 NotThatKindOfDrLiz

Follow-up to my earlier comment, now that #6742 has landed. If I read it right, signing and the auth/encryption NIPs stay "inside whoever holds the key", so the broker host becomes the key holder. That is the part I have been working on, and the results may be useful on the host side.

nostr-remote-signer is a NIP-46 vault for agents: keys sealed at rest (envelope encryption, passphrase or AWS KMS), a default-deny policy on methods and event kinds, per-agent tokens with live revocation, and one journal line per decision (metadata only).

The new part is attested key release on AWS Nitro Enclaves. The vault runs in an enclave, and the KMS key policy allows kms:Decrypt only with an attestation document whose PCR0 is the vault image's (kms:RecipientAttestation:ImageSha384). On EC2, root on the parent instance was refused, the same image in debug mode was refused, an account administrator was refused, and the enclave opened its keys and signed. Transcript, key policy, measurements and CloudTrail events: docs/proof/2026-10-15.

Two findings that may carry over to a broker host:

  • QEMU's nitro-enclave machine runs the whole path without AWS, except AWS's signature check, against a fake KMS that reads the real (unsigned) attestation documents. Handy for CI.
  • The default key policy grants kms:* to the account, Decrypt included, so IAM can grant Decrypt without any attestation. It has to be removed for the condition to mean anything.

Limits: the enclave build is not reproducible yet, and the account's administrators can still rewrite the key policy (CloudTrail records it).

I agree with the per-operation argument in #6742: a NIP-46 policy by event kind is coarser than named operations. Custody would sit underneath the broker, not replace it.

Is the broker host's key custody planned or already in progress? If an enclave-backed signer behind the broker would help, I am happy to open a separate issue rather than stretch this one.

bonpiedlaroute avatar Oct 15 '26 21:10 bonpiedlaroute