diff --git a/constantine/io/io_bigints.nim b/constantine/io/io_bigints.nim index ba93e3a..a7e437e 100644 --- a/constantine/io/io_bigints.nim +++ b/constantine/io/io_bigints.nim @@ -149,7 +149,6 @@ func fromUint*( # Serialising from internal representation to canonical format # # ############################################################ -import strutils template toByte(x: SomeUnsignedInt): byte = ## At compile-time, conversion to bytes checks the range diff --git a/constantine/math/bigints_raw.nim b/constantine/math/bigints_raw.nim index 4672bf6..b582b64 100644 --- a/constantine/math/bigints_raw.nim +++ b/constantine/math/bigints_raw.nim @@ -271,7 +271,7 @@ func sub*(a: BigIntViewMut, b: BigIntViewAny, ctl: CTBool[Word]): CTBool[Word] = func dec*(a: BigIntViewMut, w: Word): CTBool[Word] = ## Decrement a big int by a small word - # returns the result carry + ## Returns the result carry a[0] -= w result = a[0].isMsbSet() diff --git a/constantine/math/finite_fields.nim b/constantine/math/finite_fields.nim index 2ca17de..7326cf6 100644 --- a/constantine/math/finite_fields.nim +++ b/constantine/math/finite_fields.nim @@ -126,7 +126,6 @@ func `*`*(a, b: Fq): Fq {.noInit.} = ## It is recommended to assign with {.noInit.} ## as Fq elements are usually large and this ## routine will zero init internally the result. - result.mres.setInternalBitLength() result.mres.montyMul(a.mres, b.mres, Fq.C.Mod.mres, Fq.C.getNegInvModWord()) func square*(a: Fq): Fq {.noInit.} = @@ -135,7 +134,6 @@ func square*(a: Fq): Fq {.noInit.} = ## It is recommended to assign with {.noInit.} ## as Fq elements are usually large and this ## routine will zero init internally the result. - result.mres.setInternalBitLength() result.mres.montySquare(a.mres, Fq.C.Mod.mres, Fq.C.getNegInvModWord()) func pow*(a: var Fq, exponent: BigInt) = @@ -171,7 +169,6 @@ func inv*(a: var Fq) = ## Modular inversion ## Warning ⚠️ : ## - This assumes that `Fq` is a prime field - const windowSize = 5 # TODO: find best window size for each curves a.mres.montyPowUnsafeExponent( Fq.C.getInvModExponent(), diff --git a/constantine/math/precomputed.nim b/constantine/math/precomputed.nim index c760903..c635f06 100644 --- a/constantine/math/precomputed.nim +++ b/constantine/math/precomputed.nim @@ -74,8 +74,6 @@ func doubleMod(a: var BigInt, M: BigInt) = func checkOddModulus(M: BigInt) = doAssert bool(BaseType(M.limbs[0]) and 1), "Internal Error: the modulus must be odd to use the Montgomery representation." -import strutils - func checkValidModulus(M: BigInt) = const expectedMsb = M.bits-1 - WordBitSize * (M.limbs.len - 1) let msb = log2(BaseType(M.limbs[^1]))