#include "display.c"
#include "chacha20.c"
#define QUBITS_MAX 11
+double HIDDEN_VARIABLE;
typedef struct
{
double qansel_rand()
{
- static uint64_t hiddenVariable = 0;
static uint32_t blockNumber = 0;
- if (hiddenVariable == 0)
- {
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- hiddenVariable = (uint64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
- }
uint8_t key[32];
uint8_t nonce[12];
uint64_t tmpVariable;
for (uint8_t i = 0; i < 32; i++)
{
- if (i % 8 == 0) tmpVariable = hiddenVariable;
+ if (i % 8 == 0) memcpy(&tmpVariable, &HIDDEN_VARIABLE, sizeof(uint64_t));
key[i] = tmpVariable & 0xFF;
- tmpVariable >> 8;
-
+ tmpVariable = tmpVariable >> 8;
}
for (uint8_t i = 0; i < 12; i++)
{
void main(int argc, char** argv)
{
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ HIDDEN_VARIABLE = (double)((uint64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec);
char** lines = malloc(0);
uint32_t* lineIDs = malloc(0);
char* text = malloc(0);
uint8_t bitCount = 0xFF;
QInstr* instr = malloc(0);
uint32_t instrLen = 0;
-
+ uint8_t doDisplay = 0;
uint8_t errFound = 0;
for (uint32_t i = 0; i < linesLen; i++)
{
instr[instrLen].q0 = q0;
instr[instrLen++].q1 = q1;
}
+ else if (strcmp(lines[i], "display") == 0)
+ {
+ if (doDisplay)
+ {
+ fprintf(stderr, "QAnsel: Display re-initialized");
+ errFound = 1;
+ break;
+ }
+ doDisplay = 1;
+ }
else if (strcmp(lines[i], "print q") == 0)
{
if (qubitCount == 0xFF)
{
if (strcmp(argv[1], "-d") == 0)
{
- qansel_run(qubitCount, bitCount, instr, instrLen, 1);
+ doDisplay = 1;
}
}
- else
+ else if (argc == 3)
{
- qansel_run(qubitCount, bitCount, instr, instrLen, 0);
+ if (strcmp(argv[1], "-h") == 0)
+ {
+ HIDDEN_VARIABLE = atof(argv[2]);
+ }
}
+ else if (argv == 4)
+ {
+ if (strcmp(argv[1], "-d") == 0)
+ {
+ doDisplay = 1;
+ }
+ else if (strcmp(argv[3], "-d") == 0)
+ {
+ doDisplay = 1;
+ }
+ if (strcmp(argv[1], "-h") == 0)
+ {
+ HIDDEN_VARIABLE = atof(argv[2]);
+ }
+ else if (strcmp(argv[2], "-h") == 0)
+ {
+ HIDDEN_VARIABLE = atof(argv[3]);
+ }
+ }
+
+ qansel_run(qubitCount, bitCount, instr, instrLen, doDisplay);
free(instr);
free(lineIDs);
}