Skip to content

Commit

Permalink
modify a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Coats committed Jan 16, 2024
1 parent e9e2d12 commit d7a27bd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub const SECRET_KEY_LENGTH: usize = 32;
pub const PUBLIC_KEY_LENGTH: usize = 32;
pub const SIGNATURE_LENGTH: usize = 64;

use crypto::signatures::ed25519::{PublicKey, SecretKey, Signature};
use crypto::signatures::ed25519::{PublicKey, PublicKeyBytes, SecretKey, Signature};

#[test]
fn test_zip215() -> crypto::Result<()> {
Expand All @@ -24,13 +24,13 @@ fn test_zip215() -> crypto::Result<()> {
for tv in tvs.iter() {
let mut pkb = [0; PUBLIC_KEY_LENGTH];
hex::decode_to_slice(tv.public_key, &mut pkb as &mut [u8]).unwrap();
let pk = PublicKey::try_from_bytes(pkb)?;
let pk = PublicKeyBytes::from_bytes(pkb);

let mut sigb = [0; SIGNATURE_LENGTH];
hex::decode_to_slice(tv.signature, &mut sigb as &mut [u8]).unwrap();
let sig = Signature::from_bytes(sigb);

assert!(PublicKey::verify(&pk, &sig, ms));
assert!(pk.verify(&sig, ms)?);
}

Ok(())
Expand All @@ -55,9 +55,9 @@ fn test_malleability() -> crypto::Result<()> {
0x7d, 0x4d, 0x0e, 0x7f, 0x61, 0x53, 0xa6, 0x9b, 0x62, 0x42, 0xb5, 0x22, 0xab, 0xbe, 0xe6, 0x85, 0xfd, 0xa4,
0x42, 0x0f, 0x88, 0x34, 0xb1, 0x08, 0xc3, 0xbd, 0xae, 0x36, 0x9e, 0xf5, 0x49, 0xfa,
];
let pk = PublicKey::try_from_bytes(pkb)?;
let pk = PublicKeyBytes::from_bytes(pkb);

assert!(!PublicKey::verify(&pk, &sig, &ms));
assert!(!pk.verify(&sig, &ms)?);

Ok(())
}
Expand Down

0 comments on commit d7a27bd

Please sign in to comment.