diff --git a/.changes/add-ed25519-tests.md b/.changes/add-ed25519-tests.md new file mode 100644 index 00000000..933071f6 --- /dev/null +++ b/.changes/add-ed25519-tests.md @@ -0,0 +1,5 @@ +--- +"iota-crypto": minor +--- + +Add ed25519 test suite. diff --git a/tests/x25519.rs b/tests/x25519.rs index 000bebb6..42ba765a 100644 --- a/tests/x25519.rs +++ b/tests/x25519.rs @@ -20,22 +20,22 @@ fn test_x25519_rfc7748() -> crypto::Result<()> { for tv in tvs.iter() { let secret_a: SecretKey = { let bytes = hex::decode(tv.secret_a).unwrap(); - SecretKey::from_bytes(&bytes).unwrap() + SecretKey::from_bytes(&bytes)? }; let public_a: Option = { let bytes = tv.public_a.map(hex::decode).transpose().unwrap(); - bytes.map(|bytes| PublicKey::from_bytes(&bytes)).transpose().unwrap() + bytes.map(|bytes| PublicKey::from_bytes(&bytes)).transpose()? }; let secret_b: Option = { let bytes = tv.secret_b.map(hex::decode).transpose().unwrap(); - bytes.map(|bytes| SecretKey::from_bytes(&bytes)).transpose().unwrap() + bytes.map(|bytes| SecretKey::from_bytes(&bytes)).transpose()? }; let public_b: PublicKey = { let bytes = hex::decode(tv.public_b).unwrap(); - PublicKey::from_bytes(&bytes).unwrap() + PublicKey::from_bytes(&bytes)? }; let expected: Vec = hex::decode(tv.shared).unwrap(); diff --git a/utils/test_vectors/py/ed25519_sign_transform.py b/utils/test_vectors/py/ed25519_sign_transform.py index affa4122..0ce8f61e 100644 --- a/utils/test_vectors/py/ed25519_sign_transform.py +++ b/utils/test_vectors/py/ed25519_sign_transform.py @@ -1,11 +1,12 @@ import sys import binascii -#generates ed25519_sign.rs by using python3 ed25519_sign_transform.py < sign.input > ed25519_sign.rs +# generates ed25519_sign.rs by using python3 ed25519_sign_transform.py < sign.input > ed25519_sign.rs print("[") while 1: line = sys.stdin.readline() - if not line: break + if not line: + break x = line.split(':') # 64-byte secret key - it consists of 32-byte seed and 32 additional bytes which @@ -23,4 +24,4 @@ print(f" signature: \"{sig.hex()}\",") print(" },") -print("]") \ No newline at end of file +print("]")