Skip to content

Commit

Permalink
[Zcash] Use libsodium's PRNG.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebfull committed Jul 15, 2016
1 parent dcb78b2 commit a6b0ad0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/algebra/fields/bigint.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define BIGINT_TCC_
#include <cassert>
#include <cstring>
#include "sodium.h"

namespace libsnark {

Expand Down Expand Up @@ -166,10 +167,8 @@ template<mp_size_t n>
bigint<n>& bigint<n>::randomize()
{
assert(GMP_NUMB_BITS == sizeof(mp_limb_t) * 8);
FILE *fp = fopen("/dev/urandom", "r"); //TODO Remove hard-coded use of /dev/urandom.
size_t bytes_read = fread(this->data, 1, sizeof(mp_limb_t) * n, fp);
assert(bytes_read == sizeof(mp_limb_t) * n);
fclose(fp);

randombytes_buf(this->data, sizeof(mp_limb_t) * n);

return (*this);
}
Expand Down

0 comments on commit a6b0ad0

Please sign in to comment.