{"id":28199776,"url":"https://github.com/dosaygo-studio/rain","last_synced_at":"2026-03-02T04:01:52.519Z","repository":{"id":180040981,"uuid":"664485304","full_name":"DOSAYGO-STUDIO/rain","owner":"DOSAYGO-STUDIO","description":"The fastest 128-bit and 256-bit hash, passes all tests, and under 140 source lines of code. API library and CLI tool in C++ and NodeJS/Wasm","archived":false,"fork":false,"pushed_at":"2025-12-20T07:15:16.000Z","size":15771,"stargazers_count":130,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"boss","last_synced_at":"2026-02-21T14:10:48.664Z","etag":null,"topics":["call-for-papers","cpp","cryptanalysis","cryptanalysis-tasks","cryptography","cryptohash","emscripten","hash","rain","rainbow","rainhash","rainstorm","wasm"],"latest_commit_sha":null,"homepage":"https://dosaygo-studio.github.io/rain/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DOSAYGO-STUDIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-07-10T04:54:59.000Z","updated_at":"2026-02-04T15:18:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"6078c51b-cc74-43ee-ace5-e18da81f3c6b","html_url":"https://github.com/DOSAYGO-STUDIO/rain","commit_stats":{"total_commits":256,"total_committers":3,"mean_commits":85.33333333333333,"dds":0.515625,"last_synced_commit":"2025f88db3dd4183e52efa6bb79493bc1459af11"},"previous_names":["dosyago/rain","dosaygo-studio/rain","dosaygo-research/rain"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/DOSAYGO-STUDIO/rain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DOSAYGO-STUDIO%2Frain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DOSAYGO-STUDIO%2Frain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DOSAYGO-STUDIO%2Frain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DOSAYGO-STUDIO%2Frain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DOSAYGO-STUDIO","download_url":"https://codeload.github.com/DOSAYGO-STUDIO/rain/tar.gz/refs/heads/boss","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DOSAYGO-STUDIO%2Frain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29992286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["call-for-papers","cpp","cryptanalysis","cryptanalysis-tasks","cryptography","cryptohash","emscripten","hash","rain","rainbow","rainhash","rainstorm","wasm"],"created_at":"2025-05-16T20:05:08.367Z","updated_at":"2026-03-02T04:01:52.505Z","avatar_url":"https://github.com/DOSAYGO-STUDIO.png","language":"C++","readme":"# Rain\n\n\u003e [!TIP]\n\u003e **Example usage (hash everything)**:\n\u003e ```console\n\u003e  find . -type f -print0 | xargs -0 -I{} rainsum {}\n\u003e ```\n\nThis repository features the **Rainbow** and **Rainstorm** hash functions (collectively, **Rain Hashes**), created by [Cris](https://github.com/o0101) at [DOSAYGO](https://github.com/dosyago) and licensed under Apache-2.0. All size variants of both hashes pass **all tests in SMHasher3**. Relevant [results](results) are available in the `results/` directory, or at the [SMHasher3 GitLab repository](https://gitlab.com/fwojcik/smhasher3/-/blob/main/results/README.md). The CLI tool API is similar to standard tools like `sha256sum`, but with more switches to select algorithm and digest length. The hashes produce digests ranging from 64 through to 512 bits wide. See the table below for details.\n\nThe codebase includes:\n\n- A C++ reference implementation\n- A WASM port (for Node.js and browser environments)\n- A Makefile for building all targets\n- An experimental cryptosystem based on [plaintext mining ciphers](https://dosaygo-research.github.io/rain/paper/cipher-note.pdf)\n\n| Algorithm | Speed              | Hash Size        | Purpose                              | Core Mixing Function                              | Security                        |\n|-----------|--------------------|------------------|--------------------------------------|---------------------------------------------------|---------------------------------|\n| Rainbow   | 3 - 6 GiB/s        | 64, 128, 256 bits| General-purpose, non-crypto hash      | Multiplication, addition/subtraction, rotation, XOR| Not designed as cryptographic   |\n| Rainstorm | 2 - 3 GiB/s (4 rds)| 64, 128, 256, 512 bits   | Proposed as a crypto-hash but requires analyses | Addition/subtraction, rotation, XOR                | Unvetted, no formal analysis    |\n\n---\n\n## Table of Contents\n\n- [Usage Options](#usage-options)\n- [Assets](#assets)\n- [Building](#building)\n- [Benchmark](#benchmark)\n- [Repository Structure](#repository-structure)\n- [Rainbow](#rainbow)\n- [Rainstorm - Unvetted for Security](#rainstorm---unvetted-for-security)\n- [Note on Cryptographic Intent](#note-on-cryptographic-intent)\n- [Genesis](#genesis)\n- [License](#license)\n- [Rainsum Field Manual](#rainsum-field-manual)\n  - [1. Introduction](#1-introduction)\n  - [2. Basic Usage](#2-basic-usage)\n    - [2.1 Command Structure](#21-command-structure)\n    - [2.2 Options](#22-options)\n  - [3. Modes of Operation](#3-modes-of-operation)\n    - [3.1 Digest Mode](#31-digest-mode)\n    - [3.2 Stream Mode](#32-stream-mode)\n  - [4. Hash Algorithms and Sizes](#4-hash-algorithms-and-sizes)\n  - [5. Test Vectors](#5-test-vectors)\n  - [6. Seed Values](#6-seed-values)\n  - [7. Help and Version Information](#7-help-and-version-information)\n  - [8. Compilation](#8-compilation)\n  - [9. Conclusion](#9-conclusion)\n- [Developer Information](#developer-information)\n  - [Stability](#stability)\n  - [Test vectors](#test-vectors)\n  - [Building and Installing](#building-and-installing)\n  - [Contributions](#contributions)\n- [Story](#story)\n- [Misue Disclaimer](#misuse-disclaimer)\n\n---\n\n## Usage Options\n\n### JavaScript (WASM) Channel\n\n1. **Node.js Library**\n   Install:\n   ```bash\n   npm i @dosyago/rainsum@latest\n   ```\n   Usage:\n   ```js\n   import { rainbowHash, rainstormHash } from '@dosyago/rainsum';\n\n   const seed = 0x0;\n   const hash = await rainbowHash(256, seed, 'Hello there!');\n   const intendedCryptoHash = await rainstormHash(512, seed, Buffer.from('Hello there!'));\n   ```\n\n2. **Global Binary via NPM**\n   ```bash\n   npm i -g @dosyago/rainsum@latest\n   jsrsum --help\n   ```\n\n### Native Channel\n\n1. **Build everything** (For WASM ensure [Emscripten](https://emscripten.org/docs/getting_started/downloads.html) is installed):\n   ```bash\n   make clean \u0026\u0026 make\n   sudo make install  # optional, installs 'rainsum' globally\n   ```\n\n   If you encounter troubles on macOS use the build script:\n   ```bash\n   ./scripts/build.sh\n   ```\n\n2. **Use as a library or CLI**:\n   - Link `rainstorm.o` or `rainbow.o` into your project, or include `tool.h` and source files from `./src/`.\n   - Use the `rainsum` CLI directly:\n     ```bash\n     rainsum file.txt\n     # By default: Rainbow, 256-bit hash\n     rainsum --help\n     ```\n\n`jsrsum` (via NPM + WASM) mirrors the CLI/API of `rainsum` but runs slower.\n\n---\n\n## Assets\n\n- `rainsum` CLI tool and associated `.o` object files (C++)\n- WASM binary\n- JS CLI tool (`jsrsum`) with an ES Module API exporting `rainbowHash` and `rainstormHash`\n- Scripts:\n  - `./scripts/bench.mjs`: Benchmark JS WASM vs C++\n  - `./scripts/verify.mjs`: Verify correctness\n  - Other utility scripts\n\n---\n\n## Building\n\n```bash\nmake clean \u0026\u0026 make\n```\n\nOptional installation:\n```bash\nsudo make install\n```\n\n---\n\n## Benchmark\n\n**C++ vs WASM (Node.js)**\n\nThese benchmarks highlight the performance gap between native C++ and the WASM-based implementation under Node.js:\n\n```\nTest Input \u0026 Size          Run   C++ Version        WASM Version       Speedup\n10 bytes (input1)          1     6,964,250 ns     129,892,625 ns     18x (C++ wins!)\n100 bytes (input2)         1     6,876,208 ns     127,928,542 ns     18x (C++ wins!)\n1,000 bytes (input3)       1     6,583,125 ns     127,668,333 ns     19x (C++ wins!)\n10,000 bytes (input4)      1     5,920,167 ns     127,438,666 ns     21x (C++ wins!)\n100,000 bytes (input5)     1     6,214,916 ns     127,551,791 ns     20x (C++ wins!)\n1,000,000 bytes (input6)   1     5,321,500 ns     126,986,167 ns     23x (C++ wins!)\n10,000,000 bytes (input7)  1     9,879,042 ns     132,929,875 ns     13x (C++ wins!)\n100,000,000 bytes (input8) 1    49,761,375 ns     207,500,917 ns      4x (C++ wins!)\n```\n\nRuns 2 and 3 show similar results, consistently demonstrating that the native C++ version outperforms the WASM variant by a factor of ~3x to ~25x, depending on input size.\n\n---\n\n## Repository Structure\n\n```\n.\n├─ LICENSE.txt\n├─ Makefile\n├─ README.md\n├─ docs/\n├─ js/\n├─ rain/\n│  ├─ bin/\n│  └─ obj/\n├─ results/\n│  ├─ dieharder/\n│  └─ smhasher3/\n├─ scripts/\n└─ src/\n   ├─ common.h\n   ├─ rainbow.cpp\n   ├─ rainstorm.cpp\n   ├─ rainsum.cpp\n   ├─ tool.h\n   └─ ...\n```\n\n---\n\n## Rainbow\n\n**Rainbow** is a fast, general-purpose non-cryptographic hash that can produce 64-bit, 128-bit, or 256-bit hashes. It is simple, compact (~140 LOC), and passes all SMHasher3 tests for its 64-bit variant. Its prime-based mixing function yields strong avalanche properties.\n\n---\n\n## Rainstorm - Unvetted for Security\n\n**Rainstorm** is a slower, more complex hash function inspired by cryptographic designs. It supports output sizes of 64 to 512 bits and adjustable rounds. While it uses operations reminiscent of cryptographic hashes, it **is not formally analyzed by any 3rd-party**. Consider it experimental, but designed to be secure. \n\n### Documents\n\n- **Rainstorm Formal Spec (Draft)**: [PDF](docs/paper/storm-spec.pdf)\n- **Rainstorm Crypto Note**: [PDF](docs/paper/crypto-note.pdf)\n\n---\n\n## Note on Cryptographic Intent\n\nRainstorm's design includes concepts from cryptographic hashing, but without formal analysis, it should not be considered secure. Feedback and analysis are welcome.\n\n---\n\n## Genesis\n\nThe mixing functions were inspired by Discohash and refined iteratively using SMHasher3 over a few weeks, guided by experience and intuition. Careful prime selection ensured broad avalanche properties.\n\n---\n\n## License\n\nApache-2.0 © 2023 - 2024 Cris \u0026 DOSAYGO Corporation. With improvements \u0026copy; Frank J. T. Wojcik 2023\n\n---\n\n# Rainsum Field Manual\n\n## 1. Introduction\n\nRainsum is a CLI tool for hashing input data using Rainbow or Rainstorm. It supports two primary modes:\n- **Digest Mode:** Produces a fixed-length hexadecimal output.\n- **Stream Mode:** Iteratively feeds the hash back into itself to produce a variable-length stream of binary output.\n\nA JavaScript WASM version (`jsrsum`) offers similar functionality at reduced speed.\n\n## 2. Basic Usage\n\n### 2.1 Command Structure\n\n```\nrainsum [OPTIONS] [INFILE]\n```\n\nIf no `INFILE` is provided, input is read from standard input.\n\n### 2.2 Options\n\n- `-m, --mode [digest|stream]`: Default `digest`.\n- `-a, --algorithm [bow|storm]`: Choose `rainbow` (`bow`) or `rainstorm` (`storm`). Default `storm`.\n- `-s, --size [64-256|64-512]`: Hash size in bits. Default `256`. Rainbow supports 64,128,256. Rainstorm supports 64,128,256,512.\n- `-o, --output-file FILE`: Write output to `FILE`.\n- `-t, --test-vectors`: Run test vectors.\n- `-l, --output-length HASHES`: For stream mode, number of iterations.\n- `--seed VALUE`: Sets the seed (64-bit number or string). A string seed is hashed by Rainstorm to produce a 64-bit seed.\n- `-h, --help`: Show help.\n- `-v, --version`: Print version.\n\n## 3. Modes of Operation\n\n### 3.1 Digest Mode\n\nProduces a single, fixed-size hash in hex. For example:\n\n```bash\nrainsum -m digest -a storm -s 256 -o output.txt input.txt\n```\n\n### 3.2 Stream Mode\n\nGenerates a stream of hashes by repeatedly feeding the previous hash into the function. Specify iterations with `-l`. Example:\n\n```bash\nrainsum -m stream -a storm -s 512 -l 1000000 -o output.txt input.txt\n```\n\n## 4. Hash Algorithms and Sizes\n\n- `bow` (Rainbow): 64, 128, 256 bits\n- `storm` (Rainstorm): 64, 128, 256, 512 bits\n\n## 5. Test Vectors\n\nUse `-t, --test-vectors` to verify correctness against known inputs.\n\n## 6. Seed Values\n\nUse `--seed` to set a custom seed. String seeds are hashed to a 64-bit value.\n\n## 7. Help and Version Information\n\n- `rainsum --help`\n- `rainsum --version`\n\n## 8. Compilation\n\nA modern C++17 compiler is required. Run `make` to build. Ensure necessary build tools (like `xcode-select` on macOS) are installed. On macOS you should use `./scripts/build.sh` to ensure that path to the correct compiler and SDK is accurate, modify that script if needed for your system.\n\n## 9. Conclusion\n\nRainsum provides flexible hashing through Rainbow or Rainstorm. Experiment freely and enjoy the convenience of multiple modes and sizes.\n\n---\n\n# Developer Information\n\n## Stability\n\nThe hash definitions may evolve. Changes that affect outputs will be indicated by version increments.\n\n## Test Vectors\n\nRefer to `--test-vectors` and `results/` for known outputs and verification.\n\n## Building and Installing\n\n```bash\nmake\nsudo make install\nrainsum --help\n```\n\n## Contributions\n\nImprovements, analyses, and faster implementations are welcomed.\n\n---\n\n# Story\n\nThis is my hash included in the best hash testing library out there \"SMHasher3\" maintained by Frank T Wojcik: https://gitlab.com/fwojcik/smhasher3\nThis test lib has many improvements over SMHasher 1 \u0026 2, listed on the previous link. Results are: https://gitlab.com/fwojcik/smhasher3/-/blob/main/results/README.md\n\nRainbow is the fastest 128-bit hash, and the fastest 256-bit hash (non-crypto). The 8th fastest 64-bit hash (by family, or 9th fastest overall, and 13-th fatest overall if you include 32-bit hashes). The advantage of rainbow is its easily scalable output size (64, 128 and 256), its high quality (passes all the tests), and its utter simplicity: it is under 140 source lines of code, easily readable\n\nThe random constants are primes that were selected based on their avalanche quality under a multiply modulo operation. This part of the development was interesting different primes had very distinctly different avalanche qualities. The highest quality primes caused good avalanche (~ 50% bit flip probability) across the widest possible set of bits, on average. These are quite rare. A lot of large primes only avalanche across a narrow range of bits, even in a 128-bit space. The search program took a couple of days to discover all these primes running on a 2020s era MBP. Primes are chosen because they give a complete residue set under the modulus, ensuring a long cycle length at least regarding the nominal test operation.\n\nThe rest of the hash was developed by trial and error using my intuition on developing hashes arising from long experience of doing so, and using SMHasher3 to evaluate the results, by iterating to improve and re-testing, over a period of a couple of weeks in the holidays a few years ago. I started making hash functions in my teens as a fun hobby.\n\n---\n\n### Misuse Disclaimer\n\n\u003e [!WARNING]\n\u003e Do not use this for bad things.\n\nThis project is provided under the Apache-2.0 license and is intended for lawful and ethical purposes only. The author(s) of this software explicitly disclaim any liability for its use in activities that violate applicable laws, regulations, or ethical standards. By using this project, you agree to comply with all relevant laws and not to use it for malicious or harmful purposes, including but not limited to:\n\n- Developing or distributing malware, ransomware, or other harmful software.\n- Compromising the privacy, security, or rights of others.\n- Engaging in illegal surveillance or unauthorized access to systems.\n\nThe responsibility for the use or misuse of this software lies entirely with the user. If you do not agree with these terms, do not use this software.\n\n  **Copyright 2024 Dosyago Corporation USA and @o0101**\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n**Reiteration of some key sections from the LICENSE**\n\n   7. **Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.**\n\n   8. **Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.**\n\n   9. **Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.**\n\n\n---\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdosaygo-studio%2Frain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdosaygo-studio%2Frain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdosaygo-studio%2Frain/lists"}