Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass rand_hack to build for no_std #55

Closed
wants to merge 1 commit into from

Conversation

sugargoat
Copy link

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

  • Adds witness_scalar_rng to SigningTranscript
  • Adds sign_rng to SecretKey
  • Modifies non-rng methods to call the _rng method with super::rand_hack()

@burdges
Copy link
Collaborator

burdges commented Jul 2, 2020

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

@sugargoat
Copy link
Author

@burdges - Thank you! I will take a look

@sugargoat
Copy link
Author

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.

mobilecoinfoundation/mobilecoin#368

@sugargoat
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants