nimiq / core-rs

Official Rust implementation of the Nimiq protocol
https://nimiq.com
Other
74 stars 10 forks source link

Check that Coin is not serialized with values > Javascript's MAX_SAFE_INTEGER #8

Closed jgraef closed 5 years ago

jgraef commented 5 years ago

In primitives/src/coin.rs there is a comment in the Deserialize implementation which says:

Check that the value does not exceed Javascript's Number.MAX_SAFE_INTEGER.

Shouldn't we check that then on serialization too? Serialization is currently auto-derived and thus just serializes the u64 even if it's greater than Javascripts MAX_SAFE_INTEGER.

Also the checked_add should check this.

jgraef commented 5 years ago

Closed with Commit Bugfix in primitives::Coin