{"id":22071290,"url":"https://github.com/lancejpollard/hash","last_synced_at":"2025-10-28T17:17:16.608Z","repository":{"id":66858513,"uuid":"449982406","full_name":"lancejpollard/hash","owner":"lancejpollard","description":"Hashing Function Theory","archived":false,"fork":false,"pushed_at":"2022-01-20T11:51:19.000Z","size":12214,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"make","last_synced_at":"2025-01-29T01:59:44.680Z","etag":null,"topics":["cryptography","group-theory","hash-functions","mathematics","papers"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lancejpollard.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,"publiccode":null,"codemeta":null}},"created_at":"2022-01-20T06:33:42.000Z","updated_at":"2022-12-23T09:23:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc258439-2e97-4afd-bddc-5e9500a6c432","html_url":"https://github.com/lancejpollard/hash","commit_stats":null,"previous_names":["haresurf/hash","termhare/hash","lancejpollard/hash"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancejpollard%2Fhash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancejpollard%2Fhash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancejpollard%2Fhash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancejpollard%2Fhash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lancejpollard","download_url":"https://codeload.github.com/lancejpollard/hash/tar.gz/refs/heads/make","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245153896,"owners_count":20569408,"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":["cryptography","group-theory","hash-functions","mathematics","papers"],"created_at":"2024-11-30T20:29:49.754Z","updated_at":"2025-10-28T17:17:11.573Z","avatar_url":"https://github.com/lancejpollard.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Hashing Function Theory\n\nNotes relating to hashing functions.\n\n## Original Hashing Function Papers\n\n- [md2](https://github.com/lancejpollard/hash/blob/make/paper/md2/original.pdf)\n- [md4](https://github.com/lancejpollard/hash/blob/make/paper/md4/original.pdf)\n- [md5](https://github.com/lancejpollard/hash/blob/make/paper/md5/original.pdf)\n- [md6](https://github.com/lancejpollard/hash/blob/make/paper/md6/original.pdf)\n- [ripemd160](https://github.com/lancejpollard/hash/blob/make/paper/ripemd160/original.pdf)\n- [sha1](https://github.com/lancejpollard/hash/blob/make/paper/sha1/original.pdf)\n- sha2\n- [sha3](https://github.com/lancejpollard/hash/blob/make/paper/sha3/original.pdf)\n- [blake2](https://github.com/lancejpollard/hash/blob/make/paper/blake2/original.pdf)\n- [blake3](https://github.com/lancejpollard/hash/blob/make/paper/blake3/original.pdf)\n\n## Other Resources\n\n- https://github.com/BLAKE3-team/BLAKE3-specs\n- https://en.wikipedia.org/wiki/List_of_hash_functions\n- https://en.wikipedia.org/wiki/Hash_function_security_summary\n- https://en.wikipedia.org/wiki/Cipher_security_summary\n- https://noiseprotocol.org/noise.html\n- https://github.com/noiseprotocol/sho_spec/blob/master/sho.md\n\n## Notes\n\n_Much from Chapter 6 of \"Serious Cryptography\"._\n\n- Two types of **iterative hashing**:\n  1. **Compression function**: Iterative hashing which transforms an input to a _smaller_ input (also called a **Merkle-Damgård construction**).\n  2. **Sponge function**: Iterative hashing which transforms an input to a _same sized_ input (also called a **permutation based hash function**).\n- All hash functions developed from the 1980s through the 2010s are based on the Merkle-Damgård (M-D) construction: MD4, MD5, SHA-1, and the SHA-2 family, as well as the lesser-known RIPEMD and Whirlpool hash functions.\n\n## General Approach\n\n### General Approach of Merkle-Damgård Construction\n\n- Break message into equal sized **blocks** (commonly 512 or 1024 bits, but can be any size).\n- Block length is fixed for a hash functions life.\n- For the last block if not equal to standard block size:\n  1. Append 1 bit.\n  2. Then append a bunch of zero bits.\n  3. Then encode the leftover bits size at the end.\n- For example, if you hash the 8-bit string 10101010 using SHA-256, which is a hash function with 512-bit message blocks, the first and only block will appear, in bits, as follows: 101010101000000000000...000001000. The 1000 at the end of the block (underlined) is the message’s length, or 8 encoded in binary.\n- If a compression function is preimage and collision resistant, then a hash function built on it using the M-D construction will also be preimage and collision\nresistant.\n- **Davies-Meyer Construction**: Most common block-cypher based compression functions.\n- All compression functions used in real hash functions such as SHA-256 and BLAKE2 are based on block ciphers, because that is the simplest way to build a compression function.\n- As long as the block cipher is secure, the resulting compression function is secure as well as collision and preimage resistant.\n- There are many block cipher-based compression functions other than Davies-Meyer.\n- **Sponge functions** use a single permutation instead of a compression function and a block cipher.\n- Instead of using a block cipher to mix message bits with the internal state, sponge functions just do an XOR operation.\n- The most famous sponge function is Keccak, also known as SHA-3.\n\n## Block Cyphers\n\n- There are hundreds of block ciphers but only a handful of techniques to\nconstruct one.\n- A block cipher used in practice isn’t a gigantic algorithm but a repetition of rounds, a short sequence of operations that is weak on its own but strong in number.\n- There are two main techniques to construct a round:\n  1. **Substitution–permutation networks** (as in AES) ([wiki](https://en.wikipedia.org/wiki/Substitution%E2%80%93permutation_network))\n  2. **Feistel schemes** (as in DES) ([wiki](https://en.wikipedia.org/wiki/Feistel_cipher))\n- Computing a block cipher boils down to computing a sequence of _rounds_.\n- The round functions are identical functions, but parameterized by a round _key_.\n- Round keys should always be different from each other in every round.\n- **Confusion**: input (plaintext and encryption key) undergoes complex transformations.\n- **Diffusion**: transformations depend equally on all bits of the input.\n- In the design of a block cipher, confusion and diffusion take the form of substitution and permutation operations, which are combined within substitution–permutation networks (SPNs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancejpollard%2Fhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flancejpollard%2Fhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancejpollard%2Fhash/lists"}