w3f / schnorrkel

Schnorr VRFs and signatures on the Ristretto group
BSD 3-Clause "New" or "Revised" License
310 stars 93 forks source link

Bypass rand_hack to build for no_std #55

Closed sugargoat closed 4 years ago

sugargoat commented 4 years ago

Motivation

I am using schnorrkel signatures in a no_std environment, however the rand_hack requirement for signing via witness_scalar was causing collisions via rand_core. This PR introduces bypasses to calls to rand_hack and allows the caller to provide an rng. For example, with default-features = false, the following builds and runs in the no_std environment of SGX:

let sig: Signature =
                keypair.sign_rng(ctx.bytes(&fingerprint), &mut csprng);

This approach may also address related no_std issue #31.

In this PR

burdges commented 4 years ago

Is there an issue with using the attach_rng function instead? It should achieve this..

sugargoat commented 4 years ago

@burdges - Thank you! I will take a look

sugargoat commented 4 years ago

Hi @burdges, I attempted to update our no_std schnorrkel usage to use attach_rng as opposed to the changes in this PR, but it does not build for no_std. Digging in now to see where std is coming in.

https://github.com/mobilecoinofficial/mobilecoin/pull/368

sugargoat commented 4 years ago

Nevermind! The issue was that I didn't have default-features = false on the new merlin dependency. Sorry about that, and thank you for the help!