wallet-core icon indicating copy to clipboard operation
wallet-core copied to clipboard

[PrivateKey] Add shortcut method to get `PublicKey` from `CoinType`

Open hewigovens opened this issue 3 years ago • 3 comments

We have these methods in TWPrivateKey.h:

  • TWPrivateKeyGetPublicKeySecp256k1
  • TWPrivateKeyGetPublicKeyEd25519
  • TWPrivateKeyGetPublicKeyNist256p1
  • ...

Would be easier for the app to have a method like TWPrivateKeyGetPublicKey(TWCoinType)

hewigovens avatar Oct 17 '22 22:10 hewigovens

In the internal C++ class we have with publicKeyType parameter. I'm not sure why in the C version we have named versions for different types. If we follow the same approach, we should have a version with publicKeyType (caller has to first retrieve public key type from coin type). But your suggestion is more convenient for the caller. https://github.com/trustwallet/wallet-core/blob/master/src/PrivateKey.h#L65

optout21 avatar Oct 18 '22 07:10 optout21

@hewigovens @catenocrypt TWCoinType include TWPrivateKey.h

There is a circular dependencies, and forward enum declaration are not authorized in C++ - do we implement the function in TWCoinType.h?

Otherwise I can just move the enum in a standalone file and continue the implementation as expected

Milerius avatar Oct 18 '22 07:10 Milerius

In the internal C++ class we have with publicKeyType parameter. I'm not sure why in the C version we have named versions for different types. If we follow the same approach, we should have a version with publicKeyType (caller has to first retrieve public key type from coin type). But your suggestion is more convenient for the caller. https://github.com/trustwallet/wallet-core/blob/master/src/PrivateKey.h#L65

We can have both possibility - there is some use case where in CLI the second version is more appropriate.

Milerius avatar Oct 18 '22 07:10 Milerius