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

Use varuint encoding for message prefix #123

Closed
kyranjamie opened this issue Jul 29, 2022 · 2 comments
Closed

Use varuint encoding for message prefix #123

kyranjamie opened this issue Jul 29, 2022 · 2 comments
Assignees

Comments

@kyranjamie
Copy link
Contributor

kyranjamie commented Jul 29, 2022

As discussed in #90 and this previous bug on geth, the message prefix should be encoded using a variable length integer.

I'm learning as I go, but as far as I understand, this is because ascii decimal encoding presents the issue that ...\n12... is ambiguous. Is it length 1 with value 2, or 12. And that using a varuint encoding fixes this.

Stacks.js implementation using this encoding

🔗 zboto Link

@neithanmo
Copy link
Collaborator

neithanmo commented Jul 29, 2022

our implementation in a sense uses this approach..
the parser reads the first digit and checks if it matches the remaining data len, if not, it moves to the next digit, and now reads both as a len, and check if it matches the remaining data len and so on.
but we can adjust to use this new approach, which is faster than read, check, advance and check again..

@neithanmo neithanmo self-assigned this Jul 29, 2022
@kyranjamie
Copy link
Contributor Author

kyranjamie commented Jul 29, 2022

I believe so, yes

For the message Hello world! we'd expect: \x17Stacks Signed Message:\n\fHello world!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants