[Steem-JS] Fix invalid sequence when disabling witness with null key

Img Source
Description
This submission details a fix in the SteemJS library that would return an error when attempting to disable a witness by sending a null key. Upon sending the null key, users would receive an "Invalid sequence" error suggesting that their public key was malformed. Similar issues have appeared in bitshares and in the corresponding bitshares-js. Some of the knowledge of this issue and fix was adopted from bitshares.
Summary
When using SteemJS to send a witness update with STM1111111111111111111111111111111114T1Anm as the key an error occurred.
Changed files
src/auth/ecc/src/key_public.js
test/KeyFormats.js
Related code
static fromBuffer(buffer) {
+ if (
+ buffer.toString("hex") ===
+ "000000000000000000000000000000000000000000000000000000000000000000"
+ )
+ return new PublicKey(null);
return new PublicKey(ecurve.Point.decodeFrom(secp256k1, buffer));
}
- toBuffer(compressed = this.Q.compressed) {
+ toBuffer(compressed = this.Q ? this.Q.compressed : null) {
+ if (this.Q === null)
+ return Buffer.from(
+ "000000000000000000000000000000000000000000000000000000000000000000",
+ "hex"
+ );
return this.Q.getEncoded(compressed);
}
Links
Vote @netuoso as Witness
- Click the link above and input your active private key when asked to vote
- Alternatively, visit https://steemit.com/~witnesses
- Or click here to set @netuoso as your voting proxy
Posted on Utopian.io - Rewarding Open Source Contributors
Thanks for the contribution, @netuoso. A small, but relatively valuable fix - good work!
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @netuoso
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you!!!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit