-
Notifications
You must be signed in to change notification settings - Fork 757
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
Encoding for "shortstring" typed data (SNIP-12) #1039
Comments
Hi, I'm trying to implement SNIP-12 in Based on the current impl: starknet.js/src/utils/typedData.ts Lines 424 to 429 in 8c65fa8
a type of However, fixing this bug has some pretty devastating implications. First of all, the bug conveniently accommodates an exception outlined in the spec:
with this bug the This is a minor issue though. Some refactoring can be done to actually implement the exception specifically for that domain field. The bigger issue is just the fact that fixing this bug itself is a breaking change. Many applications might already depend on the current behaviour. Making matters worse, this bug affects the domain hash, which is usually hard-coded in contracts for verification purposes. Upgrading them would either need to be a huge coordinated effort or simply impossible. So I guess whichever direction we take, at least one of these need to be done:
|
Hey @thiagodeev I saw you committed to SNIP-12 so pinging you here. Any thoughts on this? Thanks! |
Hi @xJonathanLEI. I recommend you to keep implementing the feature by comparing it with starknet.js, because as you said, it's the most widely used. In the meantime, you can keep analyzing it until finding an answer. Please let me know the result of your research. Thanks |
Considering this issue and the faulty enum encoding noted within #1292, the option of introducing a new revision to the SNIP-12 spec was brought up as a possible solution. The avenue would be to modify the revision 1 spec in line with the current implementation, and the corrected implementation to be represented as revision 2. Tagging various people that have been involved with the topic, feel free to bring anyone else into the discussion as you deem appropriate: @xJonathanLEI @thiagodeev @sgc-code @gaetbout @DelevoXDG @yoga-braavos @PhilippeR26 @amanusk @tabaktoni |
I want to draw attention to the approach taken with the
shortstring
encoding. It was implemented by reusing the existingfelt
encoding.As a basic example, a provided value
"hello"
will be encoded as0x68656c6c6f
, this I believe to not be contentious. The part where I believe there might be issues with is the encoding of numerical strings, the existingfelt
encoding treats both numbers and numerical strings as the same value and such behaviour might be undesirable/unexpected for theshortstring
type. As an example"2"
will be encoded as0x2
while someone coming from a Cairo background will probably assume it to be encoded as0x32
.Added context: This issue is a copy of the issue noted in this PR comment.
The text was updated successfully, but these errors were encountered: