iroha-javascript icon indicating copy to clipboard operation
iroha-javascript copied to clipboard

Implement sort for some Maps, Sets and Vecs

Open 0x009922 opened this issue 3 years ago • 0 comments

The issue is that some structs, like Signatures, are sorted. That is, no matter in what order entries are inserted in the map or set (in Rust), when the map or set is encoded, its entries are sorted using PartialEq trait. It is wise - the exact encoded form has impact on hashing and signing (which could have BTreeMap metadata, for example). The ordered encoding ensures consistent output despite the insertion order.

The problem is that the JavaScript SDK doesn't perform sorting on encoding, so, signature check failures might be thrown by Iroha if SDK users don't sort some structs content on their own.

0x009922 avatar Apr 24 '22 04:04 0x009922