hyperledger / iroha-javascript

JavaScript library for Iroha, a Distributed Ledger Technology (blockchain) platform.
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
94 stars 64 forks source link

Implement sort for some Maps, Sets and Vecs #100

Open 0x009922 opened 2 years ago

0x009922 commented 2 years ago

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.