Converting a vector<u8> to a u256 in Move #593
Replies: 1 comment
-
I solved it in a way I guess, but I still want to know if there are other more idiomatic ways to do it. So I have a vector in Move and a Buffer in javascript, I can verify they contain the same bytes. Its the output of so to convert it to an integer that is the same on both sides, I had to do it manually: In Move I break up the vector into individual bytes and cast them to u256, then add them together with bit shifting with little endian ordering.
And I did the same in Javascript but casting the bytes of the buffer to BigInt: This was the only way I could get the same integer from a vector and Buffer consistently both in Move and Javascript. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello
I am looking to convert vector to a u256 in Move.
I am looking to do the equivalent of bytesToBigIntLE from "@aptos-labs/ts-sdk" but in Move.
I am hashing an address with blake2b_256 and I want to convert the resulting vector into an integer.
I can do it in javascript with BigInt and the mentioned ts-sdk funcitons, but I would like to do the same in Move.
How do I convert a 32 byte vector to a u256 ?
Beta Was this translation helpful? Give feedback.
All reactions