Unverified Commit c3e05f2a authored by svetaro's avatar svetaro

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

parent bb63afeb
......@@ -67,4 +67,4 @@ void xor_encrypt(char* key, char* message, char* cypher){
for (int i = 0; i < 32; i++){
cypher[i] = message[i] ^ key[i];
}
}
\ No newline at end of file
}
#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
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>
......@@ -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/exponentiation/exponentiation.hpp>
#include <libff/algebra/fields/fp.hpp>
#include <dkg/dkg.h>
#include "sgxwallet_common.h"
#include "create_enclave.h"
#include "secure_enclave_u.h"
......@@ -56,9 +64,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#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
#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