/* * Verification program for Chaum's scheme * @author kms7341@rit.edu */ // note on array lengths: chaum's scheme can operate at any scale // we've chosen size = 8 since that is reasonably large without // imposing undue costs of size and time int deSignInt(int bit, int invKey) { return bit ^ invKey; } // only need deSign for first two portions int checkSerial(int q, int qSigned, int invKey) { int q2; q2 = deSignInt(qSigned, invKey); if (q2 == q) return 1; return 0; } //next set of conditions: needs designArray void deSignArray(int bits[], int invKey, int size) { int i = 0; int bit = 0; int ans = 0; while (i < size) { bit = bits[i]; ans = deSignInt(bit, invKey); bits[i] = ans; i++; } } int checkArray(int signedBits[], int originalBits[], int invKey, int size) { deSignArray(signedBits, invKey, size); int i = 0; int bit1 = 0; int bit2 = 0; int flag = 1; while (i < size) { bit1 = signedBits[i]; bit2 = originalBits[i]; if (bit1 != bit2) { flag = 0; } i++; } return flag; } int checkTuple(int layer[], int q, int topDoll[], int botDoll[], int v, int k[], int r, int i[], int j[], int w, int key, int size) { int flag = 1; int val = 0; val = checkArray(k, layer, key, size); flag = flag & val; val = checkSerial(q, r, key); flag = flag & val; val = checkArray(i, topDoll, key, size); flag = flag & val; val = checkArray(j, botDoll, key, size); flag = flag & val; val = checkSerial(v, w, key); flag = flag & val; return flag; } int certifyReceipt(int topFlag, int layer[], int q, int topDoll[], int botDoll[], int v, int k[], int r, int i[], int j[], int w, int size, // size is constant for all arrays int topSerialKey, int botSerialKey, int topTupleKey, int botTupleKey) { int flag = 1; int val = 0; int serKey = 0; int tupKey = 0; if (topFlag == 1) { serKey = topSerialKey; tupKey = topTupleKey; } else { serKey = botSerialKey; tupKey = botTupleKey; } val = checkSerial(q, v, serKey); flag = flag & val; val = checkTuple(layer, q, topDoll, botDoll, v, k, r, i, j, w, tupKey, size); flag = flag & val; return flag; } // arbitrary values int qVals[8] = {15, 5463, 12, 75, 231, 1431, 735, 134}; int processedQVals[8] = {15, 5463, 12, 75, 231, 1431, 735, 134}; int main(void) { int qsigned, ser; int q = 15687; int key = 4231; qsigned = deSignInt(q, key); // xor makes algo same both ways ser = checkSerial(q, qsigned, key); deSignArray(processedQVals, key, 8); int arr = checkArray(processedQVals, qVals, key, 8); return ser; }