Skip to content

[Fuzzing] 32-bit no ASM Fp fused sumproduct #618

Description

@mratsim
------------------------------------------------------

test_finite_fields_mulsquare xoshiro512** seed: 1777910495

[Suite] Modular squaring is consistent with multiplication on special elements [32-bit words]
[OK] Squaring 0,1,2 with Fake101 [FastSquaring = true]
[OK] Squaring 0,1,2 with Mersenne61 [FastSquaring = true]
[OK] Squaring 0,1,2 with Mersenne127 [FastSquaring = false]
[OK] Squaring 0,1,2 with P224 [FastSquaring = false]
[OK] Squaring 0,1,2 with P256 [FastSquaring = false]
[OK] Squaring 0,1,2 with Secp256k1 [FastSquaring = false]
[OK] Squaring 0,1,2 with BLS12_381 [FastSquaring = true]
[OK] Squaring 0,1,2 with Edwards25519 [FastSquaring = false]
[OK] Squaring 0,1,2 with Bandersnatch [FastSquaring = false]
[OK] Squaring 0,1,2 with Pallas [FastSquaring = false]
[OK] Squaring 0,1,2 with Vesta [FastSquaring = false]

[Suite] Modular Squaring: selected tricky cases [32-bit words]
  [OK] P-256 [FastSquaring = false]

[Suite] Random Modular Squaring is consistent with Modular Multiplication [32-bit words]
  [OK] Random squaring mod P-224 [FastSquaring = false]
  [OK] Random squaring mod P-256 [FastSquaring = false]
  [OK] Random squaring mod Secp256k1 [FastSquaring = false]
  [OK] Random squaring mod BLS12_381 [FastSquaring = true]
  [OK] Random squaring mod Edwards25519 [FastSquaring = false]
  [OK] Random squaring mod Bandersnatch [FastSquaring = false]
  [OK] Random squaring mod Pallas [FastSquaring = false]
  [OK] Random squaring mod Vesta [FastSquaring = false]

[Suite] Modular multiplication - bugs highlighted by property-based testing
  [OK] Edwards25519 - 32-bit Crandall prime acceleration

[Suite] Modular squaring - bugs highlighted by property-based testing
  [OK] a² == (-a)² on for Fp[2^127 - 1] - #61
  [OK] a² == (-a)² on for Fp[2^127 - 1] - #62
  [OK] 32-bit fast squaring on BLS12-381 - #42
  [OK] 32-bit fast squaring on BLS12-381 - #43

[Suite] Random sum products is consistent with naive  [32-bit words]
  [OK] Random sum products mod P-224]
  [OK] Random sum products mod BN254_Nogami]
fatal.nim(62)            sysFatal
Error: unhandled exception: t_finite_fields_mulsquare.nim(363, 7) `bool(r`gensym1906 == r_ref`gensym1906)`  [AssertionDefect]
stack trace: (most recent call last)
Error: execution of an external program failed: '/home/runner/work/constantine/constantine/constantine/build/test_suite/t_finite_fields_mulsquare'

========================== Command exited with code 1 ==========================
[FAIL]: 'nim c -r --passC:-fstack-protector-strong  --passC:-D_FORTIFY_SOURCE=3  -d:CTT_ASM=false  --tlsEmulation=off  -d:danger  --panics:on -d:noSignalHandler  --mm:arc -d:useMalloc  --verbosity:0 --hints:off --warnings:off  --passC:-fno-semantic-interposition  --passC:-falign-functions=64  --passC:-fmerge-all-constants --outdir:build/test_suite  --nimcache:nimcache/tests/math_fields/t_finite_fields_mulsquare.nim tests/math_fields/t_finite_fields_mulsquare.nim' (#18/128)
[FAIL]: Command #18 exited with error 1
================================================================================

proc random_sumprod(Name: static Algebra, N: static int) =
template sumprod_test(random_instancer: untyped) =
block:
var a: array[N, Fp[Name]]
var b: array[N, Fp[Name]]
for i in 0 ..< N:
a[i] = rng.random_instancer(Fp[Name])
b[i] = rng.random_instancer(Fp[Name])
var r, r_ref, t: Fp[Name]
r_ref.prod(a[0], b[0])
for i in 1 ..< N:
t.prod(a[i], b[i])
r_ref += t
r.sumprod(a, b)
doAssert bool(r == r_ref)

Probably an overflow of spare bits.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions