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)
- uptream regression: support aliasing in towers of extension fields
- Handle aliasing for elliptic curves
- BW6-761: fix naive pairings and implement optimized version
- BN254-Snarks: bad performance on Fp4 squaring
- Implement Bandersnatch: elliptic curve over BLS12-81 scalar field
- FR: Non-cryptographer friendly opinionated suite HOT 2
- Buggy ADX detection
- Protocol: Waku's Rate-Limiting Nullifier for privacy preserving spam protection
- Protocol: Compact Proofs-of-Retrievability (Shacham and Waters 2008) HOT 1
- Protocol: Verkle Trees HOT 1
- Protocol: EIP2333 - BLS12-381 Ethereum Consensus Key Generation
- Scalar-mul: Constant-Time double-and-add
- Perf: `isSquare` - constant-time Jacobi/Kronecker/Legendre symbol using fast GCD
- Perf: Assembly code generator for ARM and ARM64 HOT 1
- Accelerate Merkle tree hashing
- [Fuzz fail] Fused sumproduct failure HOT 1
- Protocol: Chaum-Pedersen BLS aggregation proof without pairings for light client
- [Hash Table] Provide SipHash (stretch: Highway hash)
- [CSPRNG] Provides CSPRNGs HOT 1
- [Fuzz fail] WNAF (used only for randomization) 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.