nkeys icon indicating copy to clipboard operation
nkeys copied to clipboard

[BUG] - update types to use fixed-length slices

Open 5225225 opened this issue 3 years ago • 2 comments

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.

5225225 avatar Jan 21 '22 08:01 5225225

Good catch on this one, thanks.

autodidaddict avatar Jan 21 '22 12:01 autodidaddict

@connorsmith256 looks like we had something similar to your comment filed -- you think we can use this to represent that refactoring?

vados-cosmonic avatar Nov 28 '23 16:11 vados-cosmonic