Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create KeyPair from byte[] secretKey #84

Open
niekvse opened this issue Nov 10, 2017 · 1 comment
Open

Can't create KeyPair from byte[] secretKey #84

niekvse opened this issue Nov 10, 2017 · 1 comment

Comments

@niekvse
Copy link

niekvse commented Nov 10, 2017

After migrating our code from kalium to libsodium-jni, it's no longer possible to generate a KeyPair from a byte[] secretKey.

See also this change:

This constructor was commented out:

//    public KeyPair(byte[] secretKey) {
//        this.secretKey = secretKey;
//        checkLength(this.secretKey, SECRETKEY_BYTES);
//    }

How are we supposed to generate a KeyPair when we only have the secretKey stored locally? In the past, we used that constructor (KeyPair(byte[] secretKey)) which is now gone. We can of course subclass this class and put it back (copying all the other code as well) but it's not really ideal.

Also, your other constructor's first argument now has a confusing/wrong name:

public KeyPair(String secretKey, Encoder encoder) {
    this(encoder.decode(secretKey));
}

That String secretKey argument is now actually a seed, because it calls the KeyPair(byte[] seed) constructor.

How did you envision this upgrade path scenario from old clients using the KeyPair(byte[] secretKey) constructor? (clients that have already stored that key)

Perhaps you can add that constructor back, or add it as a static factory method (or find some other workaround for the fact they have the same signature).

@joshjdevl
Copy link
Owner

I would be happy to take a pull request for the proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants