Add FieldElementSize

This commit is contained in:
akshaya
2024-08-05 09:13:25 -04:00
parent 086b1dc3dd
commit 01ff8db20a
2 changed files with 6 additions and 5 deletions

View File

@@ -6,13 +6,14 @@ license = "MIT"
# Dependencies
requires "nim >= 1.6.0"
requires "nimcrypto"
requires "nimcrypto >= 0.6.0"
requires "libp2p >= 1.4.0"
requires "protobuf_serialization >= 0.3.0"
requires "serialization >= 0.2.2"
# Set the source directory
srcDir = "src"
# Tasks
task test, "Run the test suite":
exec "nim c -r --path:src tests/test_crypto.nim"
exec "nim c -r --path:src tests/test_curve25519.nim"
exec "nim c -r --path:src tests/test_curve25519.nim"

View File

@@ -15,8 +15,8 @@ suite "Curve25519 Tests":
(privateKey, publicKey) = generateKeyPair()
# Assert the length of the keys
assert fieldElementToBytes(privateKey).len == Curve25519KeySize, "Private key size must be 32 bytes"
assert fieldElementToBytes(publicKey).len == Curve25519KeySize, "Public key size must be 32 bytes"
assert fieldElementToBytes(privateKey).len == FieldElementSize, "Private key size must be 32 bytes"
assert fieldElementToBytes(publicKey).len == FieldElementSize, "Public key size must be 32 bytes"
# Assert that the keys are not empty (i.e., not all zeros)
assert privateKey.isNotZero(), "Private key is empty"