# Using Rust differential privacy libraries in contracts

**URL:** <https://forum.scrt.network/t/using-rust-differential-privacy-libraries-in-contracts/2645>\
**Category:** Developer Help\
**Created:** [February 16, 2021, 9:34pm UTC](https://forum.scrt.network/t/using-rust-differential-privacy-libraries-in-contracts/2645 "2021-02-16T21:34:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![darwinzer0](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/darwinzer0/32/1009_2.png) [@darwinzer0](https://forum.scrt.network/u/darwinzer0)\
**Post date:** [February 16, 2021, 9:34pm UTC](https://forum.scrt.network/t/using-rust-differential-privacy-libraries-in-contracts/2645/1 "2021-02-16T21:34:29Z")

</div>

Say I wanted to create a contract that let users submit some private data and then let other users see differentially private summary statistics, like mean and variance across all the users. Could I just hook in the Rust smartnoise library ( [GitHub - opendifferentialprivacy/smartnoise-core: Differential privacy validator and runtime](https://github.com/opendifferentialprivacy/smartnoise-core#smartnoise-core-rust-documentation) )?

It looks like they use openssl for random number generation: [smartnoise-core/mod.rs at ae521c801e4369f966a90769db1a852707e18a3a · opendifferentialprivacy/smartnoise-core · GitHub](https://github.com/opendifferentialprivacy/smartnoise-core/blob/ae521c801e4369f966a90769db1a852707e18a3a/runtime-rust/src/utilities/mod.rs#L210) . Does that create issues in terms of deterministic execution? I saw in the texas holdem example that ChaCha20 was used to randomly generate the deck. Would I need to update that fill\_bytes function with something similar?

---

<div class="post-metadata">

**Author:** ![darwinzer0](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/darwinzer0/32/1009_2.png) [@darwinzer0](https://forum.scrt.network/u/darwinzer0)\
**Post date:** [February 16, 2021, 10:21pm UTC](https://forum.scrt.network/t/using-rust-differential-privacy-libraries-in-contracts/2645/2 "2021-02-16T22:21:52Z")

</div>

I guess maybe a bigger obstacle is dealing with floating point numbers… there’s no solution to include floating point operations in contracts, yet, correct?

---

<div class="post-metadata">

**Author:** ![darwinzer0](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/darwinzer0/32/1009_2.png) [@darwinzer0](https://forum.scrt.network/u/darwinzer0)\
**Post date:** [February 16, 2021, 10:54pm UTC](https://forum.scrt.network/t/using-rust-differential-privacy-libraries-in-contracts/2645/3 "2021-02-16T22:54:37Z")

</div>

I suppose one workaround is to use fixed-point arithmetic [fixed - Rust](https://docs.rs/fixed/1.6.0/fixed/) . It would be slower but do-able. would mean needing to re-implement a lot more of the smartnoise lib.

---

<div class="post-metadata">

**Author:** ![reuven](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/reuven/32/326_2.png) [@reuven](https://forum.scrt.network/u/reuven)\
**Post date:** [February 17, 2021, 1:18pm UTC](https://forum.scrt.network/t/using-rust-differential-privacy-libraries-in-contracts/2645/4 "2021-02-17T13:18:35Z")

</div>

Your conclusions are correct, I’m afraid. And in fact we do use decimal libraries, and only use pseudo-randomness. Another problem with openssl is that it depends on dynamic loading of system libraries, which is just not a thing in our runtime (Wasm inside SGX), and even if it didn’t use dynamic linking, openssl uses a bunch of system components which are not available to contracts.

---

<div class="post-metadata">

**Author:** ![darwinzer0](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.scrt.network/darwinzer0/32/1009_2.png) [@darwinzer0](https://forum.scrt.network/u/darwinzer0)\
**Post date:** [February 17, 2021, 9:06pm UTC](https://forum.scrt.network/t/using-rust-differential-privacy-libraries-in-contracts/2645/5 "2021-02-17T21:06:50Z")

</div>

great, thanks for the information!
