Skip to main content

BlockDAGs for structured signature generation.

Project description

License: MIT Pylint: 10 Tests: Passing DOI

BlockDAG

BlockDAGs for structured signature generation.

A Merkle-Tree is a binary tree of hash nodes. This module implements an extension of this data-structure which differs in that:

  • Data can be included at any node in the structure
  • The structure between nodes can form a directed acyclic graph

Note, this is, in principle, a superset of a MerkleTree.

One creates a BlockDAG by providing a dictionary of vertices (id : dict()) and list of edges (id: id tuples).

For example (available in examples/EX0.py). Consider the following Graph:

Once processed, the following HashDAG is generated.

Changing the values of a single vertex, or edges the graph signature will be completely different. Moreover, the hashes of all descendent vertices will be completely different too.

The main method build_block_dag requires:

  • A dictionary of vertices, each with a unqiue key, and dictionary of fields as values
  • A list of tuples, describing the edges in the graph.
  • A hash function (returns the hex-digest of the provided data. Hashlib provides many)
  • A list of keys used to inclusively filter the data contained in each vertex. The values selected are placed in a MerkleTree, the root of which is used as the datahash for that vertex
  • A boolean, append_hashes which if True, will add the hash and graph signature to the original vertex dictionary.

bulid_block_dag returns a dictionary with the datahash, parenthashes and blockhash for each vertex in the original graph, along with a whole-graph signature.

The whole-graph signature is computed by collecting the hashes of all leaf nodes (no outgoing edges) then inserting them into a MerkleTree, and taking the root.

Usage

Install it:

pip install blockdag

or clone it.

There are several examples in examples to get started. You can compare blockdags to find differing vertices (by signature, not label) and print dags nicely.

Requirements / Assumptions

  • Vertex keys are assumed to be unique
  • The fields 'hash' and 'signature' will be overwritten if append_hashes is set to True
  • While it will not cause any issues, cycles will be ignored in the original graph.

Contributions

Feel free to help out, submit issues and make merge requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BlockDAG-1.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

BlockDAG-1.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file BlockDAG-1.1.0.tar.gz.

File metadata

  • Download URL: BlockDAG-1.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for BlockDAG-1.1.0.tar.gz
Algorithm Hash digest
SHA256 651c8a26c04307c191cb4c96d8942d87191c1b8f930e5ae8b18d93160ae67a17
MD5 e6f25e804010f7ddc5b0b0fb9de61782
BLAKE2b-256 91cc8afec1a98b33fce97f2b67c14eb985d08eaa89bf4d20a45654153f2c4fce

See more details on using hashes here.

File details

Details for the file BlockDAG-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: BlockDAG-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for BlockDAG-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bac3602a2ecda8fb7ff06fd168af52be3618dbef1136cc41a266836f46ec12d1
MD5 79ad986115479f811164f4f28450bf28
BLAKE2b-256 d656e5a7507c2d879684e2dd113799764c57446893c9991c63624781166e4a7c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page