Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid fake hashes & additional hash helper utilities #216

Merged
merged 20 commits into from
Nov 29, 2023

Conversation

mattyg
Copy link
Member

@mattyg mattyg commented Nov 17, 2023

  • add helper function dhtLocationFrom32 to construct valid dht location bytes from core 32 bytes
  • alter fakeAgentPubKey, fakeEntryHash, fakeActionHash, fakeDnaHash to produce valid hashes, and to optionally take a param coreByte which will be repeated for all core 32 bytes
  • add helper functions to slice up a full hash: sliceDhtLocation, sliceCore32, sliceHashType
  • add helper functions to construct a full hash: hashFrom32AndType
  • add helper object hashTypePrefix to store hash type label -> hash type bytes
  • adds dependency @bitgo/blake2b
  • Tests for all functions and new features

Feel free to rename functions as you please.

@mattyg mattyg changed the title WIP feat: produce valid fake hashes with valid checksum WIP Hash helper utilities Nov 19, 2023
@mattyg mattyg changed the base branch from main to develop November 28, 2023 01:20
@mattyg mattyg changed the title WIP Hash helper utilities Valid fake hashes & additional hash helper utilities Nov 28, 2023
@mattyg mattyg marked this pull request as ready for review November 28, 2023 01:20
@mattyg
Copy link
Member Author

mattyg commented Nov 28, 2023

@jost-s tagging you to request review since I can't don't have permission to assign you.

Copy link
Contributor

@jost-s jost-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the complete feature

src/utils/hash-parts.ts Outdated Show resolved Hide resolved
test/e2e/utils.ts Outdated Show resolved Hide resolved
test/e2e/utils.ts Outdated Show resolved Hide resolved
@mattyg
Copy link
Member Author

mattyg commented Nov 29, 2023

@jost-s should be all set -- I don't have permission to merge

@jost-s
Copy link
Contributor

jost-s commented Nov 29, 2023

Great, and thanks for the changelog!
I know about Matthew's holo hash package and I want to incorporate that into the JS client, but AFAIK it doesn't generate fake hashes, so your work is not a duplicate.

@jost-s jost-s merged commit 7ad9a32 into holochain:develop Nov 29, 2023
10 checks passed
jost-s pushed a commit that referenced this pull request Nov 29, 2023
* feat: produce valid fake hashes with valid checksum

* fix: core of hash is 32 bytes

* fix: hash

* Revert "fix: hash"

This reverts commit 04bf0b3.

* fix: hash fn

* fix: hash length

* feat: add functions to slice hash into prefix, core, and dht location bytes

* chore: comment

* feat: add functions to generate full hash from core 32 and type, rename functions for consistency

* chore: rename test utils to common to make room for tests against utilty functions

* chore: remove unused hash types

* test: tests that fake hash functions produce valid hashes

* build: fix typescript module declaration for @bitgo/blake2b

* doc: generate docs

* feat: specify a core byte to repeate for all core 32 bytes of a fake hash, in order to generate a determanistic fake hash

* test: add tests for hash slice and hash construct utils

* chore: capital-case hashTypePrefix dict

* chore: spelling

* doc: changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants