Zcash ZIPs
Theme
Appearance
Contents

Unnumbered proposal

Structured Attestation Protocol for Application-Layer Lifecycle Events (ZAP1)

Draft

Structured Attestation Protocol for Application-Layer Lifecycle Events (ZAP1) https://github.com/zcash/zips/pull/1243>"/> https://github.com/zcash/zips/pull/1243>"/>

Terminology

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

Abstract

This ZIP specifies an application-layer attestation format for lifecycle events committed to Zcash shielded transactions. It defines event typing, BLAKE2b hash construction rules, Merkle tree aggregation, and a verification procedure for on-chain commitments that keep participant-identifying data off-chain.

This draft is based on the deployed ZAP1 attestation protocol (formerly NSM1). In the reference deployment, event payloads are hashed with BLAKE2b-256 using the personalization string NordicShield_, inserted into an append-only Merkle tree, and periodically anchored to Zcash using a transaction with type byte 0x09.

Relationship to ZIP 302

This ZIP defines application-layer attestation semantics. The carrier format is specified separately by ZIP 302 1 (Structured Memos, PR #638). When ZIP 302 is deployed, ZAP1 attestation payloads SHOULD be encoded as a ZIP 302 part type. Until then, the binary layout below serves as a transitional encoding within the raw 512-byte shielded memo field.

The parts of this ZIP that are independent of the container are: the event type registry, hash construction rules, Merkle tree aggregation, and the verification procedure.

Motivation

Zcash shielded memos can carry structured application commitments, but the ecosystem lacks a convention for typed lifecycle events that can be independently recomputed by external verifiers.

Exposing Zcash state and actions to agents is straightforward. A REST or GraphQL endpoint can be wrapped as an MCP server in a small amount of code, and wallet-layer MCP implementations can expose balances, signing workflows, sync state, and transaction construction. These surfaces share one property: the consumer must trust the server response. If the backend is wrong, compromised, or unavailable later, the agent has no independent receipt it can hand to a third party for verification.

ZAP1 closes that gap. It exposes no balances and moves no value. It produces a receipt: a typed event committed to a BLAKE2b Merkle tree, with the root anchored in Zcash memo data, verifiable from the public schema, proof material, and chain anchor without trusting the issuer’s server.

The distinction is categorical. Tool servers answer “what does this backend say right now?” ZAP1 answers “what happened, provable later to another verifier?” The protocol exists for the proof artifact, not for tool exposure.

Applications that track ownership, deployment, billing, transfer, and exit events need:

This ZIP standardizes the event commitment rules used by one such deployment so that other builders can implement compatible tooling, verification, and future extensions.

Requirements

An implementation of this ZIP:

Specification

Binary Payload Layout

Before shielded memo encoding (or ZIP 302 part encoding), the binary attestation payload is:

byte 0      : version            = 0x01
byte 1      : type               = 0x01..0x0f
bytes 2..5  : cohort_id          = u32 big-endian
bytes 6..37 : payload_hash       = 32 bytes
bytes 38..45: timestamp          = u64 big-endian unix seconds
bytes 46..77: serial_hash        = 32 bytes, or 32 zero bytes when unused
bytes 78..n : label              = UTF-8 human-readable label, optional

For human-readable transport, the payload SHOULD be rendered as:

ZAP1:{type}:{payload}

where:

Event Types

This draft defines the following event type assignments:

Type Name Payload definition Status
0x01 PROGRAM_ENTRY BLAKE2b_32(wallet_hash) Deployed
0x02 OWNERSHIP_ATTEST `BLAKE2b_32(wallet_hash serial_number)` Deployed
0x03 CONTRACT_ANCHOR `BLAKE2b_32(serial_number contract_sha256)` Deployed
0x04 DEPLOYMENT `BLAKE2b_32(serial_number facility_id timestamp_be)` Deployed
0x05 HOSTING_PAYMENT `BLAKE2b_32(serial_number month_be year_be)` Deployed
0x06 SHIELD_RENEWAL `BLAKE2b_32(wallet_hash year_be)` Deployed
0x07 TRANSFER `BLAKE2b_32(old_wallet new_wallet serial_number)` Deployed
0x08 EXIT `BLAKE2b_32(wallet_hash serial_number timestamp_be)` Deployed
0x09 MERKLE_ROOT raw 32-byte Merkle root Deployed
0x0A STAKING_DEPOSIT `BLAKE2b_32(wallet_hash amount_zat_be validator_id)` Reserved
0x0B STAKING_WITHDRAW `BLAKE2b_32(wallet_hash amount_zat_be validator_id)` Reserved
0x0C STAKING_REWARD `BLAKE2b_32(wallet_hash amount_zat_be epoch_be)` Reserved
0x0D GOVERNANCE_PROPOSAL `BLAKE2b_32(wallet_hash proposal_id proposal_hash)` Reserved
0x0E GOVERNANCE_VOTE `BLAKE2b_32(wallet_hash proposal_id vote_commitment)` Reserved
0x0F GOVERNANCE_RESULT `BLAKE2b_32(wallet_hash proposal_id result_hash)` Reserved

Implementations of the deployed ZAP1 flow currently use the first nine event types in production. The staking and governance event types are reserved and MUST NOT be assumed stable until separately activated.

Hash Construction

Field sizes for hash inputs:

Unless otherwise specified, event payload hashes use BLAKE2b with:

The hash input for each event type is defined in the table above. The MERKLE_ROOT event is a special case whose payload hash is the 32-byte Merkle root itself, without an additional BLAKE2b compression step.

For event types that carry a serial number, the serial_hash payload field MUST be:

BLAKE2b_32(serial_number)

with the same personalization string NordicShield_.

If no serial number is applicable, serial_hash MUST be 32 zero bytes.

Merkle Tree Commitments

Applications using this attestation protocol SHOULD aggregate event payload hashes into an append-only binary Merkle tree. For the deployed ZAP1 protocol:

An inclusion proof consists of:

On-Chain Anchoring

When anchoring a Merkle root to Zcash:

The deployed ZAP1 implementation broadcasts shielded memo commitments using zingo-cli. The current deployment anchors every 10 events or every 24 hours, whichever occurs first.

Verification Procedure

To verify a committed event, a verifier:

  1. recomputes the event payload hash from the application fields
  2. reconstructs the attestation payload and event leaf hash
  3. walks the Merkle proof path to derive the root
  4. retrieves the referenced anchor transaction
  5. confirms that the shielded memo field contains the same 0x09 root commitment
  6. confirms that the transaction is mined on the intended chain

Rationale

This design separates protocol semantics from wallet transport.

The binary layout is fixed-width for all critical fields so parsers can extract event type, cohort identifier, and proof-relevant material without needing to understand any free-form label text. BLAKE2b-256 is used for compactness and performance. Personalization strings provide domain separation between event payload hashing and Merkle internal-node hashing.

Anchoring Merkle roots rather than full event records minimizes chain load while preserving independent verifiability. The shielded memo field remains short and constant-sized for the root-commitment case even as the underlying event history grows.

Privacy Considerations

This protocol avoids writing participant-identifying plaintext data to chain. Implementations MUST ensure that wallet_hash, serial_hash, contract digests, and other payload inputs are derived values rather than directly identifying customer records.

The optional label field may leak application metadata if misused. Protocols using this ZIP SHOULD either omit the label field or constrain it to operational strings that do not identify participants.

Security Considerations

This protocol provides integrity and auditability, not confidentiality of the underlying application database. Security depends on:

This ZIP does not address:

The deployed ZAP1 stack currently uses single-operator anchor signing, with a separate FROST migration design under development for threshold authorization of future root anchors.

Backwards Compatibility

This ZIP codifies the deployed version-0x01 ZAP1 format. Existing proof bundles remain valid as long as verifiers preserve the original event hash construction, Merkle hashing rules, and anchor transaction references.

Future incompatible payload layouts MUST use a new version byte and SHOULD use a distinct human-readable protocol marker.

Reference Implementation

Reference implementations are available at:

In the deployed zap1 implementation:

Test Vectors

A companion test vector package SHOULD provide:

The deployed ZAP1 implementation 3 publishes those vectors separately as:

References