Skip to content

noise_sv2: let a server present a pre-issued certificate #2437

Open

Description

@plebhash

Problem

in its early development stages, SRI's noise_sv2 made the KISS decision of making server static key ephemeral... every session leverages RNG to create a new static key, and a new throw-away certificate is signed

moreover, the application layer of SRI is currently structured in a way where authority keypairs are written into config.toml and deployed on the server (which is not a good idea for production)

all of that is still true on SRI today

this oversimplification was practical for early development, but now it might be nudging implementers in a direction where their custody expectations around authority keys might be shaped by what SRI does today, not by what the protocol was designed for

while ephemerally generating static keys for every handshake is not violating the spec as-is, I don't think it is good practice for production systems

static keys do deserve "cheap" rotation, but making them ephemeral pushes authority key to a "hot" position where it doesn't belong

looking at it from a pure protocol design perspective:

  • ephemeral keys are meant to be rotated on every session
  • static keys are meant to be hot, and periodically rotated (with new signed certificates)
  • authority keys are meant to be kept off the internet-facing server (offline, HSM, or an internal signing service), and only ever touched when new certificates need to be signed... rotation is expensive by design

Spec PR sv2-spec#234 (at a0a32bd) documents the intended key management in a new §4.8. §4.8.1: "The authority private key SHOULD therefore be kept off internet-facing servers [...] An internet-facing server holds only its static key and a certificate over it, issued where the authority private key is kept and loaded by the server. [...] Outside development and testing, a server SHOULD NOT sign certificates at handshake time, nor generate a new static key for every connection, since such a key cannot be certified in advance." §4.8.3: "Certificates SHOULD have short validity periods and be renewed automatically, each renewal certifying a new static key rather than extending the old one." SRI cannot follow either today.

Impact

Any host that accepts Noise connections (Pool, JDS, JDC's downstream listener) holds the authority private key in memory and on disk. A compromise of one internet-facing server leaks the key that lets an attacker impersonate the operator to every client, for as long as any client still trusts that key, and there is no revocation (spec §4.8.1, §4.8.2).

Certificate validity is whatever the server chooses at handshake time, so nothing bounds the lifetime of a leaked static key except cert_validity_sec on the same compromised host. Operators cannot issue short-lived certificates from a separate signing machine, nor renew them without restarting the server.

Because the only way to run a server is with the authority secret in its config, the shared test secret shipped in config examples is reused in deployments (sv2-apps#784), and the secret-at-rest problems in sv2-apps#446 and sv2-apps#834 apply to every server host instead of one signing machine.

Expected outcome

  • a new Responder constructor taking a static keypair plus a pre-signed certificate, with step_1 sending that certificate verbatim instead of signing a new one
  • all the risks associated with the old Responder constructor very well documented

Activity

  1. Christopherdominic commented on Oct 28, 2026

    @Christopherdominic
    Contributor

    @plebhash I'd like to work on this. Since #2426 reworks the certificate verification path in initiator.rs and signature_message.rs, should I wait for it to land and build on top of it (so both breaking changes can share one noise_sv2 major bump), or would you prefer to keep this one yourself? Happy to split it as well, e.g. the pre-issued-certificate Responder first, then the multi-key Initiator.

  2. changed the title [-]`noise_sv2`: let a server present a pre-issued certificate, and a client trust several authority keys[/-] [+]`noise_sv2`: let a server present a pre-issued certificate[/+] on Oct 30, 2026
  3. plebhash commented on Oct 30, 2026

    @plebhash
    MemberAuthor

    @Christopherdominic thanks for your interest but this is a sensitive issue, and we need it to be solved by experienced contributors.

  4. plebhash commented on Oct 30, 2026

    @plebhash
    MemberAuthor

    note: multikey proposal from stratum-mining/sv2-spec#234 is now unlikely to move forward, so I'm reducing the scope here so that we only fix the Responder constructor to allow for cold authority key

  5. plebhash commented on Nov 3, 2026

    @plebhash
    MemberAuthor

    here's some potential approaches for how we can shape UX on the sv2-apps companion:

    environment variables

    server config.toml:

    # no authority_public_key
    # no authority_secret_key
    # no cert_validity_sec
    #
    # the server reads the static key and certificate from the environment at startup.
    # if set, the environment variables take precedence over active_static_key (see below).
    # if neither is present, the server refuses to start.
    
    # rest of the config file
    ...

    environment, e.g. a systemd EnvironmentFile= or a docker --env-file:

    # the server's static private key
    SV2_STATIC_PRIVATE_KEY=24Zfqe5i5LQVc8yV6okoMpiQn7DohfxTBRJSgBKeH65oS6Gtkd
    
    # the corresponding certificate as one opaque bs58check string
    #
    #   version (2 bytes) || valid_from (4 bytes) || not_valid_after (4 bytes) || schnorr signature (64 bytes)
    #
    # the validity window travels inside it, which is why there is no cert_validity_sec anywhere.
    #
    # this one:
    # - version: 0
    # - valid_from: 2026-10-08T23:00:00Z (one hour before rotation, so the new certificate is valid the moment it goes live)
    # - not_valid_after: 2026-10-10T01:00:00Z (one hour after the next rotation, so a late cron doesn't break handshakes)
    # - signed by authority pubkey: 9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72
    SV2_CERTIFICATE=11Bq97W2YjA6HzQsudhPAFE93sqF6b23Uuo7gWvZY5HQH4U6f5iU7cuv5YPM2HKJgDZXZRoMR6t43aJWBRLjibkFqvHuWj8LTArMrmLSVq
    
    # optional authority pubkey for sanity checking
    #
    # if present, the server verifies the certificate against it at load time and refuses to start on mismatch,
    # so the error surfaces early instead of as failed handshakes at runtime.
    SV2_AUTHORITY_PUBLIC_KEY=9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72

    a running process cannot see changes to its own environment, so here rotation is a restart:

    # written by the same job that signed the new certificate
    $ cp key_2.env /etc/sv2/static_key.env
    $ systemctl restart sv2-pool

    active_static_key.toml + symlinks

    server config.toml:

    # no authority_public_key
    # no authority_secret_key
    # no cert_validity_sec
    
    # path to a standalone file holding the active static private key and its certificate.
    # only used when the environment variables above are not set.
    #
    # for rotation: no app restart, no reload of config.toml.
    #
    # ongoing connections are unaffected by rotation.
    active_static_key = "./static_keys/active_static_key.toml"
    
    # rest of the config file
    ...

    server active_static_key.toml, same fields as the environment variables:

    static_private_key = "24Zfqe5i5LQVc8yV6okoMpiQn7DohfxTBRJSgBKeH65oS6Gtkd"
    certificate = "11Bq97W2YjA6HzQsudhPAFE93sqF6b23Uuo7gWvZY5HQH4U6f5iU7cuv5YPM2HKJgDZXZRoMR6t43aJWBRLjibkFqvHuWj8LTArMrmLSVq"
    
    # optional, same sanity check at load time
    authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"

    in order to enable atomic updates for rotation, active_static_key.toml is a symlink on disk.

    new files are written for rotation, and symlink is updated.

    for example, imagine I'm rotating static keys every 24h:

    $ ls -l static_keys/
    total 12
    lrwxrwxrwx 1 plebhash plebhash  10 Oct  8 23:55 active_static_key.toml -> key_2.toml
    -rw-rw-r-- 1 plebhash plebhash 320 Oct  6 23:55 key_0.toml
    -rw-rw-r-- 1 plebhash plebhash 320 Oct  7 23:55 key_1.toml
    -rw-rw-r-- 1 plebhash plebhash 320 Oct  8 23:55 key_2.toml

    ideally key_0.toml and key_1.toml could be deleted, but I left them in the example for clarity.

    every time the server needs to perform a new handshake, stratum-apps::network_helpers reads active_static_key.toml and instantiates a new noise_sv2::Responder from its static_private_key + certificate.

    tradeoffs

    • with environment variables, rotation drops ongoing connections, unless the restart is a rolling one across several instances. the symlink approach never does.
    • with environment variables, the secret lives wherever the deployment already keeps secrets (systemd EnvironmentFile=, docker/k8s secrets), not in the app's own directory, and no file watching or re-reading per handshake is needed.

    so env variables fit orchestrated deployments where a rolling restart per rotation is routine anyway, while the symlink fits a single long-running process.

  6. self-assigned this
    on Nov 9, 2026
  7. 29 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions