All Projects → piggypiggy → fp256

piggypiggy / fp256

Licence: Apache-2.0 license
An efficient library for 256 bit integer arithmetic

Programming Languages

c
50402 projects - #5 most used programming language
perl
6916 projects
assembly
5116 projects
CMake
9771 projects

Projects that are alternatives of or similar to fp256

docker-dns-ad-blocker
A lightweight dnsmasq DNS server to block traffic to known ad servers with optional DNSCrypt support. Supports x86_64 and Raspberry Pi (armhf).
Stars: ✭ 78 (+271.43%)
Mutual labels:  x86-64, aarch64
kempe
Kempe is a compiled stack-based language
Stars: ✭ 54 (+157.14%)
Mutual labels:  x86-64, aarch64
Rcore
Rust version of THU uCore OS. Linux compatible.
Stars: ✭ 2,175 (+10257.14%)
Mutual labels:  x86-64, aarch64
Unisimd Assembler
SIMD macro assembler unified for ARM, MIPS, PPC and x86
Stars: ✭ 63 (+200%)
Mutual labels:  x86-64, aarch64
lsp-dsp-lib
DSP library for signal processing
Stars: ✭ 37 (+76.19%)
Mutual labels:  x86-64, aarch64
Chrysalisp
Parallel OS, with GUI, Terminal, OO Assembler, Class libraries, C-Script compiler, Lisp interpreter and more...
Stars: ✭ 1,205 (+5638.1%)
Mutual labels:  x86-64, aarch64
Mandibule
linux elf injector for x86 x86_64 arm arm64
Stars: ✭ 171 (+714.29%)
Mutual labels:  x86-64, aarch64
Cemu
Cheap EMUlator: lightweight multi-architecture assembly playground
Stars: ✭ 666 (+3071.43%)
Mutual labels:  x86-64, aarch64
Asmjit
Machine code generation for C++
Stars: ✭ 2,874 (+13585.71%)
Mutual labels:  x86-64, aarch64
Onednn
oneAPI Deep Neural Network Library (oneDNN)
Stars: ✭ 2,600 (+12280.95%)
Mutual labels:  x86-64, aarch64
Mir
A light-weight JIT compiler based on MIR (Medium Internal Representation)
Stars: ✭ 1,075 (+5019.05%)
Mutual labels:  x86-64, aarch64
profiler-api
The portable version of JetBrains profiler API for .NET Framework / .NET Core / .NET / .NET Standard / Mono
Stars: ✭ 21 (+0%)
Mutual labels:  x86-64, aarch64
Reko
Reko is a binary decompiler.
Stars: ✭ 942 (+4385.71%)
Mutual labels:  x86-64, aarch64
Docker Homebridge
Homebridge Docker. HomeKit support for the impatient using Docker on x86_64, Raspberry Pi (armhf) and ARM64. Includes ffmpeg + libfdk-aac.
Stars: ✭ 1,847 (+8695.24%)
Mutual labels:  x86-64, aarch64
Rappel
A linux-based assembly REPL for x86, amd64, armv7, and armv8
Stars: ✭ 818 (+3795.24%)
Mutual labels:  x86-64, aarch64
Mcsema
Framework for lifting x86, amd64, aarch64, sparc32, and sparc64 program binaries to LLVM bitcode
Stars: ✭ 2,198 (+10366.67%)
Mutual labels:  x86-64, aarch64
Docker Cloudflare Ddns
A small amd64/ARM/ARM64 Docker image that allows you to use CloudFlare as a DDNS / DynDNS Provider.
Stars: ✭ 467 (+2123.81%)
Mutual labels:  x86-64, aarch64
Remill
Library for lifting of x86, amd64, and aarch64 machine code to LLVM bitcode
Stars: ✭ 633 (+2914.29%)
Mutual labels:  x86-64, aarch64
Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (+742.86%)
Mutual labels:  x86-64, aarch64
libcluon
libcluon is a small and efficient, single-file and header-only library written in modern C++ to power microservices.
Stars: ✭ 81 (+285.71%)
Mutual labels:  x86-64, aarch64

linux-x64 macos-x64

windows-x64-vs2017 windows-x64-vs2019

qemu-aarch64 qemu-riscv64

introduction

fp256 is an efficient library implemented in C and assembly for 256 bit integer arithmetic.

It supports Windows, Linux and Macosx on x86_64 and arm64 processor, and can be compiled with MSVC, mingw-w64, gcc and clang.

implementation

  • Use 4×64bit to represent 256 bit integer.

  • Leveled api :
    low level api operates directly on integer array, most low level api are specific for 256 bit integer, there are also a few api for arbitrary length array.
    high level api operates on 256 bit integer.

  • Most low level arithmetic are implemented in assembly, including add, mul, u256 mul, div, shift, exgcd, mont mul, etc, they are very efficient and (maybe)well commented, see ll/x64, ll/aarch64 and ll/riscv64.

compilation

$ mkdir build
$ cd build
$ cmake ..
$ make -j
$ make test

Or cross compilation (cmake toolchain files are here):

$ mkdir build
$ cd build
$ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/aarch64-linux-gcc.cmake ..
$ make -j

configuration

-DCMAKE_BUILD_TYPE : possible values are empty, Debug, Release, RelWithDebInfo and MinSizeRel, default is Release.
-DCMAKE_INSTALL_PREFIX : where to install fp256 library, default is /usr/local.
-DBUILD_STATIC : build static library, default is ON.
-DBUILD_SHARED : build shared library, default is ON.
-DUSE_DEV_RANDOM : use /dev/random to get random number, default is OFF(use /dev/urandom).
-DUSE_ASM : use assembly code, default is ON. it can not be turned off since some algorithms have no C implementation to fall back yet.
-DUSE_ASAN : use AddressSanitizer, default is OFF.

TODO

  • Add prime test, modular exponential, square root related, etc.
  • Constant-time implementation of division and exgcd.
  • more tests.

benchmark

Some of benchmark results are listed below. Build and run build/bench/bench to get full result.

AMD Ryzen 5 4600U 2.1GHz, Ubuntu 20.04 LTS, gcc-9.3.0

arithmetic(256 bit) cycles / op op / s
naive div 428 4890000
gcd 3784 554000
mod add 330 6340000
mod sqr 491 4260000
mod mul 509 4110000
mod inv 4628 453000
mod exp 17000 123000
mont mul 130 16000000
mont sqr 117 17800000

license

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].