mirror of
https://github.com/codex-storage/constantine.git
synced 2025-01-30 20:45:08 +00:00
Fix warnings
This commit is contained in:
parent
e6c7b3e52a
commit
abaafa816e
@ -53,7 +53,7 @@ import
|
|||||||
../primitives/constant_time,
|
../primitives/constant_time,
|
||||||
../primitives/extended_precision,
|
../primitives/extended_precision,
|
||||||
../config/common
|
../config/common
|
||||||
from sugar import distinctBase
|
from typetraits import distinctBase
|
||||||
|
|
||||||
# ############################################################
|
# ############################################################
|
||||||
#
|
#
|
||||||
|
@ -29,8 +29,6 @@ import
|
|||||||
../config/[common, curves],
|
../config/[common, curves],
|
||||||
./bigints_checked
|
./bigints_checked
|
||||||
|
|
||||||
from ../io/io_bigints import exportRawUint # for "pow"
|
|
||||||
|
|
||||||
# type
|
# type
|
||||||
# `Fp`*[C: static Curve] = object
|
# `Fp`*[C: static Curve] = object
|
||||||
# ## All operations on a field are modulo P
|
# ## All operations on a field are modulo P
|
||||||
|
@ -162,9 +162,6 @@ template toByte(x: SomeUnsignedInt): byte =
|
|||||||
template blobFrom(dst: var openArray[byte], src: SomeUnsignedInt, startIdx: int, endian: static Endianness) =
|
template blobFrom(dst: var openArray[byte], src: SomeUnsignedInt, startIdx: int, endian: static Endianness) =
|
||||||
## Write an integer into a raw binary blob
|
## Write an integer into a raw binary blob
|
||||||
## Swapping endianness if needed
|
## Swapping endianness if needed
|
||||||
|
|
||||||
const bits = sizeof(src) * 8
|
|
||||||
|
|
||||||
when endian == cpuEndian:
|
when endian == cpuEndian:
|
||||||
for i in 0 ..< sizeof(src):
|
for i in 0 ..< sizeof(src):
|
||||||
dst[startIdx+i] = toByte((src shr (i * 8)))
|
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
|
current_idx = 2
|
||||||
else: discard
|
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 =
|
func countNonBlanks(hexStr: string, startPos: int): int =
|
||||||
## Count the number of non-blank characters
|
## Count the number of non-blank characters
|
||||||
## ' ' (space) and '_' (underscore) are considered blank
|
## ' ' (space) and '_' (underscore) are considered blank
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
import
|
import
|
||||||
../config/curves,
|
|
||||||
../arithmetic/finite_fields
|
../arithmetic/finite_fields
|
||||||
|
|
||||||
# ############################################################
|
# ############################################################
|
||||||
@ -35,10 +34,11 @@ import
|
|||||||
# ############################################################
|
# ############################################################
|
||||||
|
|
||||||
type
|
type
|
||||||
QuadExtAddGroup*[T] = concept x
|
QuadExtAddGroup* = concept x
|
||||||
## Quadratic extension fields - Abelian Additive Group concept
|
## Quadratic extension fields - Abelian Additive Group concept
|
||||||
x.c0 is T
|
type BaseField = auto
|
||||||
x.c1 is T
|
x.c0 is BaseField
|
||||||
|
x.c1 is BaseField
|
||||||
|
|
||||||
func setZero*(a: var QuadExtAddGroup) =
|
func setZero*(a: var QuadExtAddGroup) =
|
||||||
## Set ``a`` to zero in the extension field
|
## Set ``a`` to zero in the extension field
|
||||||
@ -86,11 +86,12 @@ func diff*(r: var QuadExtAddGroup, a, b: QuadExtAddGroup) =
|
|||||||
# ############################################################
|
# ############################################################
|
||||||
|
|
||||||
type
|
type
|
||||||
CubicExtAddGroup*[T] = concept x
|
CubicExtAddGroup* = concept x
|
||||||
## Cubic extension fields - Abelian Additive Group concept
|
## Cubic extension fields - Abelian Additive Group concept
|
||||||
x.c0 is T
|
type BaseField = auto
|
||||||
x.c1 is T
|
x.c0 is BaseField
|
||||||
x.c2 is T
|
x.c1 is BaseField
|
||||||
|
x.c2 is BaseField
|
||||||
|
|
||||||
func setZero*(a: var CubicExtAddGroup) =
|
func setZero*(a: var CubicExtAddGroup) =
|
||||||
## Set ``a`` to zero in the extension field
|
## Set ``a`` to zero in the extension field
|
||||||
|
@ -84,7 +84,7 @@ func square*(a: Fp2): Fp2 {.noInit.} =
|
|||||||
# Stack: 6 * ModulusBitSize (4x 𝔽p element + 1 named temporaries + 1 multiplication temporary)
|
# Stack: 6 * ModulusBitSize (4x 𝔽p element + 1 named temporaries + 1 multiplication temporary)
|
||||||
# as multiplications require a (shared) internal 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]
|
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.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]
|
result.c0.sum(c0mc1, result.c1) # result.c0 = c0 - c1 + 2 c1 [1 Add, 1 Dbl, 1 Sub]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user