Add Mersenn 61 and 127 + debugging print

This commit is contained in:
Mamy André-Ratsimbazafy 2020-02-16 12:03:01 +01:00
parent 5620bbfaee
commit f1430915fe
No known key found for this signature in database
GPG Key ID: 7B88AD1FE79492E1
3 changed files with 24 additions and 0 deletions

View File

@ -58,6 +58,12 @@ else:
curve Fake101:
bitsize: 7
modulus: "0x65" # 101 in hex
curve Mersenne61:
bitsize: 61
modulus: "0x1fffffffffffffff" # 2^61 - 1
curve Mersenne127:
bitsize: 127
modulus: "0x7fffffffffffffffffffffffffffffff" # 2^127 - 1
# ############################################################
#

View File

@ -72,6 +72,18 @@ debug:
accum = accum or (a.limbs[i] xor b.limbs[i])
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
{.push raises: [].}
{.push inline.}

View File

@ -39,6 +39,12 @@ debug:
## Returns true if 2 big ints are equal
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
{.push raises: [].}
{.push inline.}