Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/janos/hashchain
Transparent log with Hash Chain
https://github.com/janos/hashchain
Last synced: about 1 month ago
JSON representation
Transparent log with Hash Chain
- Host: GitHub
- URL: https://github.com/janos/hashchain
- Owner: janos
- License: bsd-3-clause
- Created: 2021-09-10T13:58:39.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-20T14:17:11.000Z (over 2 years ago)
- Last Synced: 2024-06-20T16:39:42.162Z (5 months ago)
- Language: Go
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hash Chain Go library
[![Go](https://github.com/janos/hashchain/workflows/Go/badge.svg)](https://github.com/janos/hashchain/actions)
[![PkgGoDev](https://pkg.go.dev/badge/resenje.org/hashchain)](https://pkg.go.dev/resenje.org/hashchain)
[![NewReleases](https://newreleases.io/badge.svg)](https://newreleases.io/github/janos/hashchain)Hash Chain is a Go implementation of a compact append only log structure with integrity validation using cryptographic hash functions.
The implementation goals are compact storage size and relatively fast writes and reads.
## Data structure
Data structure that is written by `Writer` and read by `Reader` is a binary representation of a sequence of records that contain a timestamp, message of the specified size and a hash for integrity validation. The data structure is:
```
8 bytes messageSize hashSize
+-----------+-------------+----------++-----------+-------------+----------+
| timestamp | message | hash | record id 0
+-----------+-------------+----------+
| timestamp | message | hash | ...
+-----------+-------------+----------+
| timestamp | message | hash | record id n
+-----------+-------------+----------+
```Where the `n`-th hash is a product of the hash function applied to the concatenated data of the previous (`n-1`-th) record hash, `n`-th record timestamp and `n`-th record message, basically the exact data of the complete record size (hashSize + 8 bytes + messageSize) before the same hash in the structure. The hash used for calculation of the first record is a constant data of zero hash (zero bytes of the length of hashSize).
## Validation
The integrity validation involves successive hashing of records with previous record's hashes and comparing them to the current record hash value. This method ensures detection of changes after the messages is appended to the hash chain structure.
## License
This application is distributed under the BSD-style license found in the [LICENSE](LICENSE) file.