-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Randomized testing failure: EC Add G2 #65
Labels
Comments
Also commit 0400187, seed 1592676115, BLS12-381 - 32-bit https://github.com/mratsim/constantine/runs/791167555#step:15:2057 Repro, 32-bit again import
# Standard library
std/[unittest, times],
# Internals
../constantine/config/[common, curves],
../constantine/[arithmetic, towers],
../constantine/io/[io_bigints, io_fields, io_towers],
../constantine/elliptic/[ec_weierstrass_affine, ec_weierstrass_projective]
proc trySetFromCoordsXandZ_debug*[F](P: var ECP_SWei_Proj[F], x, z: F): SecretBool =
## Try to create a point the elliptic curve
## Y²Z = X³ + aXZ² + bZ³ (projective coordinates)
## y² = x³ + a x + b (affine coordinate)
## return true and update `P` if `x` leads to a valid point
## return false otherwise, in that case `P` is undefined.
##
## Note: Dedicated robust procedures for hashing-to-curve
## will be provided, this is intended for testing purposes.
P.y.curve_eq_rhs(x)
echo "P.y: ", P.y.toHex()
echo "P.y.isSquare: ", bool P.y.isSquare
result = sqrt_if_square(P.y)
echo "P.y.wasSquare: ", bool result
P.x.prod(x, z)
P.y *= z
P.z = z
var a, b, c: ECP_SWei_Proj[Fp2[BLS12_381]]
var ax, az, bx, bz, cx, cz: Fp2[BLS12_381]
ax.fromHex(
c0 = "0x0be65dc3f260e3814b86f997a256dc6cf5cbfc536ed257455f48985751c758b6d3efc005c38b00027588befff802fffc",
c1 = "0x015802786d80b1c7e206290223e4440c40a8da49575c7cc40ca93b99392944fd084ba00124b2fdfde907000000025552"
)
az.fromHex(
c0 = "0x13f1dcf37a53c48a5c071a972236ea6cebce5843674a5324542885d7098337b0e2ebe003b80bd801f588ffb7f55efbdb",
c1 = "0x05b5dec1fa80e4935c05fa869055ec6cb5b64fc37051d74557088c4753c758baeb31fd03420ae00155fe7e000002fffb"
)
bx.fromHex(
c0 = "0x0beb9e43fa1f34933c06ea5c9206536d67ce585330525744fe485756817f46ba53f3f00bc40c00027188ffeefbf2efe7",
c1 = "0x15f65ebdf640e4525c051a976256ec6d778c185370524f3d5f48905741c6d829ebf3ff6ba34abfb87607fed3cfaabfa8"
)
bz.fromHex(
c0 = "0x16fbb84711c0596bd3916126d2d0caa1da00b1bc116b70ff4938b574243aa76f754d5f05309fffa90ffbeff9e900b043",
c1 = "0x13d2848256ff557fbd1601aa27b8f07384e7faca4ae18d030c55883a36d63b1f4778000757ff780163f57ffffffee469"
)
cx.fromHex(
c0 = "0x15d0dd8bf97fe1eb37fe9a827a56e9665ace4bd168120cbd5b208e56f18f547aeaf2000b2289effa61fff7300002f7b9",
c1 = "0x15f65ec3fa80e4832ec68a97a256ec6d734e27cee05257435ef898554cc748bae3cfda0b998277c27606bffdf202ff7c"
)
cz.fromHex(
c0 = "0x05f61d97f970e1867be71a17a1d6e46d764e53ce7051d5455f4697d7139f54b8eb63f80bc40bfffe6e04fbffb5d2efba",
c1 = "0x15f65ec3f63fe0115b9ee2871232dc63378e584b6fc95742d807184cbb4735faebf4000ac40afd727608dfef8002ff7c"
)
doAssert bool a.trySetFromCoordsXandZ_debug(ax, az)
doAssert bool b.trySetFromCoordsXandZ_debug(bx, bz)
doAssert bool c.trySetFromCoordsXandZ_debug(cx, cz)
echo "a.x: ", a.x.toHex()
echo "a.y: ", a.y.toHex()
echo "a.z: ", a.z.toHex()
echo ""
echo "b.x: ", b.x.toHex()
echo "b.y: ", b.y.toHex()
echo "b.z: ", b.z.toHex()
echo ""
echo "c.x: ", c.x.toHex()
echo "c.y: ", c.y.toHex()
echo "c.z: ", c.z.toHex()
var tmp1{.noInit.}, tmp2{.noInit.}: ECP_SWei_Proj[Fp2[BLS12_381]]
# r0 = (a + b) + c
tmp1.sum(a, b)
tmp2.sum(tmp1, c)
let r0 = tmp2
# r1 = a + (b + c)
tmp1.sum(b, c)
tmp2.sum(a, tmp1)
let r1 = tmp2
# r2 = (a + c) + b
tmp1.sum(a, c)
tmp2.sum(tmp1, b)
let r2 = tmp2
# r3 = a + (c + b)
tmp1.sum(c, b)
tmp2.sum(a, tmp1)
let r3 = tmp2
# r4 = (c + a) + b
tmp1.sum(c, a)
tmp2.sum(tmp1, b)
let r4 = tmp2
# ...
doAssert bool(r0 == r1)
doAssert bool(r0 == r2)
doAssert bool(r0 == r3)
doAssert bool(r0 == r4) |
https://github.com/mratsim/constantine/runs/791098558#step:13:577 Another sqrt issue import
# Standard library
std/[unittest, times],
# Internals
../constantine/config/[common, curves],
../constantine/[arithmetic, towers],
../constantine/io/[io_bigints, io_fields, io_towers],
../constantine/elliptic/[ec_weierstrass_affine, ec_weierstrass_projective]
proc trySetFromCoordsXandZ_debug*[F](P: var ECP_SWei_Proj[F], x, z: F): SecretBool =
## Try to create a point the elliptic curve
## Y²Z = X³ + aXZ² + bZ³ (projective coordinates)
## y² = x³ + a x + b (affine coordinate)
## return true and update `P` if `x` leads to a valid point
## return false otherwise, in that case `P` is undefined.
##
## Note: Dedicated robust procedures for hashing-to-curve
## will be provided, this is intended for testing purposes.
P.y.curve_eq_rhs(x)
echo "P.y: ", P.y.toHex()
echo "P.y.isSquare: ", bool P.y.isSquare
result = sqrt_if_square(P.y)
echo "P.y.wasSquare: ", bool result
P.x.prod(x, z)
P.y *= z
P.z = z
var a, b, c: ECP_SWei_Proj[Fp2[BLS12_381]]
var ax, az, bx, bz, cx, cz: Fp2[BLS12_381]
ax.fromHex(
c0 = "0x0206c8357bce498e14724363fd8303be0d9dada03288450b75d7e38da4d271cfdd98c7235571ee58f63929cd6210a809",
c1 = "0x0419d3333523d23a3a59181bb6c519d2d2aa0f83f51c6bd5b916d82447a02f6143894943f90dfc8faf0524016538e200"
)
az.fromHex(
c0 = "0x0c0b324ebb784e2223657e1d54c37bebc453f55aa4dffa3e50bec37c95afa43e3e1e562d5c30f9360ec3710a486a6683",
c1 = "0x141a351b0c423f0bb9680dba5047c3364013e4cc9d2b65f467436dabe92fa164a72f3ba98d387f9ba36fd687b6084ac0"
)
bx.fromHex(
c0 = "0x00685bd1b3e4bd34518fb984b4387e0acc3844db814a1a86d0f0b8ea287e44c7894ee00ba0fdd4bef410982f39097613",
c1 = "0x059d602ef0ff0406ab299c2024e6df7f243954df7fc948a9d5965adffe00b5108de49d3e2603e0415500fc1007078457"
)
bz.fromHex(
c0 = "0x031bbb7e0ff9995ae2b7f223d4a8c536b0c1c8e08bd0720cd49242a516fc2e8749077b2b04b637b07d30499f5e1bacbf",
c1 = "0x0e788191485934ff8b69796fa6103db6b203a6f3def033c9d0899f709fc8e298718afa0fcd7e6c973aec2e9a2a69bc0c"
)
cx.fromHex(
c0 = "0x0ed6d4f86a8537338e041dd0b388f78dc15ebdc0da21487604f5485d3407c9830897b163e76e1c23fe92f3f4518e6396",
c1 = "0x04e49e91837d18ed72fcd84b084200593814ab0cb8d3d5d8410c522f111b4c8e9c698fc188af2bfec0c5ebba48218571"
)
cz.fromHex(
c0 = "0x13695be638f4c0c8cb845d25cf5e0439afb8216d1facf84abc1a3a3d138db644345f1a3214b3c22f7e7682829b1a2fe1",
c1 = "0x0157a74d9903679d2ac4ef2bdf464238202d6984cb5adf74a4ed1d550d6b1e6a8ba7d41764561741e618c277a853bf93"
)
doAssert bool a.trySetFromCoordsXandZ_debug(ax, az)
doAssert bool b.trySetFromCoordsXandZ_debug(bx, bz)
doAssert bool c.trySetFromCoordsXandZ_debug(cx, cz)
echo "a.x: ", a.x.toHex()
echo "a.y: ", a.y.toHex()
echo "a.z: ", a.z.toHex()
echo ""
echo "b.x: ", b.x.toHex()
echo "b.y: ", b.y.toHex()
echo "b.z: ", b.z.toHex()
echo ""
echo "c.x: ", c.x.toHex()
echo "c.y: ", c.y.toHex()
echo "c.z: ", c.z.toHex()
var tmp1{.noInit.}, tmp2{.noInit.}: ECP_SWei_Proj[Fp2[BLS12_381]]
# r0 = (a + b) + c
tmp1.sum(a, b)
tmp2.sum(tmp1, c)
let r0 = tmp2
# r1 = a + (b + c)
tmp1.sum(b, c)
tmp2.sum(a, tmp1)
let r1 = tmp2
# r2 = (a + c) + b
tmp1.sum(a, c)
tmp2.sum(tmp1, b)
let r2 = tmp2
# r3 = a + (c + b)
tmp1.sum(c, b)
tmp2.sum(a, tmp1)
let r3 = tmp2
# r4 = (c + a) + b
tmp1.sum(c, a)
tmp2.sum(tmp1, b)
let r4 = tmp2
# ...
doAssert bool(r0 == r1)
doAssert bool(r0 == r2)
doAssert bool(r0 == r3)
doAssert bool(r0 == r4)
|
Merged
2 tasks
mratsim
added a commit
that referenced
this issue
Jun 22, 2020
* Add test case for #30 - Euler's criterion doesn't return 1 for a square * Detect #42 in the test suite * Detect #43 in the test suite * comment in sqrt tests * Add #67 to the anti-regression suite * Add #61 to the anti-regression suite * Add #62 to anti-regression suite * Add #60 to the anti-regression suite * Add #64 to the test suite * Add #65 - case 1 * Add #65 case 2 * Add #65 case 3 * Add debug check to isSquare/Euler's Criterion/Legendre Symbol * Make sure our primitives are correct * For now deactivate montySquare CIOS fix #61 #62 * Narrow down #42 and #43 to powinv on 32-bit * Detect #42 #43 at the fast squaring level * More #42, #43 tests, Use multiplication instead of squaring as a temporary workaround, see #68 * Prevent regression of #67 now that squaring is "fixed"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For BLS12-381, seed 1592673796, commit 89c78ef like #62 (but different seed for the life of me I can't find the original CI trigger)
Repro with -d:Constantine32
The text was updated successfully, but these errors were encountered: