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

feat: add new methods for conversion between Ed25519 public key and long account ID (as defined in HIP-32) #2063

Closed
bguiz opened this issue Dec 14, 2023 · 0 comments · Fixed by #2066
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bguiz
Copy link
Member

bguiz commented Dec 14, 2023

Problem

Why

  • Some Mirror Node APIs do not accept the default serialisation format for the public key, and this conversion needs to be performed first
  • In some circumstances, one needs to have a valid account ID, prior to the account being initialised on the network, for example in order to receive an initial transfer

Context: HIP-32 defines the a long form account ID like so:

This long form doesn’t look like 0.0.123, but instead is an alias consisting of <shard>.<realm>.<bytes>, where the bytes is a base32url representation of the bytes of a serialized HAPI primitive Key, with the trailing = padding characters removed. For example, 0.0.CIQNOWUYAGBLCCVX2VF75U6JMQDTUDXBOLZ5VJRDEWXQEGTI64DVCGQ is the alias address of shard 0 realm 0 with a serialization of a HAPI Key for the ed25519 public key 0xd75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a.

Solution

What

  • Consider adding utility methods in EntityIdHelper class or the PublicKey class
  • One method to convert from Ed25519 public key to long account ID, for example:
    • Input: d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a
    • Output: CIQNOWUYAGBLCCVX2VF75U6JMQDTUDXBOLZ5VJRDEWXQEGTI64DVCGQ
  • Another method to convert from long account ID to Ed25519 public key, for example:
    • Input: CIQNOWUYAGBLCCVX2VF75U6JMQDTUDXBOLZ5VJRDEWXQEGTI64DVCGQ
    • Output: d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a
  • Take into account the specific configuration of base32url

Alternatives

Further considerations

  • HIP-32 does not define behaviour for ECDSA secp256k1 public keys (as it predates them being on Hedera, slightly, Dec 2021 vs Feb 2022)
    • This is beyond the scope of this github issue, but is something worth investigating separately

References

@bguiz bguiz added the enhancement New feature or request label Dec 14, 2023
@Petyo-Lukanov Petyo-Lukanov added this to the 2.40.0 milestone Dec 14, 2023
@SimiHunjan SimiHunjan modified the milestones: 2.40.0, 2.41.0 Dec 14, 2023
@Petyo-Lukanov Petyo-Lukanov modified the milestones: 2.41.0, 2.40.0 Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants