bip-schnorr icon indicating copy to clipboard operation
bip-schnorr copied to clipboard

Recommended way to derive public keys?

Open faustbrian opened this issue 3 years ago • 1 comments

Resolves my issues from https://github.com/guggero/bip-schnorr/issues/29#issuecomment-1096422957 but wondering one last bit. I currently use https://github.com/bcoin-org/bcrypto/blob/master/lib/js/schnorr.js#L251-L261 to derive public keys but in the aforementioned mentioned issue you mentioned that the issue most likely is that they don't support x-only public keys which is most likely the cause of failing tests.

What would be the recommended way to generate a private key and public key with this library that are compatible with all actions?

faustbrian avatar Apr 24 '22 02:04 faustbrian

Deriving the public keys isn't the hard part. A 32-byte (x-only) public key is just the compressed, 33-byte public key with the first byte chopped off. There's a lift_x method explained in BIP-0340 for how you get back to the original point. The more complicated thing to implement though is how this affects the parity of everything. But that's also all explained in BIP 340.

guggero avatar Apr 25 '22 08:04 guggero