int main(int argc, const char **argv) { const char *method = 0; const char *print = 0; mtw_seed(0); if (argc < 2) help(); character::init(); optimize::init(); matrix::data *mtx = matrix::load(argv[argc-1]); if (!mtx) { std::cerr << "Matrix failed to load. Aborting." << std::endl; return -1; } network::data *net = network::alloc(mtx); const int count = 600; rounds(net, count, 0); rounds(net, count, 1); return 0; }
void *out_bytes(int verbose) { int i = 0; struct timespec wc_bgn, tr_bgn, wc_end, tr_end, drift; u08b_t buffer[SIZE]; while(1) { if (verbose && (BYTES % 0x400 == 0)) fprintf(stderr, "bytes: %12d\n", BYTES); for(i = 0; i < SIZE; i++) { int byte = 0, k; for(k = 0; k < 8; k++) { clock_gettime(CLOCK_MONOTONIC, &wc_bgn); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tr_bgn); rounds(128); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tr_end); clock_gettime(CLOCK_MONOTONIC, &wc_end); drift = diff(diff(tr_bgn, tr_end), diff(wc_bgn, wc_end)); byte = (byte<<1); int n = drift.tv_nsec; while (n) { byte ^= n&1; n >>= 1; } } buffer[i] = byte; } BYTES += SIZE; fwrite(buffer, 1, SIZE, stdout); } }
int main(){ int x(0), k(0); scanf("%d %d", &x, &k); std::vector<bool> rounds(x + 1, 0); while(k--){ int roundType; scanf("%d\nn", &roundType); if(roundType == 1){ int idA, idB; scanf("%d %d", &idA, &idB); rounds[idA] = rounds[idB] = 1; } else if(roundType == 2){ int idA; scanf("%d", &idA); rounds[idA] = 1; } } int maxRounds(0); for(int k = 1; k < x; k++){if(!rounds[k]){++maxRounds;}} int currentIndex(1), minRounds(0); while(currentIndex < x){ if(rounds[currentIndex] == 1){++currentIndex; continue;} ++minRounds; ++currentIndex;if(rounds[currentIndex] == 0){++currentIndex;} } printf("%d %d\n", minRounds, maxRounds); return 0; }
void diy::RegularPartners:: fill_steps() { if (contiguous_) { std::vector<int> cur_steps(divisions().size(), 1); for (size_t r = 0; r < rounds(); ++r) { steps_.push_back(cur_steps[kvs_[r].dim]); cur_steps[kvs_[r].dim] *= kvs_[r].size; } } else { std::vector<int> cur_steps(divisions().begin(), divisions().end()); for (size_t r = 0; r < rounds(); ++r) { cur_steps[kvs_[r].dim] /= kvs_[r].size; steps_.push_back(cur_steps[kvs_[r].dim]); } } }
static PyObject *trivium_rounds(PyObject *self, PyObject *args) { u8 iv[10], key[10]; u16 num_rounds; PyObject *iv_seq, *key_seq; if (!PyArg_ParseTuple(args, "OOH", &iv_seq, &key_seq, &num_rounds)) return NULL; iv_seq = PySequence_Fast(iv_seq, "IV must be iterable."); if (!iv_seq) return NULL; if (80 != PySequence_Fast_GET_SIZE(iv_seq)) { Py_DECREF(iv_seq); return NULL; } if (seq2array(iv_seq, iv)) { Py_DECREF(iv_seq); return NULL; } Py_DECREF(iv_seq); key_seq = PySequence_Fast(key_seq, "KEY must be iterable."); if (!key_seq) return NULL; if (80 != PySequence_Fast_GET_SIZE(key_seq)) { Py_DECREF(key_seq); return NULL; } if (seq2array(key_seq, key)) { Py_DECREF(key_seq); return NULL; } Py_DECREF(key_seq); return Py_BuildValue("i", rounds(iv, key, num_rounds)); }
void ubiimplement(void)//function to implement the ubi chaining mode { int originalsize,i1,mini,w,j,tempe[100000],tempe1[128],i,tempe2[127],maxaddvalue,tempe3[128],tweakbyte1[16]; originalsize=sizeofplaintext; while((sizeofplaintext%32)!=0)//making the size of plaintext a multiple of 32 bytes { plaintext[sizeofplaintext]=0; sizeofplaintext=sizeofplaintext+1; } bytestowords(plaintext,0,sizeofplaintext);//converting from bytes to 64 bit words for use in threefish for(i1=1;i1<=(sizeofplaintext/32);i1++)//the rounds in ubi chaining mode { mini=originalsize;//implementing the generation of tweak value for each round if(mini<(i*32)) mini=(i*32); w=0; for(j=mini;j!=0;j=(j/2))//converting to bits { tempe[w]=(j%2); w=w+1; } for(i=0,j=127;i<128;i++,j--)//inverting input tweak { tempe1[i]=tweak[j]; } addbyte(tempe1,tempe,128,w);//performing bit addition if(w>128) maxaddvalue=w; else maxaddvalue=128; if((i1-1)==0) { for(i=0;i<126;i++)//finding 2^126 { tempe2[i]=0; } tempe2[i]=1; addbyte(addvalue,tempe2,maxaddvalue,127);//adding bits if(maxaddvalue<127)//updating max array size maxaddvalue=127; } if(i1==(sizeofplaintext-1)) { for(i=0;i<127;i++)//finding 2^127 { tempe3[i]=0; } tempe3[i]=1; addbyte(addvalue,tempe3,maxaddvalue,128);//adding bits if(maxaddvalue<128)//updating max array size maxaddvalue=128; } changebyte(addvalue,maxaddvalue);//changing to byte format from bits for(i=0,j=15;i<16;i++,j--)//changing to lsb first mode { tweakbyte1[i]=tweakbyte[j]; } bytestowords(blockcipherkey,1,32);//changing from bytes to 64-bit words for threefish bytestowords(tweakbyte1,2,16); keyschedule();//generating key schedule rounds();//performing rounds in threefish for(i=0;i<32;i++)//generating block cipher key for next ubi round { blockcipherkey[i]=ciphertext[i]; if(move1<originalsize) { entireciphertext[move1]=ciphertext[i]; move1=move1+1; } } } }
void GameStorage::decreaseRounds() { setRounds(opponentUniqueId(), rounds(opponentUniqueId()) - 1); }