Closed larry0x closed 1 day ago
Note: when importing crypto-bigint, make sure to disable default features, otherwise randomness operators are included
[dependencies.crypto-bigint]
git = "https://github.com/left-curve/crypto-bigint"
branch = "v0.5.5-grug"
default-features = false
features = ["serde", "borsh"]
Based on the current design:
bnum
to crypt-bigint
;Signed
and Int
types created with macros;Signed<T>
;Signed<T>
Signed
(Decimals
and Int
) with new macros;Completed
In CosmWasm there are the types
Uint{64,128,256,512}
but they are basically the same file copy-pasted. Same situation withInt64/128/256/512
,Decimal128/512
, andSignedDecimal128/512
. We want to avoid the duplicate code.Also, CosmWasm uses bnum underneath which isn't a particularly popular library (only about 500k all time downloads).
Ideas:
Switch from bnum to crypto-bigint, which is part of RustCrypto, a high quality project, and is the basis of crypto libraries such as elliptic-curve.
Create a single
Uint<T>
struct to represent all unsigned integer types:Create a
Decimal<T>
type to represent all fixed-point number types:Create a
Signed<T>
type to represent all signed number types: