Fix warnings

This commit is contained in:
Mamy André-Ratsimbazafy 2020-02-25 14:32:54 +01:00
parent e6c7b3e52a
commit abaafa816e
No known key found for this signature in database
GPG Key ID: 7B88AD1FE79492E1
5 changed files with 11 additions and 20 deletions

View File

@ -53,7 +53,7 @@ import
../primitives/constant_time,
../primitives/extended_precision,
../config/common
from sugar import distinctBase
from typetraits import distinctBase
# ############################################################
#

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]