Implement `from_slice` for keys and nonce.