Zcash ZIPs
Theme
Appearance
Contents

ZIP 270

Key Rotation for Tracked Signing Keys

Draft

Terminology

The key words “MUST”, “MUST NOT”, “SHOULD”, and “MAY” in this document are to be interpreted as described in BCP 14 1 when, and only when, they appear in all capitals.

The term “full validator” in this document is to be interpreted as defined in the Zcash protocol specification 2.

The term “network upgrade” in this document is to be interpreted as described in ZIP 200. 3

The character § is used when referring to sections of the Zcash Protocol Specification. 4

The terms “v7 transaction”, “bundle”, “effecting data”, and “authorizing data” are to be interpreted as described in ZIP 248. 5

Abstract

This ZIP describes a mechanism for keys registered at the consensus level to be rotated, or migrated between supported signing protocols.

A tracked signing key is a public key that is held in the global chain state under an identifier that never changes. Each identifier has an application key, which authorizes the actions of the ZIP that registered it (such as disbursing from a fund, or issuing an asset), and a rotation key, which authorizes replacing either of the two.

This ZIP defines a bundle for the v7 transaction format that carries key rotation operations. An operation states the key state that it modifies, and is signed by both the current rotation key and the new key.

Tracked signing keys, and every rotation of them, are public.

Motivation

Most Zcash funds are controlled by “off-chain” signing keys, where a user controls some signing key authorizing spends. The consensus rules allow the keyholder to rotate these keys at any time, by sending funds to a new address (possibly in a different wallet).

In a few recent ZIPs 6 7, a second category of key management has been defined: consensus-tracked signing keys. Whether they are initially defined by consensus rules in a network upgrade or registered via a trust-on-first-use mechanism, from that point onward the consensus rules enforce that a specific key is used to authorize relevant on-chain actions.

There are several reasons why the ability to rotate these keys is necessary:

Funding Stream addresses are also hard-coded into consensus, but rotation of these addresses is outside the scope of this ZIP.

Two facilities define, or are proposed to define, authorization keys in consensus:

It would be beneficial for this mechanism to support rotation of both of these key types, and any similar key types defined by future facilities of the Zcash consensus protocol.

Use cases

Small-scale single issuer (e.g. toy usage)

ZSA asset bridges

Issuer merging

An issuer can choose to transfer all of their controlled assets to another issuer, by creating a single key rotation bundle that:

Privacy Implications

The mechanisms defined in this ZIP are only suitable for rotation of keys that are publically visible in the state of the consensus protocol.

Every key rotation operation is public. It links the new key to the keys that it replaces, and to every action authorized under the same identifier. The fee paid by its transaction links the key holders to the funds that paid it, unless those funds are shielded.

A threshold signature scheme that produces ordinary signatures, such as FROST 8, reveals neither the threshold nor which of the parties signed.

Requirements

Non-requirements

Specification

Tracked signing keys

A tracked signing key is a public key that is held in the global chain state, and that full validators use to validate signatures in any transaction that refers to it. These are distinct from untracked (normal) signing keys, which are provided by transactions themselves, and are only used within the context of validating that single transaction.

Each tracked signing key has an associated protocol_type, identifying the signing protocol that the key is for. Tracked signing keys MUST use a protocol type defined in this ZIP. The encoding TrackedKey of a tracked signing key is its protocol_type as a single byte, followed by its public key.

The following protocol types are currently valid in consensus:

protocol_type Signing protocol Public key Signature
0x00 BIP 340 12 32 bytes 64 bytes
0x01 RedPallas, as instantiated for Orchard spend authorization 13 32 bytes 64 bytes

A signature over a 32-byte message is valid for a tracked signing key if:

Protocol types, and the key usages defined below, are allocated by the ZIP Editors. A ZIP that needs a new one specifies it as a modification to the corresponding table in this ZIP.

Key usages and key pointers

Each tracked signing key has an associated key_usage, specifying which sub-protocol (within the overall Zcash protocol) it is used within, and a key identifier key_id that identifies it within that usage. The pair (key_usage, key_id) is a key pointer. A key pointer does not change when its keys are rotated.

The set of defined key usages for tracked signing keys is as follows:

key_usage Defining ZIP key_id
0x01 ZIP 272: Consensus accounts 9 The 32-byte consensus_account_id
0x02 ZIP 227: ZSA issuance 7 The 33-byte issuer

key_id is treated as an opaque byte sequence within the context of this ZIP. The ZIP that defines a key usage specifies:

That ZIP SHOULD require a transaction containing a signature by an application key to state the key pointer and the key that the signature was made for, with a consensus rule that the stated key is the current application key. The signature can then be validated without access to chain state.

Key state

The global chain state is extended with a map from key pointers to key states. A key state is a pair of tracked signing keys:

The two MAY be the same key, and the rotation key MAY be of any protocol type. The encoding KeyState of a key state is the encoding of application_key followed by that of rotation_key.

An entry is added to this map only by Key registration, and is modified only by Key rotation operations. Entries are never removed.

Key registration

Registering a key pointer adds an entry for it to the map of key states. Registration MUST NOT replace an existing entry.

The ZIP that defines a key usage specifies how its key pointers are registered, in one or both of the following ways:

Key rotation bundle

This ZIP defines the key rotation bundle, a bundle type for the v7 transaction format. 5 Its bundle type identifier \(\mathsf{KeyRotationBundleId}\) is to be allocated in the bundle type registry of ZIP 248 14, and its only variant is bundleVariant = 0. The bundle moves no value, and so has no entry in mValuePoolDeltas.

A transaction that has an entry for the key rotation bundle in mEffectBundles MUST also have one in mAuthBundles.

Key rotation effecting data

Bytes Name Data Type Description
varies nKeyRotations compactSize The number of key rotation operations. MUST be nonzero.
varies vKeyRotations KeyRotation[nKeyRotations] The key rotation operations.
KeyRotation
Bytes Name Data Type Description
1 keyUsage uint8 The key_usage of the key pointer.
varies keyId byte[] The key_id of the key pointer, of the length specified for keyUsage.
1 keyRole uint8 The key to be replaced: 0x00 for application_key, or 0x01 for rotation_key.
varies prevState KeyState The key state that this operation modifies.
varies newKey TrackedKey The key that replaces the one selected by keyRole.

keyUsage MUST be a defined key usage, keyRole MUST be 0x00 or 0x01, and the protocol_type of each of the three keys MUST be a defined protocol type. With the protocol types defined above, a TrackedKey is 33 bytes and a KeyState is 66 bytes.

Key rotation authorizing data

Bytes Name Data Type Description
varies vKeyRotationAuths KeyRotationAuth[nKeyRotations] The signatures for each operation, in the same order as vKeyRotations.
KeyRotationAuth
Bytes Name Data Type Description
varies rotationAuthSig TrackedKeySignature A signature by the rotation_key of prevState, authorizing the operation.
varies newKeySig TrackedKeySignature A signature by newKey, showing that its holder can sign with it and consents.
TrackedKeySignature
Bytes Name Data Type Description
varies sizeSighashInfo compactSize The size in bytes of sighashInfo.
sizeSighashInfo sighashInfo byte[sizeSighashInfo] The sighash variant and associated information, as defined in ZIP 248.
varies signature byte[] A signature, of the length specified for the protocol_type of the key it is to be valid for.

Sighash variant 0 is the only variant defined for the key rotation bundle, and its associatedData is the empty byte string. Both signatures in vKeyRotationAuths[i] are over the digest defined in ZIP 248, ‘Variant 0 Signature Digest’ 15, with \(\mathsf{bundleType} = \mathsf{KeyRotationBundleId}\kern-0.05em\textsf{,}\) bundleVariant = 0, and signature_context set to the two-byte unsigned little-endian encoding of \(i\kern-0.05em\textsf{.}\)

Key rotation digests

The bundle_effects_digest of the key rotation bundle is a BLAKE2b-256 hash of the encodings of the elements of vKeyRotations, concatenated in order. The personalization field of this hash is set to:

"ZTxIdKeyRot_Hash" (1 underscore character)

The bundle_auth_digest of the key rotation bundle is a BLAKE2b-256 hash of the encodings of the elements of vKeyRotationAuths, concatenated in order. The personalization field of this hash is set to:

"ZTxAuthKeyRoHash"

Key rotation operations

