-
Notifications
You must be signed in to change notification settings - Fork 158
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
Example steps to generate address from public key in C #362
Comments
first, you need to calculate the hash of the public key, we are using blake2b with a personalization string ( https://github.com/nervosnetwork/ckb/wiki/ckbhash ), this is the python demo code:
the first 20 bytes of the hash (adf33350760d7d939935c48751886ad55506c741) will be used as the script args, we call it blake160(PK), then you can use it to generate the payload. according to the rfc, the desired address format is Deprecated Short Payload Format, the payload is composed of the following data:
now you can use bech32 lib to encode the payload with the hrp
here is an online tool to verify the bech32 result ( https://slowli.github.io/bech32-buffer/ ) And I am sorry to say that there is no C sdk at the moment, but the main computational process here is blake2b and bech32/bech32m, and I think there are already some open source C libs (especially in the bitcoin related lib) that can be used. If you have any questions, please comment on the issue. |
thanks for the above info. Also can you let me know the derivation path from mnemonic to attain the desired public key for above operations. |
we follow the bip44, you may find registered nervos ckb coin type here: https://github.com/satoshilabs/slips/blob/master/slip-0044.md , the code is 309, and the derivation path is |
I am trying to implement Nervos address generation from public key in C. While following the steps mentioned in RFC, I am unable to generate the correct address. Are there any detailed examples showcasing intermediate values, so I can debug my logic?
I referenced this python demo and js sdk to verify the logic.
Example:
Address format - testnet short address
How do I generate the address mentioned ^? Since I am implementing it in C, I cannot use libraries from other languages. Is there any demo C implementation logic for the same?
Also are there any recommended C libraries for steps in generating address? (PK -> blake160(PK) -> payload -> address )
TIA
The text was updated successfully, but these errors were encountered: