-
Notifications
You must be signed in to change notification settings - Fork 12
API change: Helper functions to combine/merge keys #2
Comments
As a rule, the keypair is the secret key type and the actual private key type should never be used. It's okay to use the private key type for serialization though, as you can derive the keypair from the secret key. |
Based on the latest discussion with @jacogr who will be first to use this library I was informed that having the public/private portions separated is actually more convenient for him. This will still be open to change but I think it is fine as in the context of wasm exported function, none of the rust-defined data structures such as |
It's fine to separate them for user facing js things that do not require high performance, just provide a sign function that calls In practice, almost all methods in this library use only a |
That rename would have helped ;) Never too late, we still need updates, so rather earlier than later. But yes, the public portion is separated out since that is used (via ss58) to represent the address. EDIT: With a rename (i.e. pair is actually secretKey), it makes more sense to pass it in as a whole |
I'm torn still because really all performant dlog crypto libraries should have keypair types that provide this optimization. It's maybe worse to hide the keypair form a person who is looking for it? Also, there are two serializations for a keypair with maybe the best being to serialize only If we renamed, then what name should the existing secret key be then? |
Ok, now I get your dilemma... Not a cryptographer, so it took me a while to get on the same page. I can only comment on a external use perspective where (in "simpler" libraries, e.g. sodium), you only have the But then you start looking at derivation and friends, and well, clueless. |
In the end, this is a performance optimization, but it's often best to stick with the usual terminology. I actually did one rename here already btw:
I felt justified in that rename because it's makes our soft BIP32 analog in derive.rs far more intuitive and no sane terminology or standards exists in that area. Anyways just because I do one thing in schnorrkel does not mean that schnorrkel-js needs to do the same thing. If the js stuff is not used for anything high performance then you can call |
Based on the discussion I can propose the following to be A) more aligned with how the original schnorrkel is working B) performant C) easier to use for JS
I am not sure if we still need the
I think this is fulfilling in the sense that:
I actually do agree that this looks better. Much better. |
The above API is implemented but not yet merged published in #4. |
Currently, one of the API functions returns a byte array which is the concatenation of the private and public key respectively.
It is the user's duty to properly separate them as documented in the Rust code.
While there also exists another function which does almost the same but only returns the
secret/private
portion of the key.Consequently, the sign function is currently accepting the public and private key separately.
Based on the above, I see at least two improvements that could be made:
secret_from_seed
even needed?private_from_pair(keypair)
etc.The text was updated successfully, but these errors were encountered: