#sloth #subspace #opencl #codec #permutation #blockchain #cpu

no-std sloth256-189

Encoder/decoder for the Subspace Network Blockchain based on the SLOTH permutation

10 unstable releases (3 breaking)

0.4.2 Jun 21, 2022
0.4.1 Jun 13, 2022
0.3.2 May 17, 2022
0.3.0 Mar 29, 2022
0.1.0 Aug 31, 2021

#3 in #subspace

MIT/Apache

245KB
6.5K SLoC

Perl 2K SLoC // 0.2% comments GNU Style Assembly 1.5K SLoC CUDA 1K SLoC // 0.0% comments C 879 SLoC // 0.0% comments Assembly 550 SLoC C++ 545 SLoC // 0.2% comments Rust 378 SLoC // 0.1% comments Shell 11 SLoC

sloth256-189

Encoder/decoder for the Subspace Network Blockchain based on the SLOTH permutation

CI Crates.io Docs

This is an adaptation of SLOTH (slow-timed hash function) into a time-asymmetric permutation using a standard CBC block cipher.

This library consists of 2 major implementations:

  • CPU
  • OpenCL (requires opencl feature to be enabled)

WebAssembly (no_std) is also supported, but llvm-ar command needs to be available for build.rs to succeed in that case.

CPU

CPU Implementation contains 3 flavors:

  • optimized assembly-assisted implementation for x86-64 processors with ADX ISA extension (Linux, macOS and Windows)
  • any 64-bt platform with support for __int128 C type (modern GCC/Clang, but not MSVC)
  • fallback for other platforms

For more details, README.md under src/cpu can be referred.

OpenCL

OpenCL is a universal implementation that supports AMD (ROCm), Nvidia (CUDA) and Intel GPUs, including support for multiple GPU vendors on the same machine at the same time.

Details of the OpenCL implementation can be found in mod.rs under src/opencl.

How to test

Simply run cargo test at the root folder

  • use cargo test --features=opencl for enabling opencl tests (openCL drivers must be installed on your device)

How to benchmark

Simply run cargo bench at the root folder

  • use cargo bench --features=opencl for enabling opencl tests (openCL drivers must be installed on your device)

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in cc-rs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–1.4MB
~18K SLoC