web3j
web3j copied to clipboard
Update the Web3J documentation to contain signatures
Problem statement
Currently, the documentation is not showing how to sign random messages using Web3j and how to use those signatures. And, as a result of that, we have multiple issues in GitHub, and also other platform like Stack exchange where people ask for help concerning this. Also, some people might have different results depending on the methods used. Example issues: https://github.com/web3j/web3j/issues/208, https://github.com/web3j/web3j/issues/1662 etc
Proposed solution
It would be awesome to add to the docs this functionality via opening a new PR here.
The PR could contain:
- How to use the Sign class to generate signatures for random messages.
- How the SignatureData can be used
- Example code snippets
This work can be inspired from the way web3JS
is handling signatures and their documentation.
Stretch goal
Add to<standard>String()
method to SignatureData that returns the hex encoding of the signature (aside from the raw r
, s
and v
values) following different standards:
- Simply concatenating their values
- EIP-155 way, etc
Thanks, Rachid, this is a good proposal. By random message, do you mean arbitrary-sized message?
Thanks. Something like:
Credentials credentials = Credentials.create("0x1234");
byte[] msg = "hello".getBytes();
Sign.SignatureData signature = Sign.signMessage(msg, credentials.getEcKeyPair());
Where we show people how to create credentials, how to use them to sign arbitrary-sized messages, how to handle the resulting signature, etc. I noticed a need for this in multiple issues. It would be good to have a link containing all this information and share it with people.
@mohamedelshami What do you think if we open a tracking issue for these documentation issues. So that if someone picks up documentation, then, they will already have a list of stuff that needs to be added. Let me know if you think it is a good idea, and I will create something and start populating it with docs proposals.
@SweeXordious it's definitely a good idea. Pretty sure there's a good a number of open issues related to lack of documentation.