Fixed bug where intersection was not correctly identified

This commit is contained in:
Michael Zohner 2016-01-20 13:15:27 +01:00
parent 5070bed04a
commit 66c3da71b4
6 changed files with 56 additions and 11 deletions

View File

@ -17,7 +17,7 @@ Orhan.Emde@live.com
Kasimir.Knauf@live.co.uk
KlausPeter.Schaper@hotmail.com
Torben.Spieß@neuf.fr
Czeslaw.Hock@me.com
Günther.Zoller@googlemail.com
Martina.Haimerl@live.com.mx
Mehdi.Freudenberg@fastmail.fm
Mariechen.Seibert@rambler.ru
@ -41,7 +41,7 @@ Helmut.Ebeling@hotmail.es
Richard.Grenz@virginmedia.com
Kathrin.Dengler@charter.net
Jadwiga.Held@orange.fr
Therese.Krone@mac.com
Franz-Xaver.Gentner@gmx.com
Peter-Michael.Petry@hush.com
Mahmut.Arnold@yahoo.com
Siegmund.Preis@laposte.net

View File

@ -23,6 +23,8 @@ typedef uint16_t TABLEID_T;
#define DUMMY_ENTRY_SERVER 0x00
#define DUMMY_ENTRY_CLIENT 0xFF
//#define PRINT_DOMAIN_HASHING
//#define PRINT_LUBY_RACKOFF_PERM
#define USE_LUBY_RACKOFF
typedef struct hashing_state_ctx {
@ -70,7 +72,7 @@ static void init_hashing_state(hs_t* hs, uint32_t nelements, uint32_t inbitlen,
hs->nbins = nbins;
hs->inbitlen = inbitlen;
hs->addrbitlen = min((uint32_t) ceil_log2(nbins), inbitlen);
hs->addrbitlen = min((uint32_t) floor_log2(nbins), inbitlen);
#ifdef USE_LUBY_RACKOFF
hs->outbitlen = hs->inbitlen - hs->addrbitlen+1;
@ -176,7 +178,7 @@ inline void hashElement(uint8_t* element, uint32_t* address, uint8_t* val, hs_t*
}
//cout << endl;
#ifndef TEST_UTILIZATION
*((uint32_t*) val) = R;
*((uint32_t*) val) = (uint32_t) R;
//TODO copy remaining bits
//if(hs->outbytelen >= sizeof(uint32_t))
@ -188,15 +190,16 @@ inline void hashElement(uint8_t* element, uint32_t* address, uint8_t* val, hs_t*
// << ", " << (uint32_t) (val[hs->outbytelen-1] & (BYTE_SELECT_BITS_INV[hs->outbitlen & 0x03]) )<< (dec) << " :";
val[hs->outbytelen-1] &= (BYTE_SELECT_BITS_INV[hs->outbitlen & 0x03]);
/*for(i = 0; i < hs->inbytelen; i++) {
#ifdef PRINT_LUBY_RACKOFF_PERM
for(i = 0; i < hs->inbytelen; i++) {
cout << (hex) << (uint32_t) element[i];
}
cout << ", ";
for(i = 0; i < hs->outbytelen; i++) {
cout << (hex) << (uint32_t) val[i];
}
cout << (dec) << endl;*/
cout << (dec) << endl;
#endif
}
@ -222,7 +225,7 @@ inline void domain_hashing(uint32_t nelements, uint8_t* elements, uint32_t eleby
uint32_t resultbytelen, crypto* crypt) {
uint8_t *eleptr, *resultptr, *hash_buf;
uint32_t i;
uint32_t i, j;
eleptr=elements;
resultptr = result;
@ -233,6 +236,17 @@ inline void domain_hashing(uint32_t nelements, uint8_t* elements, uint32_t eleby
for(i = 0; i < nelements; i++, resultptr+=resultbytelen, eleptr+=elebytelen) {
memcpy(hash_buf, eleptr, elebytelen);
crypt->hash(resultptr, resultbytelen, hash_buf, elebytelen);
#ifdef PRINT_DOMAIN_HASHING
cout << "Hash for element " << i <<" ";
for(j = 0; j < elebytelen; j++) {
cout << (hex) << (uint32_t) eleptr[j] << (dec);
}
cout << ": ";
for(j = 0; j < resultbytelen; j++) {
cout << (hex) << (uint32_t) resultptr[j] << (dec);
}
cout << endl;
#endif
}
free(hash_buf);
}
@ -240,7 +254,7 @@ inline void domain_hashing(uint32_t nelements, uint8_t* elements, uint32_t eleby
inline void domain_hashing(uint32_t nelements, uint8_t** elements, uint32_t* elebytelens, uint8_t* result,
uint32_t resultbytelen, crypto* crypt) {
uint8_t *resultptr;//, *hash_buf;
uint32_t i;
uint32_t i, j;
//eleptr=elements;
resultptr = result;
@ -251,6 +265,17 @@ inline void domain_hashing(uint32_t nelements, uint8_t** elements, uint32_t* ele
for(i = 0; i < nelements; i++, resultptr+=resultbytelen) {
//memcpy(hash_buf, elements[i], elebytelens[i]);
crypt->hash(resultptr, resultbytelen, elements[i], elebytelens[i]);
#ifdef PRINT_DOMAIN_HASHING
cout << "Hash for element " << i <<" ";
for(j = 0; j < elebytelens[i]; j++) {
cout << elements[i][j];
}
cout << ": ";
for(j = 0; j < resultbytelen; j++) {
cout << (hex) << (uint32_t) resultptr[j] << (dec);
}
cout << endl;
#endif
}
//free(hash_buf);
}

View File

@ -59,7 +59,7 @@ int32_t psi_demonstrator(int32_t argc, char** argv) {
cout << "Time for reading elements:\t" << fixed << std::setprecision(2) << getMillies(t_start, t_end)/1000 << " s" << endl;
}
crypto crypto(symsecbits, (uint8_t*) const_seed);
crypto crypto(symsecbits);//, (uint8_t*) const_seed);
switch(protocol) {
case NAIVE:

View File

@ -157,6 +157,25 @@ uint32_t otpsi_client(uint8_t* elements, uint32_t neles, uint32_t nbins, uint32_
gettimeofday(&t_start, NULL);
}
#ifdef PRINT_CLIENT_MAPPING
uint32_t elebytelen = ceil_divide(elebitlen, 8);
uint32_t outbytelen = ceil_divide(outbitlen, 8);
for(uint32_t i = 0, ctr = 0; i < nbins; i++) {
if(nelesinbin[i] > 0) {
cout << "Element " << perm[ctr] << " " ;
for(uint32_t j = 0; j < elebytelen; j++) {
cout << (hex) << (uint32_t) elements[perm[ctr]*elebytelen + j] << (dec);
}
cout << " now maps to ";
for(uint32_t j = 0; j < outbytelen; j++) {
cout << (hex) << (uint32_t) hash_table[i*outbytelen + j] << (dec);
}
cout << endl;
ctr++;
}
}
#endif
#ifdef TIMING
gettimeofday(&t_end, NULL);
cout << "Client: time for cuckoo hashing: " << getMillies(t_start, t_end) << " ms" << endl;

View File

@ -29,6 +29,7 @@ static bool DETAILED_TIMINGS=0;
//#define PRINT_OPRG_MASKS
//#define PRINT_RECEIVED_VALUES
//#define PRINT_CRF_EVAL
//#define PRINT_CLIENT_MAPPING
//#define ENABLE_STASH //TODO: enabling stash introduces errors. fix!
struct mask_rcv_ctx {

View File

@ -94,7 +94,7 @@ static void create_result_from_matches_var_bitlen(uint8_t*** result, uint32_t**
std::sort(matches, matches+intersect_size);
for(i = 0; i < intersect_size; i++) {
cout << "matches[" << i << "]: " << matches[i] << endl;
//cout << "matches[" << i << "]: " << matches[i] << endl;
(*resbytelens)[i] = inbytelens[matches[i]];
(*result)[i] = (uint8_t*) malloc((*resbytelens)[i]);
memcpy((*result)[i], inputs[matches[i]], (*resbytelens)[i]);