Open Wallet Standard

repository·main·Indexed 43 days ago

https://github.com/open-wallet-standard/core

A security-first framework providing local, policy-gated signing and wallet management for blockchain networks. It features a unified interface for multi-chain key custody, ensuring private keys are never exposed to the caller. OWS includes a Rust core with Node.js and Python bindings, a CLI tool, and adapters for viem, @solana/web3.js, and the Tether WDK. Supported chains include EVM, Solana, Bitcoin, Cosmos, Tron, TON, Sui, XRPL, Spark, Filecoin, NEAR, and Cardano.

Tokens
89K
Snippets
285
Records
380
Agent score
53%

What's inside OWS

  1. Understand the core value propositions of OWS

    main

    The Open Wallet Standard (OWS) is designed to provide a unified, secure interface for multi-chain wallet operations. Key features include:

    • Local Key Custody: Private keys are stored encrypted at rest. They are only decrypted within the OWS signing path after policy checks pass. Implementations focus on hardening in-process memory and wiping key material immediately after use.
    • Unified Multi-Chain Interface: OWS provides first-class support for a wide range of chains including EVM, Solana, XRPL, Sui, Bitcoin, Cosmos, Tron, TON, Spark, Filecoin, Nano, and NEAR. It uses CAIP-2/CAIP-10 addressing to abstract away chain-specific complexities.
    • Policy-Driven Signing: A pre-signing policy engine gates operations (such as those performed by an agent via an API key). This allows for chain allowlists, expiry enforcement, and the execution of optional custom security executables before any decryption occurs.
    • Agent-Centric Design: Built with native SDKs and a CLI, OWS ensures interoperability; a wallet created by one OWS-compliant tool can be used by any other.
  2. Ensure interoperability of OWS artifacts

    main

    To maintain interoperability between conforming implementations, ensure the following behaviors are consistent when exchanging artifacts:

    • Wallet files: Must be parsed and validated consistently.
    • API key files: Must be resolvable consistently by token hash.
    • Policy files: Must produce the same allow or deny result for the same PolicyContext.
    • Identifiers: Canonical chain and account identifiers must be preserved without lossy conversion.

    Conforming implementations SHOULD ship or consume machine-readable test vectors for wallet encryption/decryption, API key resolution, policy evaluation, address derivation, and signing.

  3. How the OWS signing architecture works

    main

    OWS follows a security-first architecture designed for local key custody and policy enforcement:

    1. Access Layer: The caller (Agent/CLI/App) invokes a signing method.
    2. Policy Engine: Before decryption, the engine evaluates pre-signing policies (e.g., for API tokens).
    3. Signing Core: If authorized, keys are decrypted inside hardened in-process memory.
    4. Execution: The transaction is signed.
    5. Cleanup: Key material is wiped from memory immediately after use.
    6. Output: The signature is returned to the caller.

    Crucially, the OWS API never returns raw private keys. Keys are stored in the Wallet Vault (typically ~/.ows/wallets/).

  4. Understand the OWS Audit Log

    main

    All signing operations are recorded in an append-only JSONL file located at ~/.ows/logs/audit.jsonl. This log provides a verifiable history of wallet activity.

    Log Format:

    {
      "timestamp": "2026-02-27T10:35:22Z",
      "wallet_id": "3198bc9c-6672-5ab3-d995-4942343ae5b6",
      "operation": "broadcast_transaction",
      "chain_id": "eip155:8453",
      "details": "tx_hash=0xabc123..."
    }

    Key Properties:

    • Append-only: Implementations MUST NOT allow deletion or modification of existing entries.
    • Operations tracked: Includes create_wallet, import_wallet, export_wallet, broadcast_transaction, delete_wallet, and rename_wallet.
    • Rotation: Log rotation (e.g., monthly archives) is permitted.
  5. Common declarative policy patterns

    main

    The OWS policy engine supports several declarative rule types to restrict signing requests:

    • Time-limited access: Use the expires_at rule type with an ISO-8601 timestamp.
    • Chain restriction: Use the allowed_chains rule type with an array of CAIP-2 chain IDs.
    • EIP-712 contract restriction: Use the allowed_typed_data_contracts rule type with an array of contract addresses.

    Note: When multiple policies are attached to a single key, they follow AND semantics—all policies must allow the request for it to proceed.

    // Example: Chain restriction + expiry
    {
      "id": "base-limits",
      "name": "Base Agent Safety Limits",
      "version": 1,
      "created_at": "2026-01-01T00:00:00Z",
      "rules": [
        { "type": "allowed_chains", "chain_ids": ["eip155:8453", "eip155:84532"] },
        { "type": "expires_at", "timestamp": "2026-12-31T23:59:59Z" }
      ],
      "action": "deny"
    }
  6. Understand the OWS key lifecycle and zeroization

    main

    OWS follows a strict lifecycle to minimize the window of exposure for private keys. The process follows these steps:

    1. Request: OWS receives a sign request.
    2. Policy Check: If the credential is an API token, OWS evaluates attached policies before decryption.
    3. Read: The encrypted wallet or API-key-backed secret is read from disk.
    4. Derive KDF Key: A decryption key is derived (scrypt for passphrases, HKDF for API tokens).
    5. Decrypt: Key material (mnemonic or private key) is decrypted into hardened memory.
    6. Derive Signing Key: The chain-specific signing key is derived if necessary.
    7. Sign: The payload is signed.
    8. Zeroize: OWS immediately zeroes out the decrypted mnemonic/private key bytes, the derived signing key bytes, and the KDF-derived key bytes.
    9. Return: Only the signature or signed payload is returned to the caller.

    In the Rust implementation, this is enforced using dedicated secret containers and drop-time zeroization.

  7. Understand the OWS CLI file layout

    main

    The OWS CLI manages data within the ~/.ows/ directory. Understanding this structure helps you locate your wallets, keys, and logs:

    • ~/.ows/bin/ows: The CLI binary.
    • ~/.ows/wallets/: Contains encrypted wallet files (<uuid>.json) using AES-256-GCM and scrypt.
    • ~/.ows/policies/: Contains non-secret policy definitions (<id>.json).
    • ~/.ows/keys/: Contains API key files (<uuid>.json) with restricted 0600 permissions.
    • ~/.ows/logs/audit.jsonl: The audit log file in JSONL format.
  8. How the OWS Access Layer works

    main

    The OWS security model ensures that an agent or application never sees the actual private keys. The workflow follows these steps:

    1. Request: The Agent/CLI calls a signing method (e.g., ows.sign()).
    2. Policy Evaluation: The Policy Engine evaluates any attached rules (e.g., chain allowlists, expiration).
    3. Decryption: If allowed, the Signing Enclave (an isolated process) decrypts the key.
    4. Signing: The transaction is signed within the isolated enclave.
    5. Cleanup: The key is wiped from memory immediately after use.
    6. Return: The signature is returned to the agent.

    Components:

    • Policy Engine: Pre-signing validation layer.
    • Signing Enclave: Isolated process for cryptographic operations.
    • Wallet Vault: Secure storage located at ~/.ows/wallets/.
  9. How the OWS Access Model works

    main

    OWS uses two distinct access modes for signing transactions. The mode is determined by the authentication method used in the sign_transaction(wallet, chain, tx, credential) call:

    1. Owner Mode: Authenticated via a passphrase. This mode has no policy enforcement and provides full access to all wallets. It uses scrypt to decrypt the wallet mnemonic.
    2. Agent Mode: Authenticated via an ows_key_... token. This mode enforces all policies attached to the API key. Every policy must allow the transaction (AND semantics). It uses HKDF to decrypt the mnemonic.

    If an owner requires policy-constrained access for themselves, they should create an API key and use the resulting token instead of their passphrase.

    sign_transaction(wallet, chain, tx, credential)
                                           │
                              ┌────────────┴────────────┐
                              │                          │
                         passphrase                 ows_key_...
                              │                          │
                         owner mode                  agent mode
                         no policy                   policies enforced
                         scrypt decrypt              HKDF decrypt
  10. Handle OWS schema versioning and compatibility

    main

    OWS uses two layers of versioning: specification documents (for behavior) and schema versions (embedded in artifacts for compatibility).

    Current Version Markers:

    • Wallet file schema: ows_version = 2
    • Policy schema: version = 1

    Implementation Requirements:

    • You MUST reject unknown required schema fields.
    • You MUST reject schema versions that you do not understand.
    • You MAY accept older schema versions if you have documented how you handle compatibility.
  11. Understand the OWS Specification structure and conformance

    main

    The Open Wallet Standard (OWS) is a local-first specification for encrypted wallet storage, signing operations, policy enforcement, and multi-chain account derivation. The specification is divided into two main types of documents:

    Normative Core

    These documents define the required interoperable behavior and file formats. If a conflict exists, these documents take precedence over reference implementations.

    • 01-storage-format.md: Storage requirements.
    • 02-signing-interface.md: Signing interface requirements.
    • 03-policy-engine.md: Policy engine requirements.
    • 06-wallet-lifecycle.md: Lifecycle management (creation, import, export, etc.).
    • 07-supported-chains.md: Chain identifiers and derivation rules.
    • 08-conformance-and-security.md: Security and conformance standards.

    Optional Access and Deployment Profiles

    These define acceptable implementation patterns but do not mandate specific languages or transports.

    • 04-agent-access-layer.md
    • 05-key-isolation.md

    Reference Implementations

    Documents like quickstart.md, sdk-cli.md, sdk-node.md, and sdk-python.md are non-normative and provide practical examples of how to use the standard.

  12. Understand x402 Usage-Based Settlement

    main

    The upto (usage-based) settlement pattern is used for agent payments where the final cost is unknown until a task completes. This pattern allows an agent to authorize a maximum amount (a cap) before work begins, and the service settles only the actual cost upon completion.

    PatternAmount at authAmount settled
    exactKnown upfrontSame as authorized
    uptoMax cap authorizedActual cost (<=max)

    Lifecycle of an upto payment:

    1. Agent authorizes max amount: The service begins work once the cap is authorized.
    2. Service completes task: The service settles the actual amount used.
    3. Remaining headroom released: The wallet balance is updated to reflect the unused portion of the authorized cap.