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

tx with params fails to sign #173

Open
hugomrdias opened this issue Nov 14, 2024 · 5 comments
Open

tx with params fails to sign #173

hugomrdias opened this issue Nov 14, 2024 · 5 comments

Comments

@hugomrdias
Copy link

hugomrdias commented Nov 14, 2024

This tx has a base64('hello world') in the params and throw "Data is invalid Unexpected data type"

8a00550191519a1de64c30be61381ac8168aa411770d0984550178b407e26c1825b937b85d8e506f492beff267f81905a24200011a001776a74400019c634400019845004b68656c6c6f20776f726c64

🔗 zboto Link

@hugomrdias
Copy link
Author

hugomrdias commented Nov 14, 2024

sorry didnt explain properly, its complete, the string is the hex encoded cbor buffer

@hugomrdias hugomrdias changed the title tx params fails to sign tx with params fails to sign Nov 14, 2024
@sourajyoti-gupta
Copy link

Hi @hugomrdias , thanks for letting us know that. We'll shortly be investigating this and get back to you with some any updates. Thanks!

@emmanuelm41
Copy link
Member

Hey @hugomrdias, I was actually testing the tx blob, and I noticed the params are encoded as byte string, which is correct. However, what it is found in the inside it is just the hex value for an ascii string, which we think it is not correct. Params are byte string encoded at tx level, but inside we expect a cbor encoded array, map or byte string.

This works (byte string encoded value inside params)

8A00550191519A1DE64C30BE61381AC8168AA411770D0984550178B407E26C1825B937B85D8E506F492BEFF267F81905A24200011A001776A74400019C634400019845004C4B68656C6C6F20776F726C64

8A                                      # array(10)
   00                                   # unsigned(0)
   55                                   # bytes(21)
      0191519A1DE64C30BE61381AC8168AA411770D0984 # "\u0001\x91Q\x9A\u001D\xE6L0\xBEa8\u001A\xC8\u0016\x8A\xA4\u0011w\r\t\x84"
   55                                   # bytes(21)
      0178B407E26C1825B937B85D8E506F492BEFF267F8 # "\u0001x\xB4\a\xE2l\u0018%\xB97\xB8]\x8EPoI+\xEF\xF2g\xF8"
   19 05A2                              # unsigned(1442)
   42                                   # bytes(2)
      0001                              # "\u0000\u0001"
   1A 001776A7                          # unsigned(1537703)
   44                                   # bytes(4)
      00019C63                          # "\u0000\u0001\x9Cc"
   44                                   # bytes(4)
      00019845                          # "\u0000\u0001\x98E"
   00                                   # unsigned(0)
   4C                                   # bytes(12)
      4B68656C6C6F20776F726C64          # "Khello world"

4B68656C6C6F20776F726C64

4B                        # bytes(11)
   68656C6C6F20776F726C64 # "hello world"

This works (array encoded value inside params)

8A00550191519A1DE64C30BE61381AC8168AA411770D0984550178B407E26C1825B937B85D8E506F492BEFF267F81905A24200011A001776A74400019C634400019845004D814B68656C6C6F20776F726C64

8A                                      # array(10)
   00                                   # unsigned(0)
   55                                   # bytes(21)
      0191519A1DE64C30BE61381AC8168AA411770D0984 # "\u0001\x91Q\x9A\u001D\xE6L0\xBEa8\u001A\xC8\u0016\x8A\xA4\u0011w\r\t\x84"
   55                                   # bytes(21)
      0178B407E26C1825B937B85D8E506F492BEFF267F8 # "\u0001x\xB4\a\xE2l\u0018%\xB97\xB8]\x8EPoI+\xEF\xF2g\xF8"
   19 05A2                              # unsigned(1442)
   42                                   # bytes(2)
      0001                              # "\u0000\u0001"
   1A 001776A7                          # unsigned(1537703)
   44                                   # bytes(4)
      00019C63                          # "\u0000\u0001\x9Cc"
   44                                   # bytes(4)
      00019845                          # "\u0000\u0001\x98E"
   00                                   # unsigned(0)
   4D                                   # bytes(13)
      814B68656C6C6F20776F726C64        # "\x81Khello world"

814B68656C6C6F20776F726C64

81                           # array(1)
   4B                        # bytes(11)
      68656C6C6F20776F726C64 # "hello world"

This does NOT work (your tx blob)

8a00550191519a1de64c30be61381ac8168aa411770d0984550178b407e26c1825b937b85d8e506f492beff267f81905a24200011a001776a74400019c634400019845004b68656c6c6f20776f726c64

8A                                      # array(10)
   00                                   # unsigned(0)
   55                                   # bytes(21)
      0191519A1DE64C30BE61381AC8168AA411770D0984 # "\u0001\x91Q\x9A\u001D\xE6L0\xBEa8\u001A\xC8\u0016\x8A\xA4\u0011w\r\t\x84"
   55                                   # bytes(21)
      0178B407E26C1825B937B85D8E506F492BEFF267F8 # "\u0001x\xB4\a\xE2l\u0018%\xB97\xB8]\x8EPoI+\xEF\xF2g\xF8"
   19 05A2                              # unsigned(1442)
   42                                   # bytes(2)
      0001                              # "\u0000\u0001"
   1A 001776A7                          # unsigned(1537703)
   44                                   # bytes(4)
      00019C63                          # "\u0000\u0001\x9Cc"
   44                                   # bytes(4)
      00019845                          # "\u0000\u0001\x98E"
   00                                   # unsigned(0)
   4B                                   # bytes(11)
      68656C6C6F20776F726C64            # "hello world"

You can see it here

switch (itParams.type) {
case CborArrayType: {
size_t arrayLength = 0;
CHECK_CBOR_MAP_ERR(cbor_value_get_array_length(&itParams, &arrayLength))
PARSER_ASSERT_OR_ERROR(arrayLength < UINT8_MAX, parser_value_out_of_range)
tx->numparams = arrayLength;
break;
}
case CborMapType: {
size_t mapLength = 0;
CHECK_CBOR_MAP_ERR(cbor_value_get_map_length(&itParams, &mapLength))
PARSER_ASSERT_OR_ERROR(mapLength < UINT8_MAX, parser_value_out_of_range)
tx->numparams = mapLength;
break;
}
case CborByteStringType: {

@emmanuelm41
Copy link
Member

@hugomrdias can you please check whether this solve your issue or not? If it does so, let me know and I can close the issue! Thanks

@hugomrdias
Copy link
Author

AFAIK params can be anything base64pad string or bytes when in cbor.
For example glif.io uses params for custom messages and their explorer decodes base64 strings to UTF-8 and displays it in the web ui.

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

3 participants