How to use the hippiehug.Leaf function in hippiehug

To help you get started, we’ve selected a few hippiehug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github claimchain / claimchain-core / tests / test_e2e_timings.py View on Github external
(cap_lookup_key, encrypted_cap) = cap_index[(f1, f2)]
        (claim_lookup_key, encrypted_claim) = enc_claims[f2]

        root, e1 = tree.evidence(key=cap_lookup_key)
        _, e2 = tree.evidence(key=claim_lookup_key)

        evidence_store = {e.identity(): e for e in e1+e2}
        t2 = Tree(evidence_store, root)

        assert t2.is_in(key=cap_lookup_key, item=encrypted_cap)
        assert t2.is_in(key=claim_lookup_key, item=encrypted_claim)

        # Serialize evidence:
        evidence = []
        for e in e1 + e2:
            if isinstance(e, Leaf):
                evidence += [(e.key, e.item, tree.store[e.item])]
            elif isinstance(e, Branch):
                evidence += [(e.pivot, e.left_branch, e.right_branch)]
            else:
                pass

        import zlib
        bin_evidence = encode(evidence)
        bin_evidence_compressed = zlib.compress(bin_evidence, 9)
        print("\t\tSize for one proof: %s bytes (compressed %s bytes)" %
                (len(bin_evidence), len(bin_evidence_compressed)))

        print("\t\tPayload:")
        pprint(payload)

hippiehug

A Merkle Tree implementation with a flexible storage backend.

BSD-2-Clause
Latest version published 7 years ago

Package Health Score

36 / 100
Full package analysis