axelarnetwork / tofn

A threshold cryptography library in Rust
Apache License 2.0
107 stars 22 forks source link

deterministic generation of ephemeral scalars in GG20 #189

Open ggutoski opened 2 years ago

ggutoski commented 2 years ago

Currently we just use the OSs rng: https://github.com/axelarnetwork/tofn/blob/6edd85215cc0ab0f881c92b1381cd85360b7dbd1/src/gg20/sign/r1.rs#L53-L54

_Originally posted by @ggutoski in https://github.com/axelarnetwork/tofn/pull/185#discussion_r729856747_

tarcieri commented 2 years ago

I believe you already depend on the chacha20 crate as a dependency (maybe just in tofnd?), so FYI, you can use this:

https://docs.rs/chacha20/0.8.1/chacha20/struct.ChaCha20Rng.html

Edit: ah nevermind, seems you already depend on rand_chacha here:

https://github.com/axelarnetwork/tofn/blob/a59733f/Cargo.toml#L14

That works too. I believe they're the same speed at this point.

ggutoski commented 2 years ago

Yep. We already have a helper function for just this purpose soon to be merged in #185 https://github.com/axelarnetwork/tofn/blob/869556ba94d12b232c645e808d1562fed2bef054/src/crypto_tools/rng.rs#L66