HashLog
Principles
- Records are immutable
- Records are ordered
- It must be possible to check
hash(Xi)for anyi hash(Xi)can be sent to anyone as a proofhash(Xi) == hash(X, hash(Xi-1))- You do not need X to perform the check
Installation
$ pip install hlog
Usage
Getting started
# create a chain
c = Chain()
# send some messages
c.append(message="Alice gives 10.36 euros to Bob", amount=10.36, currency="EUR")
c.append(message="Bob gives 2 dollars to Alice", amount=2, currency="USD")
# you can loop through the chain records
used_currencies = set(r.fields["currency"] for r in c.records)
# call verify() to ensure records have not been modified
c.verify()
Raising an exception during validation
c.verify(raise_on_error=True)
Verify will raise a ModifiedRecordException. It has 3 interesting attributes:
index: the index in the chain where validation starts to failmessage: a user-friendly message to indicate the errorrecord: theRecordobject itself
Dumping
c = Chain()
c.append(message="hello")
c.append(message="wonderful")
c.append(message="world")
rows = c.dump()
rows is a tuple of bytes, each item being one record of the chain.
Restoring from a dump
If you want to reconstruct your chain based on a file or database records, you can use Chain.from_dump()
c = Chain()
c.append(message="hello")
c.append(message="wonderful")
c.append(message="world")
d = c.dump()
c2 = Chain.from_dump(d)
c2.verify()
Metadata
Release files for hlog 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hlog-1.0.1.tar.gz | 5.9 kB | Without provenance | Details for hlog-1.0.1.tar.gz |
Release files / hlog-1.0.1.tar.gz
| Download URL | hlog-1.0.1.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
931ad958218bf64c4bb8299f850df30e77485a912db595d8e838e42c1a507f26
|
|
BLAKE2b-256 checksum How to use checksums |
8cfb4f4e2afd30b56f9e31e05cbbdcb1876a547bbda2ee6ec9ef08d381587546
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9
|
Security for hlog 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.