Change endianness to BigEndian :(

Change endianness to BigEndian (ಥ﹏ಥ), spec has been updated to achieve
compatibility with js & smart contracts & circuits implementations.
This commit is contained in:
arnaucube
2020-09-18 09:39:58 +02:00
parent 92fa8aa439
commit 3013fbacb6
11 changed files with 146 additions and 130 deletions

View File

@@ -37,7 +37,7 @@ type TokenID uint32 // current implementation supports up to 2^32 tokens
// Bytes returns a byte array of length 4 representing the TokenID
func (t TokenID) Bytes() []byte {
var tokenIDBytes [4]byte
binary.LittleEndian.PutUint32(tokenIDBytes[:], uint32(t))
binary.BigEndian.PutUint32(tokenIDBytes[:], uint32(t))
return tokenIDBytes[:]
}
@@ -51,6 +51,6 @@ func TokenIDFromBytes(b []byte) (TokenID, error) {
if len(b) != tokenIDBytesLen {
return 0, fmt.Errorf("can not parse TokenID, bytes len %d, expected 4", len(b))
}
tid := binary.LittleEndian.Uint32(b[:4])
tid := binary.BigEndian.Uint32(b[:4])
return TokenID(tid), nil
}