2023-06-01 23:38:41 +02:00
|
|
|
# From issue #241
|
|
|
|
|
|
|
|
|
|
import
|
|
|
|
|
../../constantine/math/[
|
|
|
|
|
arithmetic,
|
2023-10-19 01:20:52 +02:00
|
|
|
io/io_bigints],
|
2023-10-22 03:54:09 +02:00
|
|
|
../../constantine/math_arbitrary_precision/arithmetic/limbs_divmod_vartime,
|
|
|
|
|
../../constantine/platforms/abstractions
|
2023-06-01 23:38:41 +02:00
|
|
|
|
|
|
|
|
let a = BigInt[64].fromUint(0xa0e5cb56a1c08396'u64)
|
|
|
|
|
let M = BigInt[64].fromUint(0xae57180eceb0206f'u64)
|
|
|
|
|
|
2023-10-19 01:20:52 +02:00
|
|
|
var r, r2: BigInt[64]
|
2023-06-01 23:38:41 +02:00
|
|
|
|
|
|
|
|
r.reduce(a, M)
|
2023-10-19 01:20:52 +02:00
|
|
|
doAssert r2.limbs.reduce_vartime(a.limbs, M.limbs)
|
2023-06-01 23:38:41 +02:00
|
|
|
|
2023-10-22 03:54:09 +02:00
|
|
|
let rBase = cast[BaseType](0xa0e5cb56a1c08396'u64) mod cast[BaseType](0xae57180eceb0206f'u64)
|
2023-10-19 01:20:52 +02:00
|
|
|
# echo r.toHex()
|
2023-06-01 23:38:41 +02:00
|
|
|
|
2023-10-22 03:54:09 +02:00
|
|
|
doAssert rBase == a.limbs[0].BaseType
|
2023-10-19 01:20:52 +02:00
|
|
|
doAssert bool(a == r)
|
|
|
|
|
echo "SUCCESS: t_bigints_mod.nim"
|