Download the PHP package danc0/dmerkle without Composer

On this page you can find all versions of the php package danc0/dmerkle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dmerkle

dmerkle

License Version PHP PHPUnit PHPStan

Description

Install with: composer require danc0/dmerkle

A PHP implementation of a Merkle Hash tree. Completed hashes are returned in blocks and proof of inclusion can be run on blocks to check if transactions are included in that block.

Usage

You should do the following store your transactions in a database with a block_id field and root_hash field. Process your transactions via a first in first out queue. You will also need a table to store block data to make it possible to validate transactions.

You will need to pass these transactions into the hashing function in groups based on the block size you set (defaults to 100 transactions per block). For example if your block size was 2 you would pass something similar to this:

Data passed into the hashing function should be an array of arrays no larger than the max block size, a DMerkle_Exception is thrown if this size is surpassed.

Using the DMerkle.php file

After building your queue and storing your transactions you can begin building data to pass to the hashing method.

The createBlockData method will return the structured data of the block, including the complete hash tree. You will need to store this block information to validate blocks! It will also return the block hash for you to use in your next block. This will allow you to validate blocks and should also be saved with your block data! Passing the previous blocks hash into your current block means that if anything changes in any block prior to the current one your current block will not have the same block hash. This will allow us to validate a block is unchanged.

Example block data:

This data should be stored and the block_id and root_hash should be saved to each transaction used to create this block.

Validate a transaction

To validate a transaction you need to pass the transaction data used when creating blocks and the root_hash of that block. You will also need to load the complete block data returned from the hashing method into DMerkle_Block::class.

The transactionIsPartOfBlock method will return true | false and will validate the transaction from the base level up to the root hash by hashing it and the siblings it was hashed with up to the root hash level. This means if the hash is changed at the base level there is still no way the root hash would be the same unless the entire block was compromised and hashed again.

Validate a block

It is possible to validate a block is unchanged by either recreaing or rehashing that block and using the DMerkle_Block class to validation the hash. To do this the previous block hash should always be passed into the current block when hashing transactions into a block. This technique means that any change in a block prior to the current one would create a different hash for the current block.

Since the old block hash is hashed as part of the new block if that old hash is ever changed it would cause the current blocks hash to be different thant what is stored.


All versions of dmerkle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package danc0/dmerkle contains the following files

Loading the files please wait ....