Unverified Commit c3e05f2a authored by svetaro's avatar svetaro

SKALE-1512-add-DKG-to-SGX merge

parent bb63afeb
#include <stdio.h>
#include <stdlib.h>
#include <../tgmp-build/include/sgx_tgmp.h>
#include "random.h"
/*Seeds the random state with information from /dev/random
*This may take time, but it's needed to ensure true randomness*/
void random_seeding(gmp_randstate_t r_state)
{
//Open the random device for reading
FILE* ran = fopen(RANDOM_DEVICE, "r");
//input variables
char i1, i2, i3, i4;
//Read 4 bytes, cause that's the most we can put in an unsigned long int
i1 = fgetc(ran);
if(i1 == EOF)
goto end;
i2 = fgetc(ran);
if(i2 == EOF)
goto end;
i3 = fgetc(ran);
if(i3 == EOF)
goto end;
i4 = fgetc(ran);
if(i4 == EOF)
goto end;
//abs() returns long (signed long), therefor there must be two, since DO NOT want to loose any randomness
gmp_randseed_ui(r_state, (unsigned long int)abs(i1)* (unsigned long int)abs(i2*i3*i4));
//Define end
end:
//Close file resources
fclose(ran);
}
/*Seeds the random state with information from /dev/random
*This may take time, but it's needed to ensure true randomness*/
void random_seeding(gmp_randstate_t r_state);
/*Operating system dependent random device, please use true random
*Linux has /dev/random as true RNG and /dev/urandom as pseudo random device
*Note: /dev/random may be slow, whereas /dev/urandom is not as secure*/
#define RANDOM_DEVICE "/dev/urandom"
/*Time spent reading from random device is not included in benchmark and other timings.
*To see difference between real execution time and execution time use Unix "time" command*/
...@@ -30,6 +30,10 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ...@@ -30,6 +30,10 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <libff/algebra/fields/fp.hpp>
#include <dkg/dkg.h>
#include <jsonrpccpp/server/connectors/httpserver.h> #include <jsonrpccpp/server/connectors/httpserver.h>
...@@ -37,6 +41,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -37,6 +41,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp> #include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
#include <libff/algebra/exponentiation/exponentiation.hpp> #include <libff/algebra/exponentiation/exponentiation.hpp>
#include <libff/algebra/fields/fp.hpp>
#include <dkg/dkg.h>
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
#include "create_enclave.h" #include "create_enclave.h"
#include "secure_enclave_u.h" #include "secure_enclave_u.h"
...@@ -56,9 +64,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -56,9 +64,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sgx_tcrypto.h> #include <sgx_tcrypto.h>
#include <dkg/dkg.h>
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp" #include "catch.hpp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment