-
Notifications
You must be signed in to change notification settings - Fork 1
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
trytes conversion doesn't work for longer trytes #11
Comments
Produced output
|
Sorry, could you please elaborate? When I test your code, and change the content of
When I try to decode back to the original
I get |
You are right, I think our conversion methods fundamentally are different. I was trying to decode IOTA gossip protocol (between two IRIs) using your library and that's when I discovered the difference. IOTA converts Trytes to trits and then converts 5 trits to a single byte in a 2's complement representation. I wrote another utility which converts Trytes to Trits and then to bytes in the format which is understood by IOTA. So I think we could close this by clearly explaining that this is not compliant with IOTA gossip protocol conversion method. |
Ah. That makes more sense. :) I've based my conversion on the trits forming values from 0-26, unsigned, and counting up to 0-242 when shifting trits into tryte5s. Will add a note that states this is not gossip compliant. Length of original messageI like your web site. I see that you too have the problem of needing exactly 5 of the tryte3 characters, to avoid the trailing 9s, when converting back. Not sure if the gossip protocol also has that problem. You need to either accept the limitation of 5 trytes; add a length value; or add a terminator. I ended up adding a terminator, one that indicates who many trytes to shave off when decoding the bytes back to trytes. Encoding instead of conversionAlso, as a last note of what I found out, having a tryte-byte-fight. There is no such thing as a two way tryte-byte conversion, using the same methods. (The IOTA Foundation is doing the same mistake, using a method name like trytesToAscii() that can only take values up to 255, not all the way to 727. : ) Just looking at you web site, I get the impression that I can also take a byte array, and convert it to trytes, and then convert it back later. (Let's say if I want to send Unicode message in an IOTA transaction, or convert an encrypted seed (which will use the full 0-255 range of a byte) into trytes. But sadly it dosen't work like that. I recommend you rename it to indicate that your are only encoding trytes as bytes, and that you can decode them back to the original trytes. Try converting the three bytes '0x37 0x80 0x2E' to trytes, and then back... ;-) |
While converting larger trytes in IOTA, the conversion doesn't work reliably and produces different output than the conventional method.
Here is a program which demonstrates the problem
The text was updated successfully, but these errors were encountered: