Add raw hash signing function (without the wrapping in Ethereum message: ...)
https://docs.web3js.org/libdocs/Accounts#sign
scope: add function, doc, unit test ( with recovery )
@jdevcs Hey, is anyone working on this? I'd love to try this one. I plan to add one more option parameter into the hashMessage to add support for whether there is a prefix or not.
https://github.com/web3/web3.js/blob/f70140693b14edb20891a4c8554f5fcc58dc6dd3/packages/web3-eth-accounts/src/account.ts#L159
Overall, should we introduce new function pairs, such as signRaw/recoverRaw, or modify the logic of the existing sign/recover?
The latter might introduce breaking changes, because the current prefixed param of recover actually combines whether to hash and add a prefix. If we modify the existing functionality, this logic might change.
https://github.com/web3/web3.js/blob/f70140693b14edb20891a4c8554f5fcc58dc6dd3/packages/web3-eth-accounts/src/account.ts#L424
@blackmoshui thanks for your contribution, We will prefer to avoid breaking change.
Hey @blackmoshui, just wanted to confirm that you want to implement this? Let us know if you have any questions. The main thing we want to ensure is that we want to avoid breaking changes.
Hey @blackmoshui, just wanted to confirm that you want to implement this? Let us know if you have any questions. The main thing we want to ensure is that we want to avoid breaking changes.
I understand that avoiding breaking changes in a client-side SDK is very important.
I plan to add an optional parameter to hashMessage to support not adding a prefix, then add a new signRaw function along with corresponding tests and documentation.
In the initial PR, I won't add functions like recoverRaw because users can combine existing hashMessage and recover functions to implement recovery themselves. I believe this approach won't introduce any breaking changes.
What do you think? I can prepare a draft PR first.
@jdevcs?
I prepared a PR, but after completing it I realized that we could also achieve this functionality by modifying the existing sign function instead of adding a new function. I can modify the PR if needed.