Comments (1)
Similar to #30 and #43 another square root bug:
import
# Standard library
std/[unittest, times],
# Internals
../constantine/config/[common, curves],
../constantine/arithmetic,
../constantine/io/[io_bigints, io_fields],
../constantine/elliptic/[ec_weierstrass_affine, ec_weierstrass_projective]
proc trySetFromCoordX_debug*[F](P: var ECP_SWei_Proj[F], x: F): SecretBool =
## Try to create a point the elliptic curve
## y² = x³ + a x + b (affine coordinate)
##
## The `Z` coordinates is set to 1
##
## 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)
# TODO: supports non p ≡ 3 (mod 4) modulus like BLS12-377
echo "P.y: ", P.y.toHex()
echo "P.y.isSquare: ", bool P.y.isSquare
result = sqrt_if_square_p3mod4(P.y)
echo "P.y.wasSquare: ", bool result
P.x = x
P.z.setOne()
var a: ECP_SWei_Proj[Fp[BLS12_381]]
var x: Fp[BLS12_381]
x.fromHex("0x1494859e30da25337d020ccf8629c81df7ddab3185acee7a5712c47e2192bc71d6bf74db134d3c7f7f21e43b59242ff3")
let ok = a.trySetFromCoordX_debug(x)
echo "ok: ", bool ok
echo "a.x: ", a.x.toHex()
echo "a.y: ", a.y.toHex()
doAssert bool isOnCurve(a.x, a.y)
var r0{.noInit.}, r1{.noInit.}: ECP_SWei_Proj[Fp[BLS12_381]]
r0.double(a)
r1.sum(a, a)
doAssert bool(r0 == r1)
P.y: 0x0f16d7854229d8804bcadd889f70411d6a482bde840d238033bf868e89558d39d52f9df60b2d745e02584375f16c34a3
P.y.isSquare: false
P.y.wasSquare: true
ok: true
a.x: 0x1494859e30da25337d020ccf8629c81df7ddab3185acee7a5712c47e2192bc71d6bf74db134d3c7f7f21e43b59242ff3
a.y: 0x0aad1bf39cd801cc5b917b70205bac4706e330eb8b5bac50967780f9db6025149b60fe93402bdea86f4b403807d3f4ea
...../Programming/Nim/constantine/build/debug_double_add.nim(43) debug_double_add
...../.choosenim/toolchains/nim-#devel/lib/system/assertions.nim(29) failedAssertImpl
...../.choosenim/toolchains/nim-#devel/lib/system/assertions.nim(22) raiseAssert
...../.choosenim/toolchains/nim-#devel/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: /home/beta/Programming/Nim/constantine/build/debug_double_add.nim(43, 10) `bool isOnCurve(a.x, a.y)` [AssertionDefect]
from constantine.
Related Issues (20)
- EIP-2537: Potential memory leak in G1 and G2 MSM
- Followup: Go API for BLS signatures HOT 2
- MSM - optimized MSM wrong result in IPA verifier.
- Verkle IPA - Incomplete test suite - bugs in prover & verifier HOT 2
- Bug: Cubic extension conjugate
- Build failing on MacOS HOT 4
- Optimize MSM for Bandersnatch/wagon and Verkle Tries
- Optimize MSM for small scalars
- Verkle Trees: Faster subgroup checks for Banderwagon via vartime Legendre symbol
- Parallelize IPA for Verkle Trees
- Custom Vec/Seq with destructors HOT 1
- SIMD Vectorization - Use Integer Fused Multiply-Add (AVX512) HOT 2
- Per-curve towering
- LLVM/Nvidia GPU backend: LLVM 17 broke everything HOT 2
- Optimize batch verification for same message (Pippenger msm)
- Low-level: discrepancy between field arithmetic performance and elliptic curve performance HOT 4
- Windows: Secp256k1 tests assembly test frozen
- Oblivious Maps / side-channel secure hash tables
- Parallel MSM load balancing: minimize work per-thread
- [Fuzzing] Implement a Fp12 serializer to canonical serialization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from constantine.