Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fast Recursive SHA256

License

NotificationsYou must be signed in to change notification settings

voidxno/fast-recursive-sha256

Repository files navigation

A fast recursiveSHA-256 (SHA256) implementation in C++ intrinsics withIntel SHA Extensions orARM Cryptography Extensions, and extra source codeoptimizations.

Created as a contribution to optimize the VDF (verifiable delay function) creation part by TimeLord inMMX blockchain.

The SHA256 algorithm used recursively can be a method for securing that an amount of sequential computation time has passed (VDF). Once created, easy to verify with checkpoints and parallel SHA256 processing. A valid, but niche way of using SHA256.

There is also apipelined edition for verifying VDF.

TLDR;

I just want free fast recursive SHA256:

Recommended:

  • Make checks/fallback if Extensions not available

Requirement

CPU: Intel/AMD x64 (w/ SHA Extensions).
CPU: ARMv8 (w/ Cryptography Extensions).
Model: Intel 11th-gen (Rocket Lake), AMD Zen, or later (a few exceptions).
Model: ARMv8, or later (Extensions are optional license, check spec sheet).

Windows: CPU-Z (Instructions) or HWiNFO64 (Features), look forSHA.
Linux:grep -o 'sha_ni' /proc/cpuinfo, empty if not available (Intel).
Linux:grep -o 'sha2' /proc/cpuinfo, empty if not available (ARM).

Usage

To use in your own project. Copyrsha256_fast_x64.cxx orrsha256_fast_arm.cxx file (only one needed). Remaining files are to illustrate optimizations done and perform benchmark. Function call:

voidrsha256_fast(//-- no return value, result to *hashuint8_t*       hash,//-- input/output 32bytes hash/data SHA256 valueconstuint64_t num_iters)//-- number of times to SHA256 32bytes given in *hash

Benchmark

Intel 13th-gen CPU P-core at6.0 GHz (Windows/VS2022):42.48 MH/s

Console output Windows/VS2022

LookBENCHMARK.md for more information, and results.

Optimization

LookOPTIMIZE.md for more information, andCHANGES.md for revisions.

Donation

If you find implementation useful, donations are welcome:

BTC: bc1qtl00g8lctmuud72rv5eqr6kkpt85ws0t2u9s8dETH: 0x5fA8c257b502947A65D399906999D4FC373510B5MMX: mmx1pk95pv4lj5k3y9cwxzuuyznjsgdkqsu7wkxz029nqnenjathtv7suf9qgcXCH: xch1rk473wu3yqlxyyap4f4fhs8knzf4jt6aagtzka0g24hjgskmlv7qcme9gtKAS: kaspa:qqjrwh00du33v4f78re4x3u50420fcvemuu3ye3wy2dhllxtjlhagf04g97hj

[8]ページ先頭

©2009-2025 Movatter.jp