Full validators process the key rotation bundle of a transaction after its other bundles. Those bundles are therefore validated against the key states as they were before the transaction’s own key rotations, and a key pointer registered by a transaction can be rotated by the same transaction.

The operations of a key rotation bundle are processed in order. For the operation vKeyRotations[i], a full validator MUST reject the transaction unless all of the following hold:

  1. The key pointer (keyUsage, keyId) has an entry in the map of key states, and that entry is equal to prevState.
  2. The signature in rotationAuthSig is valid for the rotation_key of prevState.
  3. The signature in newKeySig is valid for newKey.
  4. If keyRole is 0x00, the protocol type of newKey is one that the key usage permits for the application key.

It then replaces the key selected by keyRole in that entry with newKey.

Changes to ZIP 248

In the section ‘v7 Transaction Bundle Type Registry’ 14, add the following row, and remove the row for key rotation from ‘Potential Future Bundle Types’:

BundleType BundleVariant mValuePoolDeltas mEffectBundles mAuthBundles Defining ZIP Bundle kind
TBD 0 ❌ ✅ ✅ ZIP 270 Key rotation

Rationale

Rationale for the key state

Key states are looked up only by key pointer, never by key, so a full validator needs no index from keys to the key pointers that use them and no links between key states. A key that is used by several key pointers is rotated in each by a separate operation, which keeps keys that are incidentally the same from being rotated together.

Separate key usages enable independent rotation. For example, if a Key-Holder Organization accidentally uses its disbursement key to issue an asset, it can recover from that mistake.

The rotation key is part of the key state, not a tracked signing key with a key pointer of its own, so that it needs no rotation key in turn.

Protocol type 0x00 is BIP 340 because ZIP 227 already uses that byte for it. The issuer of ZIP 227 is therefore the TrackedKey encoding of an issuer’s first issuance validating key.

Rationale for stating the previous key state

An operation that named only the new key would remain valid for as long as the rotation key was unchanged. If a rotation key’s holders signed one rotation of the application key and later a different one, anyone holding the first transaction could still have it mined after the second, replacing the key that the holders chose with one that they had abandoned. With prevState, an operation takes effect only on the key state that its signers saw.

It also puts both of the keys that an operation’s signatures are validated against in the transaction, so signature validation needs no chain state and can be batched. What depends on chain state is one comparison. A full validator can store the map of key states as one record per key pointer, which an operation checks by comparing it with prevState, applies by overwriting one of its two keys, and rolls back by writing prevState back, with no undo data.

Rationale for the signatures

The new key signs so that a key state cannot be changed to a key that nobody can sign with, which would leave it unusable or unrotatable until a network upgrade, and so that actions such as asset issuance cannot be attributed to a key whose holder did not agree to it.

Both signatures commit to the transaction identifier, and to the position of the operation in the bundle. A transaction can be mined only once: a v7 transaction that is not a coinbase transaction spends a transparent output or reveals a nullifier (§ 7.1.2 ‘Transaction Consensus Rules’ 16 as modified by ZIP 248), and a coinbase transaction commits to its block height. A key rotation therefore cannot be replayed, even if later operations restore the key state that it applied to. Until it is mined, it stays valid while the key state equals its prevState; signers bound this with the transaction’s expiry height.

Rationale for replacing one key per operation

A sequence of operations that each replace a single key is equivalent to one operation with optional fields, without the need to define which fields are present, and each operation carries exactly two signatures. It also allows the rotation key concept to be extended in future, for example to permit multiple rotation keys, without a transaction format change.

Processing the key rotation bundle after a transaction’s other bundles allows an issuer to register a key and give it a separate rotation key in a single transaction.

Prior art

The did:plc method used by Bluesky 17 solves a similar problem for account identities. As in this ZIP, an identifier is derived from the initial operation and never changes, rotation keys are distinct from the keys used for signing, and each operation names the one that it supersedes.

Unlike this ZIP, did:plc does not require a new key to sign. It also gives an identifier up to five rotation keys in order of authority, and lets a higher-authority key replace operations signed by a lower-authority one within 72 hours. This ZIP does not adopt that recovery window, which would make the outcome of a key rotation, and of every action authorized by the new key, provisional for its length.

Open issues

Deployment

TBD. This ZIP can only be deployed with or after the v7 transaction format. 5

Reference implementation

TBD

References