Logo
Explore Help
Sign In
logos-storage/constantine
1
0
Fork 0
You've already forked constantine
mirror of https://github.com/logos-storage/constantine.git synced 2026-01-03 05:33:07 +00:00
Code Issues Packages Projects Releases Wiki Activity
constantine/tests/math_arbitrary_precision/t_bigints_mod.nim

19 lines
362 B
Nim
Raw Normal View History

Modular exponentiation (arbitrary output) and EIP-198 (#242) * implement arbitrary precision modular exponentiation (prerequisite EIP-198) * [modexp] implement exponentiation modulo 2ᵏ * add inversion (mod 2ᵏ) * [modexp] High-level wrapper for powmod with odd modulus * [modexp] faster exponentiation (mod 2ᵏ) for even case and Euler's totient function odd case * [modexp] implement general fast modular exponentiation * Fix modular reduction with 64-bit modulus + fuzz powmod vs GMP * add benchmark * add EIP-198 support * fixups following self review * fix test paths
2023-06-01 23:38:41 +02:00
# From issue #241
import
../../constantine/math/[
arithmetic,
io/io_bigints]
let a = BigInt[64].fromUint(0xa0e5cb56a1c08396'u64)
let M = BigInt[64].fromUint(0xae57180eceb0206f'u64)
var r: BigInt[64]
r.reduce(a, M)
let rU64 = 0xa0e5cb56a1c08396'u64 mod 0xae57180eceb0206f'u64
echo r.toHex()
doAssert rU64 == a.limbs[0].uint64
doAssert bool(a == r)
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.0 Page: 39ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API