nkeys
nkeys copied to clipboard
[BUG] - update types to use fixed-length slices
There are a few places where library functions can panic, when an input is an unexpected length. For example, when KeyPair signature is incorrect length:
fn main() {
let kp = nkeys::KeyPair::new_user();
kp.verify(&[], &[]);
}
This panics, it does not return an error.
If the signature is always meant to be 64 bytes long, and you can't do anything useful with something that isn't 64 bytes long, I'd just take a &[u8; 64] and expect the caller to do the conversion. That would be a breaking change, but it means the copy_from_slice can never fail.
Good catch on this one, thanks.
@connorsmith256 looks like we had something similar to your comment filed -- you think we can use this to represent that refactoring?