From 1383aae1059d26fb62f2094de41cb00598530108 Mon Sep 17 00:00:00 2001 From: mratsim Date: Sun, 11 Oct 2020 21:33:59 +0200 Subject: [PATCH] Remove outdated TODOs [skip ci] - noinline consts: https://github.com/nim-lang/RFCs/issues/257 --- benchmarks/platforms.nim | 2 +- constantine.nimble | 1 - constantine/arithmetic/limbs_modular.nim | 2 -- constantine/config/curves_parser.nim | 7 +++---- constantine/elliptic/ec_endomorphism_accel.nim | 5 ----- constantine/elliptic/ec_shortweierstrass_affine.nim | 1 - constantine/elliptic/ec_shortweierstrass_jacobian.nim | 2 -- constantine/elliptic/ec_shortweierstrass_projective.nim | 2 -- constantine/io/io_ec.nim | 2 -- constantine/pairing/pairing_bls12.nim | 4 ---- constantine/pairing/pairing_bn.nim | 1 - constantine/towers.nim | 1 - tests/t_finite_fields_vs_gmp.nim | 2 +- 13 files changed, 5 insertions(+), 27 deletions(-) diff --git a/benchmarks/platforms.nim b/benchmarks/platforms.nim index 0669fb9..51593fb 100644 --- a/benchmarks/platforms.nim +++ b/benchmarks/platforms.nim @@ -6,7 +6,7 @@ # * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. -when defined(amd64): # TODO defined(i386) but it seems lie RDTSC call is misconfigured +when defined(amd64): # TODO defined(i386) but it seems like RDTSC call is misconfigured import platforms/x86 export getTicks, cpuName diff --git a/constantine.nimble b/constantine.nimble index 9ad0b9e..a58aef8 100644 --- a/constantine.nimble +++ b/constantine.nimble @@ -142,7 +142,6 @@ const useDebug = [ proc test(flags, path: string, commandFile = false) = # commandFile should be a "file" but Nimscript doesn't support IO - # TODO: use a proper runner if not dirExists "build": mkDir "build" # Compilation language is controlled by WEAVE_TEST_LANG diff --git a/constantine/arithmetic/limbs_modular.nim b/constantine/arithmetic/limbs_modular.nim index c0b0586..cffe429 100644 --- a/constantine/arithmetic/limbs_modular.nim +++ b/constantine/arithmetic/limbs_modular.nim @@ -107,8 +107,6 @@ func steinsGCD*(v: var Limbs, a: Limbs, F, M: Limbs, bits: int, mp1div2: Limbs) # TODO: the inlining of primitives like `csub` is bad for codesize # but there is a 80% slowdown without it. - # TODO: The `cmov` in `cadd` and `csub` always retest the condition - # which is probably costly here given how many we have. var a = a var b = M diff --git a/constantine/config/curves_parser.nim b/constantine/config/curves_parser.nim index c11b83d..37174b8 100644 --- a/constantine/config/curves_parser.nim +++ b/constantine/config/curves_parser.nim @@ -22,7 +22,6 @@ import # - properly cross the compile-time -> runtime boundary # - avoid inlining large const arrays at the call site # for example when using the `r2modP` constant in multiple overloads in the same module -# TODO: check that those constants use extern const to avoid duplication across modules type CurveFamily* = enum @@ -352,9 +351,9 @@ macro declareCurves*(curves: untyped): untyped = ## ... ## ] ## - ## TODO: Ensure that - ## 1. the modulus is not inlined at runtime to avoid codesize explosion. - ## 2. is not duplicated across compilation modules. + ## Ensure that + ## 1. the modulus is not inlined at runtime to avoid codesize explosion. + ## 2. is not duplicated across compilation modules. curves.expectKind(nnkStmtList) curvesDefinitions.parseCurveDecls(curves) diff --git a/constantine/elliptic/ec_endomorphism_accel.nim b/constantine/elliptic/ec_endomorphism_accel.nim index ad9efcf..856e95f 100644 --- a/constantine/elliptic/ec_endomorphism_accel.nim +++ b/constantine/elliptic/ec_endomorphism_accel.nim @@ -56,11 +56,6 @@ func decomposeEndo*[M, scalBits, L: static int]( ## - Conditional negate is about 10 cycles per Fp, on G2 projective we have 3 (coords) * 2 (Fp2) * 10 (cycles) ~= 60 cycles ## We need to test the mini scalar, which is 65 bits so 2 Fp so about 2 cycles ## and negate it as well. - ## - ## However solution 1 seems to cause issues (TODO) - ## with some of the BLS12-381 test cases (6 and 9) - ## - 0x5668a2332db27199dcfb7cbdfca6317c2ff128db26d7df68483e0a095ec8e88f - ## - 0x644dc62869683f0c93f38eaef2ba6912569dc91ec2806e46b4a3dd6a4421dad1 # Equal when no window or no negative handling, greater otherwise static: doAssert L >= (scalBits + M - 1) div M + 1 diff --git a/constantine/elliptic/ec_shortweierstrass_affine.nim b/constantine/elliptic/ec_shortweierstrass_affine.nim index 19df472..6d4aa29 100644 --- a/constantine/elliptic/ec_shortweierstrass_affine.nim +++ b/constantine/elliptic/ec_shortweierstrass_affine.nim @@ -111,7 +111,6 @@ func trySetFromCoordX*[F, Tw]( ## Note: Dedicated robust procedures for hashing-to-curve ## will be provided, this is intended for testing purposes. P.y.curve_eq_rhs(x, Tw) - # TODO: supports non p ≡ 3 (mod 4) modulus like BLS12-377 result = sqrt_if_square(P.y) func neg*(P: var ECP_ShortW_Aff, Q: ECP_ShortW_Aff) = diff --git a/constantine/elliptic/ec_shortweierstrass_jacobian.nim b/constantine/elliptic/ec_shortweierstrass_jacobian.nim index 328ba73..ffc81ee 100644 --- a/constantine/elliptic/ec_shortweierstrass_jacobian.nim +++ b/constantine/elliptic/ec_shortweierstrass_jacobian.nim @@ -92,7 +92,6 @@ func trySetFromCoordsXandZ*[F; Tw]( ## Note: Dedicated robust procedures for hashing-to-curve ## will be provided, this is intended for testing purposes. P.y.curve_eq_rhs(x, Tw) - # TODO: supports non p ≡ 3 (mod 4) modulus like BLS12-377 result = sqrt_if_square(P.y) var z2 {.noInit.}: F @@ -116,7 +115,6 @@ func trySetFromCoordX*[F; Tw]( ## Note: Dedicated robust procedures for hashing-to-curve ## will be provided, this is intended for testing purposes. P.y.curve_eq_rhs(x, Tw) - # TODO: supports non p ≡ 3 (mod 4) modulus like BLS12-377 result = sqrt_if_square(P.y) P.x = x P.z.setOne() diff --git a/constantine/elliptic/ec_shortweierstrass_projective.nim b/constantine/elliptic/ec_shortweierstrass_projective.nim index 6fb5fa5..4b3fd6e 100644 --- a/constantine/elliptic/ec_shortweierstrass_projective.nim +++ b/constantine/elliptic/ec_shortweierstrass_projective.nim @@ -86,7 +86,6 @@ func trySetFromCoordsXandZ*[F; Tw]( ## Note: Dedicated robust procedures for hashing-to-curve ## will be provided, this is intended for testing purposes. P.y.curve_eq_rhs(x, Tw) - # TODO: supports non p ≡ 3 (mod 4) modulus like BLS12-377 result = sqrt_if_square(P.y) P.x.prod(x, z) @@ -107,7 +106,6 @@ func trySetFromCoordX*[F; Tw]( ## Note: Dedicated robust procedures for hashing-to-curve ## will be provided, this is intended for testing purposes. P.y.curve_eq_rhs(x, Tw) - # TODO: supports non p ≡ 3 (mod 4) modulus like BLS12-377 result = sqrt_if_square(P.y) P.x = x P.z.setOne() diff --git a/constantine/io/io_ec.nim b/constantine/io/io_ec.nim index 45321c7..d10519e 100644 --- a/constantine/io/io_ec.nim +++ b/constantine/io/io_ec.nim @@ -36,8 +36,6 @@ func toHex*[EC](P: EC): string = ## CT: ## - no leaks ## - ## TODO: only normalize and don't display the Z coordinate - ## ## This proc output may change format in the future var aff {.noInit.}: ECP_ShortW_Aff[EC.F, EC.Tw] diff --git a/constantine/pairing/pairing_bls12.nim b/constantine/pairing/pairing_bls12.nim index d0e2735..d09a293 100644 --- a/constantine/pairing/pairing_bls12.nim +++ b/constantine/pairing/pairing_bls12.nim @@ -52,7 +52,6 @@ func millerLoopGenericBLS12*[C]( ) = ## Generic Miller Loop for BLS12 curve ## Computes f{u,Q}(P) with u the BLS curve parameter - # TODO: retrieve the curve parameter from the curve declaration # Boundary cases # Loop start @@ -147,9 +146,6 @@ func finalExpHard_BLS12*[C](f: var Fp12[C]) = # # p14: 3 Φ₁₂(p(x))/r(x) = (x−1)² (x+p) (x²+p²−1) + 3 # - # TODO: paper costs are 4Eₓ+Eₓ/₂+7M₁₂+S₁₂+F₁+F₂ - # so we have an extra cyclotomic squaring since we use 5Eₓ - # # with # - Eₓ being f^x # - Eₓ/₂ being f^(x/2) diff --git a/constantine/pairing/pairing_bn.nim b/constantine/pairing/pairing_bn.nim index 91c30c4..8c49959 100644 --- a/constantine/pairing/pairing_bn.nim +++ b/constantine/pairing/pairing_bn.nim @@ -49,7 +49,6 @@ func millerLoopGenericBN*[C]( ) = ## Generic Miller Loop for BN curves ## Computes f{6u+2,Q}(P) with u the BN curve parameter - # TODO: retrieve the curve parameter from the curve declaration # TODO - boundary cases # Loop start diff --git a/constantine/towers.nim b/constantine/towers.nim index 3a9bc8d..78e1355 100644 --- a/constantine/towers.nim +++ b/constantine/towers.nim @@ -216,7 +216,6 @@ func `*=`*(a: var Fp4, _: typedesc[γ]) {.inline.} = func `*=`*(a: var Fp2, b: Fp) = ## Multiply an element of Fp2 by an element of Fp - # TODO: make generic and move to tower_field_extensions a.c0 *= b a.c1 *= b diff --git a/tests/t_finite_fields_vs_gmp.nim b/tests/t_finite_fields_vs_gmp.nim index f38dcc4..e9d8ef4 100644 --- a/tests/t_finite_fields_vs_gmp.nim +++ b/tests/t_finite_fields_vs_gmp.nim @@ -72,7 +72,7 @@ proc binary_prologue[C: static Curve, N: static int]( doAssert len >= aW, "Expected at most " & $len & " bytes but wrote " & $aW & " for " & toHex(aBuf) & " (big-endian)" doAssert len >= bW, "Expected at most " & $len & " bytes but wrote " & $bW & " for " & toHex(bBuf) & " (big-endian)" - # Build the bigint - TODO more fields codecs + # Build the bigint aTest = Fp[C].fromBig BigInt[bits].fromRawUint(aBuf.toOpenArray(0, aW-1), bigEndian) bTest = Fp[C].fromBig BigInt[bits].fromRawUint(bBuf.toOpenArray(0, bW-1), bigEndian)