{"id":36698538,"url":"https://github.com/rebaze/integrity","last_synced_at":"2026-01-12T11:36:04.848Z","repository":{"id":57738752,"uuid":"12852999","full_name":"rebaze/integrity","owner":"rebaze","description":"Java library providing Merkle DAG structures","archived":false,"fork":false,"pushed_at":"2024-10-30T18:46:53.000Z","size":679,"stargazers_count":19,"open_issues_count":7,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-29T13:16:49.086Z","etag":null,"topics":["bitcoin","blockchain","dag","java","java-library"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rebaze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-09-15T21:31:43.000Z","updated_at":"2025-05-25T00:14:53.000Z","dependencies_parsed_at":"2024-10-20T11:04:54.962Z","dependency_job_id":null,"html_url":"https://github.com/rebaze/integrity","commit_stats":null,"previous_names":["auxisrepos/auxis-commons-tree"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rebaze/integrity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebaze%2Fintegrity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebaze%2Fintegrity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebaze%2Fintegrity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebaze%2Fintegrity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rebaze","download_url":"https://codeload.github.com/rebaze/integrity/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebaze%2Fintegrity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T10:58:46.209Z","status":"ssl_error","status_checked_at":"2026-01-12T10:58:42.742Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","blockchain","dag","java","java-library"],"created_at":"2026-01-12T11:36:02.890Z","updated_at":"2026-01-12T11:36:04.841Z","avatar_url":"https://github.com/rebaze.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/rebaze/integrity) \n\n[\u003cimg src=\"http://www.rebaze.com/assets/Rebaze_icon_colors_tbg.png\" align=\"right\" width=\"100\"\u003e](http://rebaze.com)\n\n[![OSGi compatible](https://img.shields.io/badge/OSGi-compatible-green.svg)](http://www.osgi.org)\n[![Build Status](https://github.com/rebaze/integrity/workflows/cibuild/badge.svg)](https://github.com/rebaze/integrity/workflows/cibuild/)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.rebaze.integrity/org.rebaze.integrity.tree/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.rebaze.integrity/org.rebaze.integrity.tree)\n[![Apache 2.0](https://img.shields.io/github/license/nebula-plugins/nebula-publishing-plugin.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n\n# News\n\n# What is this?\n\nA small Java library for creating Merkle Trees (https://en.m.wikipedia.org/wiki/Merkle_tree) to be used in blockchain-like technologies.\n\n- Composite hash- tree based java library (DAG)\n- OSGi compatible\n- Embeddable\n- Low footprint \n\n## What is this good for\n\n- Blockchain and Hyperledger Technologies\n- Indexing arbitrary (nested) data based on hashes and metadata (called selectors and tags here)\n\n## How do i use it?\n\nThe most up-to-date code that actually works can be found in this projects test folder. \nBut it is usually helpful to have a first glance at the api and how it can be used.\n\n### Initializing the TreeSession instance\n\nThis creates the main entry for anything in this library. \nIt is called a \"Session\" because it encapsulates things you want to have consistent\nwhen creating and using the Hash-Trees like hash algorithm used, \nkind of TreeBuilder (currently in-memory only), and potentially shared instances\nsuch as MessageDigest.\n\nAn instance can be stored (when using the DefaultTreeSessionFactory) as private final static field in a class).\n\n### Lets create a hash tree\n\n````java\nTreeSession session =  new DefaultTreeSessionFactory().create();\n````\n\nThis creates the probably smalles tree possible without any meta-data attached to it.\nThe final \"seal()\" method on TreeBuilder actually creates hashes of all sub-elements (hence tree)\nand returns the composite Tree (value object, immutable).\nThis Tree can be shared, stored and searched (using IndexTree, see below, for example).\n\n````java\nTree myFirstTree = session.createTreeBuilder()\n            .add(\"anydata\")\n            .seal();\n````\n\nThat first tree basically only gives you the (by default SHA-1) hash of \"anydata\". Not a big leap by itself.\n\nWhat happens when we add more \"data\"?\n````java\nTree treeWithoutBranches = session.createTreeBuilder()\n            .add(\"anydata\".getBytes())\n            .add(\"moredata\".getBytes())\n            .seal();\n````\nThis by itself might be useful, probably it is not. What it does is it just adds \"moredata\" to the single Tree node.\nThe resulting tree will just be the SHA-1 of \"anydata\" + \"moredata\" without any branches.\n\n### What are branches?\n\nBranches are sub-nodes of a tree. They are tree-branches. Branches are a way to structure (hashed) data so that \nyou can read the sub-hashes after building the tree.\nNote that the tree above won't have any branches when you call \n```treeWithoutBranches.branches()```.\n\nHow do you create branches?\n````java\nTreeBuilder treeBuilder = session.createTreeBuilder();\ntreeBuilder.branch( selector(\"datapointA\") ).add(\"anydata\".getBytes());\ntreeBuilder.branch( selector(\"datapointB\") ).add(\"otherdata\".getBytes());\nTree tree = treeBuilder.seal();\n````\nNow your resulting tree will have the same SHA-1 hash as before but it will have the nested sub-branches\ncontained. \nSo you now can also ask for the sub-hashes:\n\n````java\nTree subTreeOfDatapoinA = treeWithBranches.branches()[0];\nTree subTreeOfDatapoinB = treeWithBranches.branches()[1];\n\n````\nNow you might wonder if you can also use the selectors to \"query\" the right sub branch.\nYes you can. That's what the \"TreeIndex\" helper is about.\nIt (upon creation) traverses the given tree and creates appropriate indexes to lookup by Selectors:\n\n````java\nTreeBuilder treeBuilder = session.createTreeBuilder();\n\ntreeBuilder.branch( selector(\"datapointA\") ).add(\"anydata\".getBytes());\ntreeBuilder.branch( selector(\"datapointB\") ).add(\"otherdata\".getBytes());\nTree tree = treeBuilder.seal();\n\nTreeIndex treeIndex = new TreeIndex( tree );\nSystem.out.println(treeIndex);\nSystem.out.println(treeIndex.select( selector(\"datapointA\" )));\nSystem.out.println(treeIndex.select( selector(\"datapointB\" )));\n\n````\n\nSelectors are \"per branch\" and can be nested and reused.\nNote how the parent selector \"index\" is reused to \"group\" data into a common ancestor.\n````java\nTreeBuilder treeBuilder = session.createTreeBuilder();\n\ntreeBuilder.branch( selector(\"index\") ).branch( selector(\"A\") ).add(\"anydata\".getBytes());\ntreeBuilder.branch( selector(\"index\") ).branch( selector(\"B\") ).add(\"otherdata\".getBytes());\nTree tree = treeBuilder.seal();\n\nTreeIndex treeIndex = new TreeIndex( tree );\nSystem.out.println(treeIndex);\nSystem.out.println(treeIndex.select( selector(\"index\" ),selector(\"A\" )));\n\n// Composite Selector is supported too:\nSystem.out.println(treeIndex.select( selector(\"index\",\"B\" )));\n\n````\n\n### Tags\nWhile selectors are an integral part of what branches get merged into a single node (see index selector above),\ntags are pure metadata only used to later lookup sub-trees.\n\nSelectors are unique per \"parent-branch\" level, which allows the grouping feature mentioned above.\nTags do not need to be unique.\n\nIndexTree currently does not build indexes for tags, so that is a thing to do..;)\n\n# LICENSE\nCopyright 2014-2020 rebaze GmbH.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\nChange\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebaze%2Fintegrity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frebaze%2Fintegrity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebaze%2Fintegrity/lists"}