rename io tests ti io bigints

This commit is contained in:
Mamy André-Ratsimbazafy 2020-02-16 11:29:27 +01:00
parent 23ecb9a221
commit 5620bbfaee
No known key found for this signature in database
GPG Key ID: 7B88AD1FE79492E1
3 changed files with 3 additions and 2 deletions

View File

@ -17,7 +17,7 @@ proc test(fakeCurves: string, path: string, lang = "c") =
### tasks ### tasks
task test, "Run all tests": task test, "Run all tests":
test "", "tests/test_primitives.nim" test "", "tests/test_primitives.nim"
test "", "tests/test_io.nim" test "", "tests/test_io_bigints.nim"
test "", "tests/test_bigints.nim" test "", "tests/test_bigints.nim"
test "", "tests/test_bigints_multimod.nim" test "", "tests/test_bigints_multimod.nim"
test "", "tests/test_bigints_vs_gmp.nim" test "", "tests/test_bigints_vs_gmp.nim"

View File

@ -273,7 +273,7 @@ func hexToPaddedByteArray(hexStr: string, output: var openArray[byte], order: st
let maxStrSize = output.len * 2 let maxStrSize = output.len * 2
let size = hexStr.len - skip - nonBlanksCount let size = hexStr.len - skip - nonBlanksCount
doAssert size <= maxStrSize doAssert size <= maxStrSize, "size: " & $size & " (without blanks or prefix), maxSize: " & $maxStrSize
if size < maxStrSize: if size < maxStrSize:
# include extra byte if odd length # include extra byte if odd length
@ -330,6 +330,7 @@ func fromHex*(T: type BigInt, s: string): T =
# 1. Convert to canonical uint # 1. Convert to canonical uint
const canonLen = (T.bits + 8 - 1) div 8 const canonLen = (T.bits + 8 - 1) div 8
var bytes: array[canonLen, byte] var bytes: array[canonLen, byte]
debugEcho "canonLen: ", canonLen
hexToPaddedByteArray(s, bytes, littleEndian) hexToPaddedByteArray(s, bytes, littleEndian)
# 2. Convert canonical uint to Big Int # 2. Convert canonical uint to Big Int