diff --git a/Cargo.toml b/Cargo.toml index a4ce36f2..1b745586 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ members = [ "pallas-utxorpc", "pallas-hardano", "pallas-wallet", + "pallas-math", "pallas", "examples/block-download", "examples/block-decode", diff --git a/README.md b/README.md index 406a40c1..ee0757db 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ As already explained, _Pallas_ aims at being an expanding set of components. The | ------------------------------- | -------------------------------------------------- | | [pallas-crypto](/pallas-crypto) | Shared Cryptographic primitives | | [pallas-codec](/pallas-codec) | Shared CBOR encoding / decoding using minicbor lib | +| [pallas-math](/pallas-math) | Shared mathematics functions | ## Etymology diff --git a/pallas-math/Cargo.toml b/pallas-math/Cargo.toml new file mode 100644 index 00000000..4a21e9fa --- /dev/null +++ b/pallas-math/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "pallas-math" +description = "Mathematics functions for Cardano" +version = "0.27.0" +edition = "2021" +repository = "https://github.com/txpipe/pallas" +homepage = "https://github.com/txpipe/pallas" +documentation = "https://docs.rs/pallas-math" +license = "Apache-2.0" +readme = "README.md" +authors = ["Andrew Westberg "] + +[dependencies] +rug = "1.24.1" + +[dev-dependencies] +quickcheck = "1.0" +quickcheck_macros = "1.0" +rand = "0.8" diff --git a/pallas-math/README.md b/pallas-math/README.md new file mode 100644 index 00000000..95107f33 --- /dev/null +++ b/pallas-math/README.md @@ -0,0 +1,14 @@ +# Pallas Math + +Crate with all the mathematics functions to support Cardano protocol: + +- [] lncf - Approximate `ln(1+x)` for `x in 0..infinty`. +- [] cf - Compute continued fraction using max steps or bounded list of a/b factors. +- [] bound - Simple way to find integer powers that bound x. +- [] contract - Bisect bounds to find the smallest integer power such that `factor^n<=x i32 { + a + b +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_add() { + assert_eq!(add(1, 2), 3); + } +}