void putch_s(uint8_t c) { uint8_t msk,i; sftbit(0); msk = 1; for(i=0; i < 8; i++) { sftbit(c & msk); msk <<= 1; } sftbit(1); sftbit(1); _delay_ms(5); }
/* * computes the loop of the algorithm. * for k=0 to h-1 * e=0 * for i=kw to kw+w-1 * if the bitIndex bit in ci is set: * calculate e += 2^(i-kw) * result = result *preComp[k][e] */ epoint* computeLoop(miracl* mip, big* exponentiations, int w, int h, epoint*** preComp, epoint* result, int bitIndex, int n, int field){ int e = 0, k, i, twoPow; big temp = mirvar(mip, 0); for (k=0; k<h; k++){ for (i=k*w; i<(k * w + w); i++){ if (i < n){ copy(exponentiations[i], temp); //check if the bit in bitIndex is set. //shift the big number bitIndex times sftbit(mip, temp, bitIndex*-1, temp); //check if the shifted big is divisible by two. if not - the first bit is set. if (subdivisible(mip, temp, 2) == 0){ twoPow = pow((double)2, i-k*w); e += twoPow; } } } //multiply operation depends on the field if (field == 1) ecurve_add(mip, preComp[k][e], result); else ecurve2_add(mip, preComp[k][e], result); e = 0; } mirkill(temp); return result; }
Big operator<<(const Big& b, int i) {Big ms; sftbit(b.fn,i,ms.fn); return ms;}