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

Updates #75

Merged
merged 16 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ CXXFLAGS = -std=c++17 -Wall -Wextra -pedantic -O3
DEPFLAGS = -MMD -MF $(@:.o=.d)
LDFLAGS =

EMCCFLAGS = -O3 -s WASM=1 -s EXPORTED_FUNCTIONS="['_rainstormHash64', '_rainstormHash128', '_rainstormHash256', '_rainstormHash512', 'stringToUTF8', 'lengthBytesUTF8', '_malloc', '_free']" -s EXPORTED_FUNCTIONS="['_rainbowHash64', '_rainbowHash128', '_rainbowHash256', 'stringToUTF8', 'lengthBytesUTF8', '_malloc', '_free']" -s EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']" -s WASM_BIGINT=1 -s ALLOW_MEMORY_GROWTH=1
EMCCFLAGS = -O3 -s WASM=1 -s EXPORTED_FUNCTIONS="['_rainbowHash64', '_rainbowHash128', '_rainbowHash256', 'stringToUTF8', 'lengthBytesUTF8', '_malloc', '_free']" -s EXPORTED_RUNTIME_METHODS="['wasmExports', 'ccall', 'cwrap']" -s WASM_BIGINT=1 -s ALLOW_MEMORY_GROWTH=1 -g

OBJDIR = rain/obj
BUILDDIR = rain/bin
SRCS = $(wildcard src/*.cpp)
OBJS = $(addprefix $(OBJDIR)/,$(notdir $(SRCS:.cpp=.o)))
DEPS = $(OBJS:.o=.d)

WASMDIR = wasm
WASMDIR = js/wasm
STORM_WASM_SOURCE = src/rainstorm.cpp
BOW_WASM_SOURCE = src/rainbow.cpp
WASM_OUTPUT = docs/rain.wasm
JS_OUTPUT = docs/rain.js
JS_OUTPUT = docs/rain.cjs

all: directories node_modules rainsum link rainwasm

Expand Down Expand Up @@ -44,9 +44,10 @@ rainwasm: $(WASM_OUTPUT) $(JS_OUTPUT)

$(WASM_OUTPUT) $(JS_OUTPUT): $(STORM_WASM_SOURCE) $(BOW_WASM_SOURCE)
@[ -d docs ] || mkdir -p docs
@[ -d wasm ] || mkdir -p wasm
@[ -d ${WASMDIR} ] || mkdir -p ${WASMDIR}
emcc $(EMCCFLAGS) -o docs/rain.html $(STORM_WASM_SOURCE) $(BOW_WASM_SOURCE)
cp $(WASM_OUTPUT) $(JS_OUTPUT) wasm/
mv docs/rain.js $(JS_OUTPUT)
cp $(WASM_OUTPUT) $(JS_OUTPUT) ${WASMDIR}
rm docs/rain.html

link:
Expand Down
38 changes: 38 additions & 0 deletions PAPER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Comprehensive Overview of the Rainstorm Hash Function

## Abstract
The Rainstorm hash function, a creation of Cris at DOSYAGO in 2023, stands as a notable cryptographic hash function featuring a 1024-bit internal state and 512-bit blocks. Capable of producing outputs up to 512 bits, it doubles as an eXtensible Output Function (XOF) and a keystream generator. This paper presents a comprehensive overview of the Rainstorm algorithm, incorporating insights from recent empirical testing.

## Introduction
Critical to cryptographic applications, hash functions ensure data integrity, authentication, and non-repudiation. Rainstorm, with its novel approach, offers high security and efficiency. Its block-based mechanism leverages bitwise operations and modular arithmetic over prime numbers for robust cryptographic processing.

## Algorithm Overview
Rainstorm functions through 512-bit blocks while maintaining a 1024-bit internal state. Its design, incorporating selected primes and rotation amounts, aims for optimal avalanche properties. The algorithm's iterative nature involves multiple rounds of input data processing.

### Key Features:
- **Block Size**: 512 bits
- **Internal State**: 1024 bits
- **Output Size**: Up to 512 bits
- **Rounds**: 4 regular, 2 final per block
- **Primes and Rotations**: Prime numbers and specific rotation amounts for enhanced cryptographic security

## Implementation
Implemented in C++ for efficiency and portability, Rainstorm is optimized across various platforms, including Emscripten for WebAssembly. Inline functions and templates in its codebase contribute to its performance and flexibility.

## Empirical Testing and Cryptographic Properties
### Performance Analysis
Rainstorm's performance, as validated by SMHasher3 tests, showcases consistent efficiency across key sizes, averaging about 247 cycles per hash for small keys. In bulk speed tests, it achieved 1.92 GiB/sec at 3.5 GHz, demonstrating high throughput capabilities.

### Avalanche Effect
Testing confirmed Rainstorm's strong avalanche effect. Changes in input bits resulted in significant and unpredictable output changes, with bias percentages ranging from 0.632% to 0.877%, indicative of a robust avalanche effect.

### Collision Resistance
Rainstorm displayed excellent collision resistance in 'Zeroes', 'Cyclic', and 'Sparse' tests at higher bit levels (64-bit to 256-bit). Some deviations at lower bit levels (27-bit to 32-bit) were within acceptable ranges, affirming the algorithm's resistance to collision attacks.

### Bit Independence
The Bit Independence Criteria (BIC) tests showed low maximum bias values, demonstrating a high level of independence among output bits and reinforcing the algorithm's resilience against common cryptographic attacks.

## Conclusion
Integrating empirical testing results, the Rainstorm hash function emerges as a sophisticated, reliable candidate in the cryptographic domain. Its design demonstrates a thoughtful approach to achieving key cryptographic properties such as efficiency, strong avalanche effect, collision resistance, and bit independence. Continued evaluation and adaptation in response to new research are vital for its ongoing relevance and application in cryptographic solutions.


Loading