diff --git a/constantine/arithmetic/assembly/limbs_asm_modular_x86.nim b/constantine/arithmetic/assembly/limbs_asm_modular_x86.nim index d0cf94e..149b9db 100644 --- a/constantine/arithmetic/assembly/limbs_asm_modular_x86.nim +++ b/constantine/arithmetic/assembly/limbs_asm_modular_x86.nim @@ -11,8 +11,7 @@ import std/macros, # Internal ../../config/common, - ../../primitives, - ../limbs + ../../primitives # ############################################################ # diff --git a/constantine/arithmetic/assembly/limbs_asm_montmul_x86.nim b/constantine/arithmetic/assembly/limbs_asm_montmul_x86.nim index 6301526..9280f16 100644 --- a/constantine/arithmetic/assembly/limbs_asm_montmul_x86.nim +++ b/constantine/arithmetic/assembly/limbs_asm_montmul_x86.nim @@ -12,7 +12,6 @@ import # Internal ../../config/common, ../../primitives, - ../limbs, ./limbs_asm_montred_x86 # ############################################################ diff --git a/constantine/arithmetic/assembly/limbs_asm_montmul_x86_adx_bmi2.nim b/constantine/arithmetic/assembly/limbs_asm_montmul_x86_adx_bmi2.nim index 88c8ce3..9d058df 100644 --- a/constantine/arithmetic/assembly/limbs_asm_montmul_x86_adx_bmi2.nim +++ b/constantine/arithmetic/assembly/limbs_asm_montmul_x86_adx_bmi2.nim @@ -12,7 +12,6 @@ import # Internal ../../config/common, ../../primitives, - ../limbs, ./limbs_asm_montred_x86 # ############################################################ diff --git a/constantine/arithmetic/assembly/limbs_asm_montred_x86.nim b/constantine/arithmetic/assembly/limbs_asm_montred_x86.nim index a0887c0..495c631 100644 --- a/constantine/arithmetic/assembly/limbs_asm_montred_x86.nim +++ b/constantine/arithmetic/assembly/limbs_asm_montred_x86.nim @@ -11,8 +11,7 @@ import std/macros, # Internal ../../config/common, - ../../primitives, - ../limbs + ../../primitives # ############################################################ # diff --git a/constantine/arithmetic/assembly/limbs_asm_montred_x86_adx_bmi2.nim b/constantine/arithmetic/assembly/limbs_asm_montred_x86_adx_bmi2.nim index 6771785..f8b467a 100644 --- a/constantine/arithmetic/assembly/limbs_asm_montred_x86_adx_bmi2.nim +++ b/constantine/arithmetic/assembly/limbs_asm_montred_x86_adx_bmi2.nim @@ -12,7 +12,6 @@ import # Internal ../../config/common, ../../primitives, - ../limbs, ./limbs_asm_montred_x86 # ############################################################ diff --git a/constantine/arithmetic/finite_fields.nim b/constantine/arithmetic/finite_fields.nim index 630f978..c4cd12f 100644 --- a/constantine/arithmetic/finite_fields.nim +++ b/constantine/arithmetic/finite_fields.nim @@ -27,7 +27,6 @@ import ../primitives, ../config/[common, type_fp, curves], - ../io/io_bigints, ./bigints, ./limbs_montgomery when UseASM_X86_64: diff --git a/constantine/arithmetic/finite_fields_double_width.nim b/constantine/arithmetic/finite_fields_double_width.nim index 3efaaba..26d8a1a 100644 --- a/constantine/arithmetic/finite_fields_double_width.nim +++ b/constantine/arithmetic/finite_fields_double_width.nim @@ -7,7 +7,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - ../config/[common, curves, type_bigint, type_fp], + ../config/[common, curves, type_fp], ../primitives, ./bigints, ./finite_fields, diff --git a/constantine/arithmetic/finite_fields_inversion.nim b/constantine/arithmetic/finite_fields_inversion.nim index cbaeae5..27ad282 100644 --- a/constantine/arithmetic/finite_fields_inversion.nim +++ b/constantine/arithmetic/finite_fields_inversion.nim @@ -7,7 +7,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - ../config/[common, curves, type_fp], + ../config/[curves, type_fp], ./bigints, ../curves/zoo_inversions diff --git a/constantine/arithmetic/finite_fields_square_root.nim b/constantine/arithmetic/finite_fields_square_root.nim index 29ddf27..7649bf5 100644 --- a/constantine/arithmetic/finite_fields_square_root.nim +++ b/constantine/arithmetic/finite_fields_square_root.nim @@ -10,8 +10,7 @@ import ../primitives, ../config/[common, type_fp, curves], ../curves/zoo_square_roots, - ../io/[io_bigints, io_fields], - ./bigints, ./finite_fields, ./limbs_montgomery + ./bigints, ./finite_fields # ############################################################ # diff --git a/constantine/arithmetic/limbs_montgomery.nim b/constantine/arithmetic/limbs_montgomery.nim index 00ab974..275d9ef 100644 --- a/constantine/arithmetic/limbs_montgomery.nim +++ b/constantine/arithmetic/limbs_montgomery.nim @@ -162,7 +162,7 @@ func montyMul_FIPS(r: var Limbs, a, b, M: Limbs, m0ninv: BaseType) = discard z.csub(M, v.isNonZero() or not(z < M)) r = z -func montySquare_CIOS_nocarry(r: var Limbs, a, M: Limbs, m0ninv: BaseType) = +func montySquare_CIOS_nocarry(r: var Limbs, a, M: Limbs, m0ninv: BaseType) {.used.}= ## Montgomery Multiplication using Coarse Grained Operand Scanning (CIOS) ## and no-carry optimization. ## This requires the most significant word of the Modulus @@ -206,7 +206,7 @@ func montySquare_CIOS_nocarry(r: var Limbs, a, M: Limbs, m0ninv: BaseType) = discard t.csub(M, not(t < M)) r = t -func montySquare_CIOS(r: var Limbs, a, M: Limbs, m0ninv: BaseType) = +func montySquare_CIOS(r: var Limbs, a, M: Limbs, m0ninv: BaseType) {.used.}= ## Montgomery Multiplication using Coarse Grained Operand Scanning (CIOS) ## ## Architectural Support for Long Integer Modulo Arithmetic on Risc-Based Smart Cards diff --git a/constantine/config/curves_derived.nim b/constantine/config/curves_derived.nim index d618762..a843876 100644 --- a/constantine/config/curves_derived.nim +++ b/constantine/config/curves_derived.nim @@ -11,9 +11,7 @@ import std/macros, # Internal ./precompute, - ./curves_declaration, - ./type_fp, - ../io/io_bigints + ./curves_declaration {.experimental: "dynamicBindSym".} diff --git a/constantine/elliptic/ec_endomorphism_accel.nim b/constantine/elliptic/ec_endomorphism_accel.nim index b21fa10..1dc72e0 100644 --- a/constantine/elliptic/ec_endomorphism_accel.nim +++ b/constantine/elliptic/ec_endomorphism_accel.nim @@ -14,11 +14,8 @@ import ../config/[common, curves, type_bigint], ../curves/zoo_glv, ../arithmetic, - ../io/io_bigints, ../towers, - ../isogeny/frobenius, - ./ec_shortweierstrass_affine, - ./ec_shortweierstrass_projective + ../isogeny/frobenius # ############################################################ # diff --git a/constantine/elliptic/ec_shortweierstrass_jacobian.nim b/constantine/elliptic/ec_shortweierstrass_jacobian.nim index f339d47..834e948 100644 --- a/constantine/elliptic/ec_shortweierstrass_jacobian.nim +++ b/constantine/elliptic/ec_shortweierstrass_jacobian.nim @@ -13,8 +13,6 @@ import ../towers, ./ec_shortweierstrass_affine -import ../io/io_fields - # ############################################################ # # Elliptic Curve in Short Weierstrass form diff --git a/constantine/hash_to_curve/cofactors.nim b/constantine/hash_to_curve/cofactors.nim index 730a771..77fd2f0 100644 --- a/constantine/hash_to_curve/cofactors.nim +++ b/constantine/hash_to_curve/cofactors.nim @@ -7,8 +7,6 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - # Standard library - std/[tables, unittest, times], # Internals ../config/common, ../arithmetic, diff --git a/constantine/io/io_fields.nim b/constantine/io/io_fields.nim index d625b72..5ecf6b0 100644 --- a/constantine/io/io_fields.nim +++ b/constantine/io/io_fields.nim @@ -8,7 +8,6 @@ import ./io_bigints, - ../config/curves, ../arithmetic/finite_fields # No exceptions allowed diff --git a/constantine/pairing/cyclotomic_fp12.nim b/constantine/pairing/cyclotomic_fp12.nim index ea85cc7..4c6e1c5 100644 --- a/constantine/pairing/cyclotomic_fp12.nim +++ b/constantine/pairing/cyclotomic_fp12.nim @@ -8,7 +8,7 @@ import ../primitives, - ../config/[common, curves], + ../config/curves, ../arithmetic, ../towers, ../isogeny/frobenius diff --git a/constantine/pairing/lines_common.nim b/constantine/pairing/lines_common.nim index b7575e6..7b3e4ce 100644 --- a/constantine/pairing/lines_common.nim +++ b/constantine/pairing/lines_common.nim @@ -9,13 +9,10 @@ import std/typetraits, ../primitives, - ../config/[common, curves], + ../config/curves, ../arithmetic, ../towers, - ../elliptic/[ - ec_shortweierstrass_affine, - ec_shortweierstrass_projective - ], + ../elliptic/ec_shortweierstrass_affine, ../io/io_towers type diff --git a/constantine/pairing/lines_projective.nim b/constantine/pairing/lines_projective.nim index 59bfc20..427534e 100644 --- a/constantine/pairing/lines_projective.nim +++ b/constantine/pairing/lines_projective.nim @@ -7,16 +7,14 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - std/typetraits, ../primitives, - ../config/[common, curves], + ../config/curves, ../arithmetic, ../towers, ../elliptic/[ ec_shortweierstrass_affine, ec_shortweierstrass_projective ], - ../io/io_towers, ./lines_common export lines_common diff --git a/constantine/pairing/mul_fp12_by_lines.nim b/constantine/pairing/mul_fp12_by_lines.nim index b261419..b23d0b7 100644 --- a/constantine/pairing/mul_fp12_by_lines.nim +++ b/constantine/pairing/mul_fp12_by_lines.nim @@ -8,7 +8,7 @@ import ../primitives, - ../config/[common, curves], + ../config/curves, ../arithmetic, ../towers, ./lines_projective diff --git a/constantine/pairing/pairing_bn.nim b/constantine/pairing/pairing_bn.nim index ea07e2e..be6ffde 100644 --- a/constantine/pairing/pairing_bn.nim +++ b/constantine/pairing/pairing_bn.nim @@ -9,7 +9,6 @@ import ../config/[curves, type_fp], ../towers, - ../io/io_bigints, ../elliptic/[ ec_shortweierstrass_affine, ec_shortweierstrass_projective diff --git a/constantine/primitives/macro_assembler_x86.nim b/constantine/primitives/macro_assembler_x86.nim index 96faf1c..1839b72 100644 --- a/constantine/primitives/macro_assembler_x86.nim +++ b/constantine/primitives/macro_assembler_x86.nim @@ -438,7 +438,7 @@ func adc*(a: var Assembler_x86, dst, src: Operand) = a.codeFragment("adc", src, dst) a.areFlagsClobbered = true - if dst.desc.rm != Reg: + if dst.desc.rm in {Mem, MemOffsettable, AnyRegOrMem}: {.warning: "Using addcarry with a memory destination, this incurs significant performance penalties.".} func adc*(a: var Assembler_x86, dst: Operand, imm: int) = @@ -447,7 +447,7 @@ func adc*(a: var Assembler_x86, dst: Operand, imm: int) = a.codeFragment("adc", imm, dst) a.areFlagsClobbered = true - if dst.desc.rm != Reg: + if dst.desc.rm in {Mem, MemOffsettable, AnyRegOrMem}: {.warning: "Using addcarry with a memory destination, this incurs significant performance penalties.".} func sub*(a: var Assembler_x86, dst, src: Operand) = diff --git a/constantine/tower_field_extensions/cubic_extensions.nim b/constantine/tower_field_extensions/cubic_extensions.nim index 409bf6f..5796260 100644 --- a/constantine/tower_field_extensions/cubic_extensions.nim +++ b/constantine/tower_field_extensions/cubic_extensions.nim @@ -42,7 +42,7 @@ import # | CH-SQR3 | 1M + 4S | 11A + 2B + 1 Div2 | # | CH-SQR3x | 1M + 4S | 14A + 2B | -func square_Chung_Hasan_SQR2(r: var CubicExt, a: CubicExt) = +func square_Chung_Hasan_SQR2(r: var CubicExt, a: CubicExt) {.used.}= ## Returns r = a² mixin prod, square, sum var v3{.noInit.}, v4{.noInit.}, v5{.noInit.}: typeof(r.c0) diff --git a/constantine/tower_field_extensions/exponentiations.nim b/constantine/tower_field_extensions/exponentiations.nim index f6861e5..f09e6ab 100644 --- a/constantine/tower_field_extensions/exponentiations.nim +++ b/constantine/tower_field_extensions/exponentiations.nim @@ -9,7 +9,7 @@ import ../arithmetic, - ../config/[common, curves], + ../config/common, ../primitives, ../io/io_bigints, ./tower_common, diff --git a/constantine/towers.nim b/constantine/towers.nim index d992997..8a9c09b 100644 --- a/constantine/towers.nim +++ b/constantine/towers.nim @@ -59,7 +59,7 @@ func `*=`*(a: var Fp2, _: typedesc[SexticNonResidue]) {.inline.} = # Yet another const tuple unpacking bug const u = Fp2.C.get_SNR_Fp2()[0] # Sextic non-residue to construct 𝔽p12 const v = Fp2.C.get_SNR_Fp2()[1] - const Beta = Fp2.C.get_QNR_Fp() # Quadratic non-residue to construct 𝔽p2 + const Beta {.used.} = Fp2.C.get_QNR_Fp() # Quadratic non-residue to construct 𝔽p2 # ξ = u + v x # and x² = β # @@ -136,9 +136,9 @@ func `*`*(_: typedesc[ξ], a: Fp2): Fp2 {.inline, noInit.} = ## Multiply an element of 𝔽p2 by the quadratic and cubic non-residue ## chosen to construct 𝔽p4/𝔽p6 # Yet another const tuple unpacking bug - const u = Fp2.C.get_CNR_Fp2()[0] # Quadratic & Cubic non-residue to construct 𝔽p4/𝔽p6 + const u = Fp2.C.get_CNR_Fp2()[0] # Quadratic & Cubic non-residue to construct 𝔽p4/𝔽p6 const v = Fp2.C.get_CNR_Fp2()[1] - const Beta = Fp2.C.get_QNR_Fp() # Quadratic non-residue to construct 𝔽p2 + const Beta {.used.} = Fp2.C.get_QNR_Fp() # Quadratic non-residue to construct 𝔽p2 # ξ = u + v x # and x² = β # @@ -162,7 +162,7 @@ func `*=`*(a: var Fp2, _: typedesc[ξ]) {.inline.} = # Yet another const tuple unpacking bug const u = Fp2.C.get_CNR_Fp2()[0] # Cubic non-residue to construct 𝔽p6 const v = Fp2.C.get_CNR_Fp2()[1] - const Beta = Fp2.C.get_QNR_Fp() # Quadratic non-residue to construct 𝔽p2 + const Beta {.used.} = Fp2.C.get_QNR_Fp() # Quadratic non-residue to construct 𝔽p2 # ξ = u + v x # and x² = β # diff --git a/tests/t_pairing_template.nim b/tests/t_pairing_template.nim index 92bd880..af7a57b 100644 --- a/tests/t_pairing_template.nim +++ b/tests/t_pairing_template.nim @@ -17,7 +17,7 @@ import ../constantine/elliptic/ec_shortweierstrass_projective, ../constantine/hash_to_curve/cofactors, # Test utilities - ../helpers/[prng_unsafe, static_for] + ../helpers/prng_unsafe export prng_unsafe, times, unittest,