Agent skill

Sparse Merkle Trees

by Nethereum in Nethereum/Nethereum

Help users build sparse Merkle trees with Poseidon or SHA-256 hashing for ZK circuits, privacy pools, and state commitments using Nethereum.Merkle (.NET).

MITAuto-check passedBackend & APIs

Install Sparse Merkle Trees

skills CLI
$ npx skills add Nethereum/Nethereum --skill sparse-merkle-trees -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Nethereum/Nethereum sparse-merkle-trees --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Nethereum/Nethereum.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/nethereum-skills/skills/sparse-merkle-trees .claude/skills/sparse-merkle-trees && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
sparse-merkle-trees
GitHub stars
2.3k
Token cost
~1.2k tokens
SKILL.md length
284 words
Files
1
Skills in repo
71
Repo updated
First seen
Licence
MIT

At a glance

Help users build sparse Merkle trees with Poseidon or SHA-256 hashing for ZK circuits, privacy pools, and state commitments using Nethereum.Merkle (.NET).

  • The user mentions sparse Merkle trees
  • SKILL.md covers When to Use This, Required Packages, Core Concept and Poseidon SMT for ZK Circuits, plus 6 more sections
  • Calls dotnet
  • Poseidon hashing

What it does

Sparse Merkle Trees is an agent skill from Nethereum/Nethereum. Help users build sparse Merkle trees with Poseidon or SHA-256 hashing for ZK circuits, privacy pools, and state commitments using Nethereum.Merkle (.NET). Use this skill whenever the user mentions sparse Merkle trees, SMT, Poseidon hashing, Celestia SMT, ZK-compatible state trees, nullifier sets, membership proofs, or PoseidonSmtHasher in a C/.NET context.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs. It works with .NET and C#. The repository describes itself as: Ethereum .Net cross platform integration library. The licence is MIT.

When your agent uses it

  • The user mentions sparse Merkle trees
  • Poseidon hashing
  • ZK-compatible state trees
  • Membership proofs

Example prompts

  • “/sparse-merkle-trees”

What it can do on your machine

Read from SKILL.md and the folder at commit 229f278. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • dotnet

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.nethereum.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Sparse Merkle Trees loads about 1.2k tokens when it runs. Until then it costs about 95 tokens; SKILL.md has 284 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~95
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Nethereum/Nethereum at commit 229f278, republished under its MIT licence (© Nethereum). 284 words, ~1,216 tokens.

Download SKILL.mdSave it as .claude/skills/sparse-merkle-trees/SKILL.md (or your agent's skills folder).
name
sparse-merkle-trees
description
Help users build sparse Merkle trees with Poseidon or SHA-256 hashing for ZK circuits, privacy pools, and state commitments using Nethereum.Merkle (.NET). Use this skill whenever the user mentions sparse Merkle trees, SMT, Poseidon hashing, Celestia SMT, ZK-compatible state trees, nullifier sets, membership proofs, or PoseidonSmtHasher in a C#/.NET context.
user-invocable
true

Sparse Merkle Trees — Nethereum.Merkle

When to Use This

Use this skill when a user wants to:

  • Build a sparse Merkle tree for ZK circuit inputs (Circom, Halo2, Noir)
  • Use Poseidon hashing for circuit-friendly Merkle trees
  • Build Celestia-compatible sparse Merkle trees
  • Create membership or non-membership proofs for privacy pools or anonymous voting
  • Persist large Merkle trees with lazy node loading

Required Packages

bash
dotnet add package Nethereum.Merkle
dotnet add package Nethereum.Util

Core Concept

SparseMerkleBinaryTree<T> is a binary sparse Merkle tree where:

  • Keys are converted to bit paths for tree traversal
  • Leaves store value hashes at the key's path
  • Empty subtrees have a fixed hash (no storage needed)
  • Root hash is deterministic regardless of insertion order

The ISmtHasher interface controls hashing. Three built-in strategies:

HasherHash FunctionUse Case
PoseidonSmtHasherPoseidon (CircomT3 leaf, CircomT2 node)ZK circuits
CelestiaSmtHasherSHA-256 with domain prefixesCelestia compatibility
DefaultSmtHasherAny IHashProviderGeneric use

Poseidon SMT for ZK Circuits

The most common use case — a Poseidon-based tree whose root can be used directly as a public input in Circom proofs:

csharp
using Nethereum.Merkle.Sparse;
using Nethereum.Util.ByteArrayConvertors;

var smt = new SparseMerkleBinaryTree<byte[]>(
    new PoseidonSmtHasher(),
    new ByteArrayToByteArrayConvertor(),
    new IdentitySmtKeyHasher(256));

smt.Put(key1, value1);
smt.Put(key2, value2);
var root = smt.ComputeRoot();  // Circom-compatible root hash

var value = smt.Get(key1);
smt.Delete(key1);

Poseidon hash details:

  • Leaf: Poseidon(key, value, 1) using CircomT3 (3 inputs)
  • Node: Poseidon(left, right) using CircomT2 (2 inputs)

Celestia-Compatible SMT

csharp
var smt = new SparseMerkleBinaryTree<byte[]>(
    new CelestiaSmtHasher(),
    new ByteArrayToByteArrayConvertor());

smt.Put(key, value);
var root = smt.ComputeRoot();

Hash formulas:

  • Leaf: SHA256(0x00 || path || SHA256(value))
  • Node: SHA256(0x01 || leftHash || rightHash)

Persistent Storage (Async API)

For trees that survive process restarts:

csharp
var storage = new InMemorySmtNodeStorage();
var smt = new SparseMerkleBinaryTree<byte[]>(
    new PoseidonSmtHasher(),
    new ByteArrayToByteArrayConvertor(),
    new IdentitySmtKeyHasher(256),
    storage: storage);

await smt.PutAsync(key1, value1);
await smt.PutAsync(key2, value2);
var root = await smt.ComputeRootAsync();
await smt.FlushAsync();  // Persist all nodes

// Later — reload from storage
var smt2 = new SparseMerkleBinaryTree<byte[]>(
    new PoseidonSmtHasher(),
    new ByteArrayToByteArrayConvertor(),
    new IdentitySmtKeyHasher(256),
    storage: storage);
await smt2.LoadRootAsync(root);  // Lazy-loads nodes on demand

Batch Operations

csharp
var entries = new Dictionary<byte[], byte[]>
{
    { key1, value1 },
    { key2, value2 },
    { key3, value3 }
};

smt.PutBatch(entries);           // Sync
await smt.PutBatchAsync(entries); // Async

Console.WriteLine($"Leaves: {smt.LeafCount}");

Key Path Strategies

ImplementationDescription
IdentitySmtKeyHasher(n)Key bits used directly as path, n-bit depth
Sha256SmtKeyHasherSHA256(key) → 256-bit path

Node Serialization (SmtNodeCodec)

For custom storage backends:

csharp
byte[] encoded = SmtNodeCodec.EncodeLeaf(path, valueBytes);
SmtNodeCodec.DecodeLeaf(encoded, out var path, out var value);

byte[] branch = SmtNodeCodec.EncodeBranch(leftHash, rightHash);
SmtNodeCodec.DecodeBranch(branch, 32, out var left, out var right);

bool isLeaf = SmtNodeCodec.IsLeaf(data);
bool isBranch = SmtNodeCodec.IsBranch(data);

Common Gotchas

  • The tree root is deterministic — insertion order doesn't matter
  • PoseidonSmtHasher uses LSB-first bit ordering, CelestiaSmtHasher uses MSB-first
  • InMemorySmtNodeStorage is thread-safe (ConcurrentDictionary) but for production use, implement ISmtNodeStorage with a database backend
  • IdentitySmtKeyHasher requires keys to be the exact bit length specified — use Sha256SmtKeyHasher for variable-length keys

For full documentation, see: https://docs.nethereum.com/docs/consensus-and-cryptography/guide-sparse-merkle-zk

© Nethereum, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/nethereum-skills/skills/sparse-merkle-trees of Nethereum/Nethereum.

Open the folder on GitHubat commit 229f278

Compare with similar skills

Sparse Merkle Trees next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Sparse Merkle Trees compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Sparse Merkle Trees this skillNethereum/Nethereum2.3k—~1.2kAutomated safety check: PassMIT
Tsp Csharpquerylenshq/ef-querylens225—~1.3kAutomated safety check: PassMIT
XML DocumentationVonage/vonage-dotnet-sdk118—~2.7kAutomated safety check: PassApache-2.0
Dotnet 10 Csharp 14sketch7/FluentlyHttpClient121—~2.2kAutomated safety check: PassMIT
DisCatSharp Discord DevelopmentAiko-IT-Systems/DisCatSharp140—~1.2kAutomated safety check: PassMIT
Foundationdb Advanced LayersSnowBankSDK/foundationdb-dotnet-client158—~3.4kAutomated safety check: PassBSD-3-Clause

Similar skills

  • Tsp Csharp

    querylenshq/ef-querylens

    Comprehensive C and .NET development skill for TSP projects.

    225 GitHub stars~1.3k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • XML Documentation

    Vonage/vonage-dotnet-sdk

    Improve XML documentation in the Vonage .NET SDK. An agent skill from Vonage/vonage-dotnet-sdk.

    118 GitHub stars~2.7k tokensUpdated 4 mo ago
    Backend & APIsAuto-check passed
  • Dotnet 10 Csharp 14

    sketch7/FluentlyHttpClient

    A skill your agent uses when building .NET 10 or C 14 applications; when using minimal APIs, modular monolith patterns, or feature folders; when implementing HTTP resilience, Options pattern…

    121 GitHub stars~2.2k tokensUpdated 22 days ago
    Backend & APIsAuto-check passed
  • DisCatSharp Discord Development

    Aiko-IT-Systems/DisCatSharp

    Helps build, explain and troubleshoot C# Discord apps on DisCatSharp, answering from the project's installed version and the library's documentation rather than guesses.

    140 GitHub stars~1.2k tokensUpdated today
    Backend & APIsAuto-check passed
  • Foundationdb Advanced Layers

    SnowBankSDK/foundationdb-dotnet-client

    Advanced engineering for sophisticated FoundationDB layers with the .NET client (FoundationDB.Client / SnowBank) — the cluster model and transaction lifecycle (proxies, resolvers, tlogs, storage…

    158 GitHub stars~3.4k tokensUpdated today
    Backend & APIsAuto-check passed
  • Tiger Brokers OpenAPI C# SDK

    qusong0627/QuantMind

    Guides building C# and .NET apps on the Tiger Brokers OpenAPI SDK: setup, market data, orders, accounts, options and real-time push, defaulting to paper trading.

    1.7k GitHub stars~1k tokensUpdated today
    Backend & APIsAuto-check passed

More from Nethereum/Nethereum

All 71 skills in this repo
  • Aa Batching Paymasters

    Nethereum/Nethereum

    Help users batch multiple calls into a single UserOperation and sponsor gas with paymasters using Nethereum Account Abstraction.

    2.3k GitHub stars~1.5k tokensUpdated 5 days ago
    Auto-check passed
  • Aa Bundler

    Nethereum/Nethereum

    Help users run an ERC-4337 bundler using Nethereum — set up in-process or standalone bundlers with mempool, validation, reputation, and JSON-RPC server.

    2.3k GitHub stars~1.2k tokensUpdated 5 days ago
    Auto-check passed
  • Abi Encoding

    Nethereum/Nethereum

    Encode and decode Ethereum ABI data with Nethereum. An agent skill from Nethereum/Nethereum.

    2.3k GitHub stars~1.3k tokensUpdated 5 days ago
    Auto-check passed
  • Abi Retrieval

    Nethereum/Nethereum

    Fetch contract ABIs from Sourcify, Etherscan, and 4Byte Directory using the composite ABIInfoStorage pattern (.NET/C).

    2.3k GitHub stars~1.5k tokensUpdated 5 days ago
    Auto-check passed
  • Account Abstraction

    Nethereum/Nethereum

    Help users implement ERC-4337 Account Abstraction with Nethereum — send UserOperations, use smart accounts, route contract calls through a bundler, enable gasless transactions, or work with AA in…

    2.3k GitHub stars~1.7k tokensUpdated 5 days ago
    Auto-check passed
  • Address Utils

    Nethereum/Nethereum

    Validate and format Ethereum addresses with Nethereum. An agent skill from Nethereum/Nethereum.

    2.3k GitHub stars~1.2k tokensUpdated 5 days ago
    Auto-check passed

Works with

Categories

Questions about Sparse Merkle Trees

What does Sparse Merkle Trees do?

Help users build sparse Merkle trees with Poseidon or SHA-256 hashing for ZK circuits, privacy pools, and state commitments using Nethereum.Merkle (.NET). Sparse Merkle Trees is an agent skill from Nethereum/Nethereum.NET).

When should I use Sparse Merkle Trees?

Sparse Merkle Trees fits situations like: the user mentions sparse Merkle trees; poseidon hashing; ZK-compatible state trees; membership proofs.

How do I install Sparse Merkle Trees in Claude Code?

Run `npx skills add Nethereum/Nethereum --skill sparse-merkle-trees -a claude-code`. Or copy the skill folder (plugins/nethereum-skills/skills/sparse-merkle-trees in Nethereum/Nethereum) into .claude/skills/sparse-merkle-trees in your project. Claude Code loads it when a task matches its description.

How do I install Sparse Merkle Trees in Codex?

Run `npx skills add Nethereum/Nethereum --skill sparse-merkle-trees -a codex`. Or copy the skill folder (plugins/nethereum-skills/skills/sparse-merkle-trees in Nethereum/Nethereum) into .agents/skills/sparse-merkle-trees in your project. Codex loads it when a task matches its description.

Can I use Sparse Merkle Trees in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Nethereum/Nethereum --skill sparse-merkle-trees -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/sparse-merkle-trees, .gemini/skills/sparse-merkle-trees, .github/skills/sparse-merkle-trees and .opencode/skills/sparse-merkle-trees in your project.

What does Sparse Merkle Trees need to run?

Going by SKILL.md and its folder, Sparse Merkle Trees needs the command-line tools its instructions call (dotnet).

Does Sparse Merkle Trees access the network?

SKILL.md names 1 domain. As links in the text: docs.nethereum.com. This is read from the text; nothing was executed.

Is Sparse Merkle Trees safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Sparse Merkle Trees use?

Sparse Merkle Trees is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Sparse Merkle Trees use?

About 1.2k tokens (SKILL.md is roughly 4.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Sparse Merkle Trees?

Skills that share tags, products or a category with Sparse Merkle Trees: Tsp Csharp (querylenshq/ef-querylens, 225 stars), XML Documentation (Vonage/vonage-dotnet-sdk, 118 stars), Dotnet 10 Csharp 14 (sketch7/FluentlyHttpClient, 121 stars) and DisCatSharp Discord Development (Aiko-IT-Systems/DisCatSharp, 140 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Sparse Merkle Trees?

Nethereum (a GitHub organization) maintains it in Nethereum/Nethereum, which has 2,260 GitHub stars. The repository holds 71 skills in this directory. The repository was last updated on October 5, 2026.

Source: Nethereum/Nethereum on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.