PHPackages                             pitsolu/merkle-tree - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pitsolu/merkle-tree

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pitsolu/merkle-tree
===================

Merkle Tree

v1.0.0-alpha(3y ago)0611[1 issues](https://github.com/pitsolu/merkle-tree/issues)MITPHPPHP &gt;=7.0

Since Mar 3Pushed 3y ago1 watchersCompare

[ Source](https://github.com/pitsolu/merkle-tree)[ Packagist](https://packagist.org/packages/pitsolu/merkle-tree)[ RSS](/packages/pitsolu-merkle-tree/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Merkle Tree
===========

[](#merkle-tree)

Usage
-----

[](#usage)

### Leaf (Array)

[](#leaf-array)

```
require("vendor/autoload.php");

$customer = sha1("John Smith");
$retailer = sha1("John Doe");
$merchant = sha1("Amazon");
$taxman = sha1("Revenue Authority");
$courier = sha1("Shiply");
$exchange = sha1("Coinbase");

$transactions = array(

    "purchase"=>array(

        "sender"=>$customer,
        "recipient"=>$retailer,
        "amount"=>110
    ),
    "w/h-tax"=>array(

        "sender"=>$retailer,
        "recipient"=>$taxman,
        "amount"=>10
    ),
    "commission"=>array(

        "sender"=>$customer,
        "recipient"=>$merchant,
        "amount"=>5
    ),
    "freight"=>array(

        "sender"=>$customer,
        "recipient"=>$courier,
        "amount"=>5
    ),
    "trx-fees"=>array(

        "sender"=>$customer,
        "recipient"=>$exchange,
        "amount"=>1
    )
);

$merkleTree = new Merkle\Tree(function($data){

    return hash("sha256", hash("sha256", $data));
});
// foreach($transactions as $name=>$trx)
//     $tree = $merkleTree->add(new Merkle\Leaf($trx));

$tree = $merkleTree->add(new Merkle\Leaf($transactions["purchase"]));
$tree = $merkleTree->add(new Merkle\Leaf($transactions["w/h-tax"]));
$tree = $merkleTree->add(new Merkle\Leaf($transactions["commission"]));
$tree = $merkleTree->add(new Merkle\Leaf($transactions["freight"]));
$tree = $merkleTree->add(new Merkle\Leaf($transactions["trx-fees"]));

// print_r($tree); //merkle tree

echo(key($tree)); //merle root
```

### Leaf Item (String)

[](#leaf-item-string)

The example below also tests consistency between two trees.

```
$slimLyrics = $realSlimShadyLyrics = array(

    "I'm Slim Shady, yes I'm the real Shady",
    "All you other Slim Shadys are just imitating",
    "So won't the real Slim Shady please stand up",
    "Please stand up, please stand up?"
);

$errIdx = 2;

$slimLyrics[$errIdx] = sprintf("%s ???", $slimLyrics[$errIdx]);

foreach($realSlimShadyLyrics as $idx=>$lyric){

    $tree = $this->merkleTree->add(new Merkle\LeafItem($lyric));
    $xtree = $this->merkleTree->add(new Merkle\LeafItem($slimLyrics[$idx]));

    if(key($tree)!=key($xtree))
        throw new \Exception("Slims lyrics don't match!");
}
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1260d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f77a56030c77ce25f7fcf6db800e45bb6a31bf3c07740b43aeabcdf5e9edec2?d=identicon)[pitsolu](/maintainers/pitsolu)

---

Top Contributors

[![pitsolu](https://avatars.githubusercontent.com/u/16669704?v=4)](https://github.com/pitsolu "pitsolu (21 commits)")

---

Tags

merkle-treephp

### Embed Badge

![Health badge](/badges/pitsolu-merkle-tree/health.svg)

```
[![Health](https://phpackages.com/badges/pitsolu-merkle-tree/health.svg)](https://phpackages.com/packages/pitsolu-merkle-tree)
```

###  Alternatives

[kenjis/codeigniter-composer-installer

Package to install CodeIgniter3 via Composer with secure folder structure.

37363.7k](/packages/kenjis-codeigniter-composer-installer)[flourish/flourish

A collection of classes for general web development, with a particular focus on compatibility, portability and security

18643.2k](/packages/flourish-flourish)[zgldh/crc16-php

crc16 hash methods for PHP

1843.5k1](/packages/zgldh-crc16-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
