{"id":15370277,"url":"https://github.com/jedisct1/go-progressive-hash","last_synced_at":"2025-04-15T13:53:34.855Z","repository":{"id":66081615,"uuid":"128064209","full_name":"jedisct1/go-progressive-hash","owner":"jedisct1","description":"Progressive hashing PoC","archived":false,"fork":false,"pushed_at":"2024-12-12T09:20:34.000Z","size":91,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T20:46:36.972Z","etag":null,"topics":["boom","buggy","dangerous","dontusethisforanythingyet","insecure","poc","wip","youvebeenwarned"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jedisct1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-04-04T13:13:40.000Z","updated_at":"2025-02-06T03:52:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"3d6363f2-da62-410f-afa2-1f8e5f726506","html_url":"https://github.com/jedisct1/go-progressive-hash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fgo-progressive-hash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fgo-progressive-hash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fgo-progressive-hash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedisct1%2Fgo-progressive-hash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jedisct1","download_url":"https://codeload.github.com/jedisct1/go-progressive-hash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085474,"owners_count":21210267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["boom","buggy","dangerous","dontusethisforanythingyet","insecure","poc","wip","youvebeenwarned"],"created_at":"2024-10-01T13:40:43.855Z","updated_at":"2025-04-15T13:53:34.836Z","avatar_url":"https://github.com/jedisct1.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Progressive hashing\n\nTraditional password stretching functions such as PBKDF2, Scrypt, Bcrypt and Argon2 compute a fixed-length digest from a variable length, low-entropy input. These functions are intentionally slow, possibly with large memory requirements, in order to mitigate dictionary attacks.\n\nThe flipside is that in order to verify that an input matches a previously computed hash, the whole computation has to be performed again. This requires significant resources, even if the input doesn't happen to match the expected hash.\n\nThis package implements a proof of concept of a _progressive hash function_, a PBKDF2 variant that can detect a mismatching hash for a given input _while doing the computation_, and thus return early instead of performing the full computation.\n\nThe first output bits of this function are computed as follows:\n\n```text\nH(x): BLAKE2B-512(x)\nG(r, x): r recursive iterations of H(x)\no: output\nN: number of progressive bits in the output\nM: total output length\nseed: application-specific seed\nB(b, x): bit b of x\nR0: initial number of iterations\nC \u003c- 2\n\nh \u003c- H(seed || pad || in)\n\nr \u003c- R0\nh \u003c- G(r, h)\nB(0, o) \u003c- B(0, h)\n\nr \u003c- r * C\nh \u003c- G(r, h)\nB(1, o) \u003c- B(0, h)\n\n...\n\nr \u003c- r * C\nh \u003c- G(r, h)\nB(n, o) \u003c- B(0, h)\n```\n\nIndividual bits of the prefix are computed sequentially and the work factor doubles after every bit.\n\nFinally, the remaining `M-N` bits are copied from bits of `h` at the same position.\n\nComputing a full new hash requires a full computation.\n\nHowever, the verification function can compute the first bit, stop early if it doesn't match, compute the next one only if it does and repeat the process until `N` bits have been accumulated.\n\n`M` should be large enough to avoid collisions. The maximum output length is 512 bits.\n\nOn the other hand, `N` should be short enough to produce collisions during the fast part of the computation.\n\n# Usage\n\n```go\nseed := []byte(\"test application\")\nin := []byte(\"input string\")\n\nh, err := progessiveHash.Hash(in, seed, 50000, 8, 256)\nif err != nil {\n\tpanic(err)\n}\n\nerr = progessiveHash.Verify(in, seed, 50000, 8, 256, h)\nif err != nil {\n\tpanic(err)\n}\n\n// This is unlikely to require a full computation\nbadIn := []byte(\"wrong input\")\nerr = progessiveHash.Verify(badIn, seed, 50000, 8, 256, h)\nif err != nil {\n\tpanic(\"verification shouldn't have passed\")\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedisct1%2Fgo-progressive-hash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjedisct1%2Fgo-progressive-hash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedisct1%2Fgo-progressive-hash/lists"}