Skip to content
merkle-proof-validation logo

merkle-proof-validation Skill

merkle-proof-validation

Merkle Proof Validation Skill

SKILL.md

Full skill instructions

merkle-proof-validation Skill

"Trust but verify. Every leaf proves its tree."

Overview

Merkle Proof Validation implements cryptographic verification of inclusion proofs. Given a leaf and a path, validate membership in a Merkle tree without the full tree.

GF(3) Role

AspectValue
Trit-1 (MINUS)
RoleVALIDATOR
FunctionValidates Merkle inclusion proofs

Core Algorithm

import hashlib

def hash_pair(left: bytes, right: bytes) -> bytes:
    """Hash two nodes together."""
    return hashlib.sha256(left + right).digest()

def verify_merkle_proof(
    leaf: bytes,
    proof: list[tuple[bytes, str]],  # (sibling_hash, position)
    root: bytes
) -> bool:
    """
    Verify a Merkle inclusion proof.

    Args:
        leaf: The leaf value to verify
        proof: List of (sibling_hash, 'left'|'right') pairs
        root: Expected Merkle root

    Returns:
        True if leaf is in tree with given root
    """
    current = hashlib.sha256(leaf).digest()

    for sibling, position in proof:
        if position == 'left':
            current = hash_pair(sibling, current)
        else:
            current = hash_pair(current, sibling)

    return current == root

Move Implementation

module merkle::validation {
    use std::vector;
    use aptos_std::aptos_hash;

    const E_INVALID_PROOF: u64 = 1;

    struct MerkleProof has store, drop {
        leaf: vector<u8>,
        siblings: vector<vector<u8>>,
        positions: vector<bool>,  // true = sibling on left
        root: vector<u8>,
    }

    public fun verify(proof: &MerkleProof): bool {
        let current = aptos_hash::sha3_256(proof.leaf);
        let len = vector::length(&proof.siblings);
        let i = 0;

        while (i < len) {
            let sibling = vector::borrow(&proof.siblings, i);
            let is_left = *vector::borrow(&proof.positions, i);

            current = if (is_left) {
                hash_pair(*sibling, current)
            } else {
                hash_pair(current, *sibling)
            };
            i = i + 1;
        };

        current == proof.root
    }

    fun hash_pair(left: vector<u8>, right: vector<u8>): vector<u8> {
        let combined = vector::empty<u8>();
        vector::append(&mut combined, left);
        vector::append(&mut combined, right);
        aptos_hash::sha3_256(combined)
    }
}

Proof Structure

                    Root
                   /    \
                  /      \
                H01      H23
               /   \    /   \
              H0   H1  H2   H3
              |    |   |    |
             L0   L1  L2   L3  ← Leaves

Proof for L1: [(H0, left), (H23, right)]
Verify: hash(H0 || hash(L1)) → H01
        hash(H01 || H23) → Root ✓

GF(3) Integration

class GF3MerkleValidator:
    """Merkle validation with GF(3) conservation."""

    TRIT = -1  # VALIDATOR role

    def validate_batch(self, proofs: list) -> dict:
        """
        Validate batch of proofs.
        Each validation is a MINUS operation.
        """
        results = []
        for proof in proofs:
            valid = self.verify(proof)
            results.append({
                'leaf': proof.leaf,
                'valid': valid,
                'trit': self.TRIT  # -1 for validation
            })

        # GF(3) check: need balancing generators
        trit_sum = len(proofs) * self.TRIT
        return {
            'results': results,
            'trit_sum': trit_sum,
            'needs_generators': -trit_sum  # To balance
        }

IECsat Integration

For hierarchical tile validation:

def validate_tile_inclusion(
    tile_code: str,      # e.g., "9C3XGV2F+QQ"
    tile_hash: bytes,
    root_tile: str,      # e.g., "9C3XGV2F+"  (10-char)
    proof: list
) -> bool:
    """
    Validate that a fine tile belongs to a root tile's Merkle tree.

    On-chain: 10-char root tiles with Merkle roots
    Off-chain: 11-17 char tiles with proofs
    """
    # Verify the Plus Code hierarchy
    assert tile_code.startswith(root_tile.rstrip('+'))

    # Verify Merkle inclusion
    return verify_merkle_proof(tile_hash, proof, get_root(root_tile))

GF(3) Triads

merkle-proof-validation (-1) ⊗ iecsat-storage (0) ⊗ aptos-gf3-society (+1) = 0 ✓
merkle-proof-validation (-1) ⊗ datalog-fixpoint (0) ⊗ anoma-intents (+1) = 0 ✓
merkle-proof-validation (-1) ⊗ spi-parallel-verify (0) ⊗ polyglot-spi (+1) = 0 ✓

Commands

# Generate Merkle proof (Python)
python3 -c "
from merkle import MerkleTree
tree = MerkleTree(leaves)
proof = tree.get_proof(leaf_index)
print(proof.to_json())
"

# Verify on-chain (Move)
aptos move run --function merkle::validation::verify --args ...

Skill Name: merkle-proof-validation Type: Cryptographic Verification Trit: -1 (MINUS - VALIDATOR) GF(3): Validates inclusion proofs

Scientific Skill Interleaving

This skill connects to the K-Dense-AI/​claude-scientific-skills ecosystem:

Graph Theory

  • networkx [○] via bicomodule
    • Universal graph hub

Bibliography References

  • cryptography: 1 citations in bib.duckdb

Cat# Integration

This skill maps to Cat# = Comod(P) as a bicomodule in the Prof home:

Trit: 0 (ERGODIC)
Home: Prof (profunctors/​bimodules)
Poly Op: ⊗ (parallel composition)
Kan Role: Adj (adjunction bridge)

GF(3) Naturality

The skill participates in triads where:

(-1) + (0) + (+1) ≡ 0 (mod 3)

This ensures compositional coherence in the Cat# equipment structure.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View