mirror of
https://github.com/status-im/constantine.git
synced 2025-02-23 17:38:09 +00:00
Add Mersenn 61 and 127 + debugging print
This commit is contained in:
parent
5620bbfaee
commit
f1430915fe
@ -58,6 +58,12 @@ else:
|
|||||||
curve Fake101:
|
curve Fake101:
|
||||||
bitsize: 7
|
bitsize: 7
|
||||||
modulus: "0x65" # 101 in hex
|
modulus: "0x65" # 101 in hex
|
||||||
|
curve Mersenne61:
|
||||||
|
bitsize: 61
|
||||||
|
modulus: "0x1fffffffffffffff" # 2^61 - 1
|
||||||
|
curve Mersenne127:
|
||||||
|
bitsize: 127
|
||||||
|
modulus: "0x7fffffffffffffffffffffffffffffff" # 2^127 - 1
|
||||||
|
|
||||||
# ############################################################
|
# ############################################################
|
||||||
#
|
#
|
||||||
|
@ -72,6 +72,18 @@ debug:
|
|||||||
accum = accum or (a.limbs[i] xor b.limbs[i])
|
accum = accum or (a.limbs[i] xor b.limbs[i])
|
||||||
result = accum.isZero
|
result = accum.isZero
|
||||||
|
|
||||||
|
func `$`*(a: BigInt): string =
|
||||||
|
result = "BigInt["
|
||||||
|
result.add $BigInt.bits
|
||||||
|
result.add "](bitLength: "
|
||||||
|
result.add $a.bitLength
|
||||||
|
result.add ", limbs: ["
|
||||||
|
result.add $BaseType(a.limbs[0])
|
||||||
|
for i in 1 ..< a.limbs.len:
|
||||||
|
result.add ", "
|
||||||
|
result.add $BaseType(a.limbs[i])
|
||||||
|
result.add "])"
|
||||||
|
|
||||||
# No exceptions allowed
|
# No exceptions allowed
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
{.push inline.}
|
{.push inline.}
|
||||||
|
@ -39,6 +39,12 @@ debug:
|
|||||||
## Returns true if 2 big ints are equal
|
## Returns true if 2 big ints are equal
|
||||||
a.mres == b.mres
|
a.mres == b.mres
|
||||||
|
|
||||||
|
func `$`*[C: static Curve](a: Fq[C]): string =
|
||||||
|
result = "Fq[" & $C
|
||||||
|
result.add "]("
|
||||||
|
result.add $a.mres
|
||||||
|
result.add ')'
|
||||||
|
|
||||||
# No exceptions allowed
|
# No exceptions allowed
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
{.push inline.}
|
{.push inline.}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user