diff --git a/sdk/src/signer/keypair.rs b/sdk/src/signer/keypair.rs index 3183dac88e8b70..1873996a399391 100644 --- a/sdk/src/signer/keypair.rs +++ b/sdk/src/signer/keypair.rs @@ -44,6 +44,11 @@ impl Keypair { /// Recovers a `Keypair` from a byte array pub fn from_bytes(bytes: &[u8]) -> Result { + if bytes.len() < ed25519_dalek::KEYPAIR_LENGTH { + return Err(ed25519_dalek::SignatureError::from_source(String::from( + "candidate keypair byte array is too short", + ))); + } let secret = ed25519_dalek::SecretKey::from_bytes(&bytes[..ed25519_dalek::SECRET_KEY_LENGTH])?; let public =