-
-
Notifications
You must be signed in to change notification settings - Fork 43
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 test failure EC Add G2 associative #64
Labels
Comments
This was referenced Jun 20, 2020
Reproduction on 32-bit, square issue 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 = "0x0a3cb51c87870ae2dbae8b2541c9e2ce3d8d7399ac27817f6693cc09afc47faf78037c99cdaf982a50f33579a025e8c6",
c1 = "0x00a139723b314c29bfecf63c19c2900a6973e2f5315e9194145a87b18ae9357830324a5f7f8f2605da22267f1e1145b4"
)
az.fromHex(
c0 = "0x0c1fe9819c78d075d0bcb9e154998c565e4c0928dfca415fe552ceda584b2adf614a1c4c1c4007c67398471f1c380483",
c1 = "0x045354e8eae1df51b1fce7608d46141412084a21645c3f1667c628d1d3bddef95804664b1d2db6beae638d66c630de4f"
)
bx.fromHex(
c0 = "0x02b1597cfa65d8bc46d8f104c7d0fa83918bef778641752b3be9c2a285a21d5f10923f4cf051799b19763a75a7bfbc92",
c1 = "0x043933ace864e9bf38bde3c37c7d52c59688758fba5ace6aacb3101ac2c1fb5521ed33ffeed4933d0b6cd798d6d0a956"
)
bz.fromHex(
c0 = "0x03d3dade5c52f71522775fcf84fefa2352b5b7a7b9c5fce68ce0696e0312c5520f7429bfd2cae0ccdc69733baba7ab84",
c1 = "0x12d0d62574b9ed0794587b7fba9dbdd6d5c34e4f85365ccfb55d873bf83793a3f20c9619dcb45b2b1d2ee8aba85c1051"
)
cx.fromHex(
c0 = "0x03aeb225779d7298b9769cb8a4629b46d251411cb7460e744a1d91c9501ff53908687cbca5dbdca44868664eed1b3050",
c1 = "0x10b8dffb7afbbcf5d930bcb369da35fada654aa21042e541f8acf7e79b4cee88685cf58941910bf01c1392fdfdaab9f9"
)
cz.fromHex(
c0 = "0x0f548d4f9fdca7281e79bf8323296ddb7b13c14382f563572338fa3f769a985c4b3af6056ec6853126e36b7c573f4478",
c1 = "0x0352c7b0b459518c61339e6d7b64a0e847a322d0aa6dc66a11595c457493fe8d9075df73e82e3624d17715a50514995b"
)
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, commit 0edc0ad, seed 1592671186, 32-bit
The text was updated successfully, but these errors were encountered: