Skip to content

Encrypted JSON keystore support (Web3 Secret Storage / EIP-2335-style) #65

Description

@koko1123

Motivation

Everyone migrating from geth/ethers/foundry has keys in encrypted JSON keystore files (Web3 Secret Storage v3). eth.zig currently only accepts raw private keys and BIP-39 mnemonics — a hard stop for users with existing operational key management.

Scope

New src/keystore.zig:

  • decrypt(allocator, json, password) ![32]u8 — scrypt and pbkdf2-hmac-sha256 KDFs, aes-128-ctr cipher, keccak MAC check
  • encrypt(allocator, key, password, opts) ![]u8 — v3 JSON output, scrypt default
  • Constant-time MAC comparison; zero key material on free (see utils/constants.zig secure-zero helper)

Pointers

std.crypto provides scrypt, pbkdf2, aes; MAC = keccak256(derived_key[16..32] ++ ciphertext) per spec. Test vectors: the canonical ones from the Web3 Secret Storage definition (myetherwallet/geth fixtures).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions