From abaafa816e8255600d554d49d5967ddec549315d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mamy=20Andr=C3=A9-Ratsimbazafy?= Date: Tue, 25 Feb 2020 14:32:54 +0100 Subject: [PATCH] Fix warnings --- constantine/arithmetic/bigints_raw.nim | 2 +- constantine/arithmetic/finite_fields.nim | 2 -- constantine/io/io_bigints.nim | 8 -------- .../tower_field_extensions/abelian_groups.nim | 17 +++++++++-------- .../tower_field_extensions/fp2_complex.nim | 2 +- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/constantine/arithmetic/bigints_raw.nim b/constantine/arithmetic/bigints_raw.nim index d9eda88..e510658 100644 --- a/constantine/arithmetic/bigints_raw.nim +++ b/constantine/arithmetic/bigints_raw.nim @@ -53,7 +53,7 @@ import ../primitives/constant_time, ../primitives/extended_precision, ../config/common -from sugar import distinctBase +from typetraits import distinctBase # ############################################################ # diff --git a/constantine/arithmetic/finite_fields.nim b/constantine/arithmetic/finite_fields.nim index e15675a..183c1f0 100644 --- a/constantine/arithmetic/finite_fields.nim +++ b/constantine/arithmetic/finite_fields.nim @@ -29,8 +29,6 @@ import ../config/[common, curves], ./bigints_checked -from ../io/io_bigints import exportRawUint # for "pow" - # type # `Fp`*[C: static Curve] = object # ## All operations on a field are modulo P diff --git a/constantine/io/io_bigints.nim b/constantine/io/io_bigints.nim index 102bd48..dc85fd7 100644 --- a/constantine/io/io_bigints.nim +++ b/constantine/io/io_bigints.nim @@ -162,9 +162,6 @@ template toByte(x: SomeUnsignedInt): byte = template blobFrom(dst: var openArray[byte], src: SomeUnsignedInt, startIdx: int, endian: static Endianness) = ## Write an integer into a raw binary blob ## Swapping endianness if needed - - const bits = sizeof(src) * 8 - when endian == cpuEndian: for i in 0 ..< sizeof(src): dst[startIdx+i] = toByte((src shr (i * 8))) @@ -330,11 +327,6 @@ func skipPrefixes(current_idx: var int, str: string, radix: static range[2..16]) current_idx = 2 else: discard -func readDecChar(c: range['0'..'9']): int {.inline.}= - ## Converts a decimal char to an int - # specialization without branching for base <= 10. - ord(c) - ord('0') - func countNonBlanks(hexStr: string, startPos: int): int = ## Count the number of non-blank characters ## ' ' (space) and '_' (underscore) are considered blank diff --git a/constantine/tower_field_extensions/abelian_groups.nim b/constantine/tower_field_extensions/abelian_groups.nim index 62cb3ac..9c13061 100644 --- a/constantine/tower_field_extensions/abelian_groups.nim +++ b/constantine/tower_field_extensions/abelian_groups.nim @@ -7,7 +7,6 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - ../config/curves, ../arithmetic/finite_fields # ############################################################ @@ -35,10 +34,11 @@ import # ############################################################ type - QuadExtAddGroup*[T] = concept x + QuadExtAddGroup* = concept x ## Quadratic extension fields - Abelian Additive Group concept - x.c0 is T - x.c1 is T + type BaseField = auto + x.c0 is BaseField + x.c1 is BaseField func setZero*(a: var QuadExtAddGroup) = ## Set ``a`` to zero in the extension field @@ -86,11 +86,12 @@ func diff*(r: var QuadExtAddGroup, a, b: QuadExtAddGroup) = # ############################################################ type - CubicExtAddGroup*[T] = concept x + CubicExtAddGroup* = concept x ## Cubic extension fields - Abelian Additive Group concept - x.c0 is T - x.c1 is T - x.c2 is T + type BaseField = auto + x.c0 is BaseField + x.c1 is BaseField + x.c2 is BaseField func setZero*(a: var CubicExtAddGroup) = ## Set ``a`` to zero in the extension field diff --git a/constantine/tower_field_extensions/fp2_complex.nim b/constantine/tower_field_extensions/fp2_complex.nim index 33c9fac..6eead05 100644 --- a/constantine/tower_field_extensions/fp2_complex.nim +++ b/constantine/tower_field_extensions/fp2_complex.nim @@ -84,7 +84,7 @@ func square*(a: Fp2): Fp2 {.noInit.} = # Stack: 6 * ModulusBitSize (4x 𝔽p element + 1 named temporaries + 1 multiplication temporary) # as multiplications require a (shared) internal temporary - var c0mc1 {.noInit.}: Fp + var c0mc1 {.noInit.}: typeof(a.c0) c0mc1.diff(a.c0, a.c1) # c0mc1 = c0 - c1 [1 Sub] result.c1.double(a.c1) # result.c1 = 2 c1 [1 Dbl, 1 Sub] result.c0.sum(c0mc1, result.c1) # result.c0 = c0 - c1 + 2 c1 [1 Add, 1 Dbl, 1 Sub]