mirror of
https://github.com/encryptogroup/PSI.git
synced 2024-03-22 13:30:44 +08:00
Merge pull request #3 from lenerd/lenerd/fix-glibc-conflict
Fix multiple bugs
This commit is contained in:
commit
e5057094ec
|
@ -155,6 +155,7 @@ void *gen_cuckoo_entries(void *ctx_void) {
|
||||||
for(i = ctx->startpos; i < ctx->endpos; i++, eleptr+=inbytelen) {
|
for(i = ctx->startpos; i < ctx->endpos; i++, eleptr+=inbytelen) {
|
||||||
gen_cuckoo_entry(eleptr, ctx->cuckoo_entries + i, hs, i);
|
gen_cuckoo_entry(eleptr, ctx->cuckoo_entries + i, hs, i);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,7 @@ void *gen_entries(void *ctx_tmp) {
|
||||||
}
|
}
|
||||||
free(tmpbuf);
|
free(tmpbuf);
|
||||||
free(address);
|
free(address);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void insert_element(sht_ctx* table, uint8_t* element, uint32_t* address, uint8_t* tmpbuf, hs_t* hs) {
|
inline void insert_element(sht_ctx* table, uint8_t* element, uint32_t* address, uint8_t* tmpbuf, hs_t* hs) {
|
||||||
|
|
|
@ -587,6 +587,7 @@ void *otpsi_query_hash_table(void* ctx_tmp) {//GHashTable *map, uint8_t* element
|
||||||
|
|
||||||
free(matches);
|
free(matches);
|
||||||
//return size_intersect;
|
//return size_intersect;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO if this works correctly, combine with other find intersection methods and outsource to hashing_util.h
|
//TODO if this works correctly, combine with other find intersection methods and outsource to hashing_util.h
|
||||||
|
@ -717,6 +718,7 @@ void print_bin_content(uint8_t* hash_table, uint32_t nbins, uint32_t elebytelen,
|
||||||
void *receive_masks(void *ctx_tmp) {
|
void *receive_masks(void *ctx_tmp) {
|
||||||
mask_rcv_ctx* ctx = (mask_rcv_ctx*) ctx_tmp;
|
mask_rcv_ctx* ctx = (mask_rcv_ctx*) ctx_tmp;
|
||||||
ctx->sock->Receive(ctx->rcv_buf, ctx->maskbytelen * ctx->nmasks);
|
ctx->sock->Receive(ctx->rcv_buf, ctx->maskbytelen * ctx->nmasks);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_stash_size(uint32_t neles) {
|
uint32_t get_stash_size(uint32_t neles) {
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#define DEFAULT_BITSIZE 128
|
#define DEFAULT_BITSIZE 128
|
||||||
|
|
||||||
|
typedef int BOOL; // as in Miracl
|
||||||
|
|
||||||
static const uint8_t REVERSE_NIBBLE_ORDER[16] =
|
static const uint8_t REVERSE_NIBBLE_ORDER[16] =
|
||||||
{0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE, 0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF};
|
{0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE, 0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF};
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
#include "ecc-pk-crypto.h"
|
#include "ecc-pk-crypto.h"
|
||||||
|
|
||||||
|
#include "../../externals/miracl_lib/ecn.h"
|
||||||
|
#include "../../externals/miracl_lib/big.h"
|
||||||
|
#include "../../externals/miracl_lib/ec2.h"
|
||||||
|
|
||||||
|
|
||||||
char *ecx163 = (char *) "2fe13c0537bbc11acaa07d793de4e6d5e5c94eee8";
|
char *ecx163 = (char *) "2fe13c0537bbc11acaa07d793de4e6d5e5c94eee8";
|
||||||
char *ecy163 = (char *) "289070fb05d38ff58321f2e800536d538ccdaa3d9";
|
char *ecy163 = (char *) "289070fb05d38ff58321f2e800536d538ccdaa3d9";
|
||||||
|
@ -203,6 +207,13 @@ void ecc_fe::sample_fe_from_bytes(uint8_t* buf, uint32_t bytelen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ecc_fe::print() {
|
||||||
|
cout << (*val) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ecc_fe::init() {
|
||||||
|
val = new EC2();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ecc_num::ecc_num(ecc_field* fld) {
|
ecc_num::ecc_num(ecc_field* fld) {
|
||||||
|
@ -245,20 +256,34 @@ void ecc_num::export_to_bytes(uint8_t* buf, uint32_t field_size_bytes) {
|
||||||
big_to_bytes ((int32_t) field_size_bytes, val->getbig(), (char*) buf, true);
|
big_to_bytes ((int32_t) field_size_bytes, val->getbig(), (char*) buf, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ecc_num::print() {
|
||||||
|
cout << (*val) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ecc_brickexp methods
|
// ecc_brickexp methods
|
||||||
|
struct ecc_brickexp::ecc_brickexp_impl {
|
||||||
|
ebrick2 br;
|
||||||
|
};
|
||||||
|
|
||||||
ecc_brickexp::ecc_brickexp(fe* point, ecc_fparams* fparams) {
|
ecc_brickexp::ecc_brickexp(fe* point, ecc_fparams* fparams) {
|
||||||
Big x, y;
|
Big x, y;
|
||||||
fe2ec2(point)->getxy(x, y);
|
fe2ec2(point)->getxy(x, y);
|
||||||
ebrick2_init(&br, x.getbig(), y.getbig(), fparams->BA->getbig(), fparams->BB->getbig(),
|
impl = std::make_unique<ecc_brickexp_impl>();
|
||||||
fparams->m, fparams->a, fparams->b, fparams->c, 8, fparams->secparam);
|
ebrick2_init(&impl->br, x.getbig(), y.getbig(), fparams->BA->getbig(),
|
||||||
|
fparams->BB->getbig(), fparams->m, fparams->a, fparams->b,
|
||||||
|
fparams->c, 8, fparams->secparam);
|
||||||
|
}
|
||||||
|
|
||||||
|
ecc_brickexp::~ecc_brickexp() {
|
||||||
|
ebrick2_end(&impl->br);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ecc_brickexp::pow(fe* result, num* e)
|
void ecc_brickexp::pow(fe* result, num* e)
|
||||||
{
|
{
|
||||||
Big xtmp, ytmp;
|
Big xtmp, ytmp;
|
||||||
mul2_brick(&br, num2Big(e)->getbig(), xtmp.getbig(), ytmp.getbig());
|
mul2_brick(&impl->br, num2Big(e)->getbig(), xtmp.getbig(), ytmp.getbig());
|
||||||
*fe2ec2(result) = EC2(xtmp, ytmp);
|
*fe2ec2(result) = EC2(xtmp, ytmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
#define ECC_PK_CRYPTO_H_
|
#define ECC_PK_CRYPTO_H_
|
||||||
|
|
||||||
#include "pk-crypto.h"
|
#include "pk-crypto.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "../../externals/miracl_lib/ecn.h"
|
// forward declarations
|
||||||
#include "../../externals/miracl_lib/big.h"
|
class Big;
|
||||||
#include "../../externals/miracl_lib/ec2.h"
|
class EC2;
|
||||||
|
|
||||||
|
|
||||||
#define fe2ec2(fieldele) (((ecc_fe*) (fieldele))->get_val())
|
#define fe2ec2(fieldele) (((ecc_fe*) (fieldele))->get_val())
|
||||||
|
@ -94,7 +95,7 @@ public:
|
||||||
void export_to_bytes(uint8_t* buf, uint32_t field_size_bytes);
|
void export_to_bytes(uint8_t* buf, uint32_t field_size_bytes);
|
||||||
void import_from_bytes(uint8_t* buf, uint32_t field_size_bytes);
|
void import_from_bytes(uint8_t* buf, uint32_t field_size_bytes);
|
||||||
void set_rnd(uint32_t bits);
|
void set_rnd(uint32_t bits);
|
||||||
void print() {cout << (*val) << endl;};
|
void print();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Big* val;
|
Big* val;
|
||||||
|
@ -118,11 +119,11 @@ public:
|
||||||
void import_from_bytes(uint8_t* buf);
|
void import_from_bytes(uint8_t* buf);
|
||||||
void sample_fe_from_bytes(uint8_t* buf, uint32_t bytelen);
|
void sample_fe_from_bytes(uint8_t* buf, uint32_t bytelen);
|
||||||
|
|
||||||
void print() {cout << (*val) << endl;};
|
void print();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init() {val = new EC2();};
|
void init();
|
||||||
EC2* val;
|
EC2* val;
|
||||||
ecc_field* field;
|
ecc_field* field;
|
||||||
};
|
};
|
||||||
|
@ -130,11 +131,12 @@ private:
|
||||||
class ecc_brickexp : public brickexp {
|
class ecc_brickexp : public brickexp {
|
||||||
public:
|
public:
|
||||||
ecc_brickexp(fe* point, ecc_fparams* fparams);
|
ecc_brickexp(fe* point, ecc_fparams* fparams);
|
||||||
~ecc_brickexp() {ebrick2_end(&br);}
|
~ecc_brickexp();
|
||||||
|
|
||||||
void pow(fe* res, num* e);
|
void pow(fe* res, num* e);
|
||||||
private:
|
private:
|
||||||
ebrick2 br;
|
struct ecc_brickexp_impl; // used to hide MIRACL's ebrick2 type in the implementation
|
||||||
|
std::unique_ptr<ecc_brickexp_impl> impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
void point_to_byte(uint8_t* pBufIdx, uint32_t field_size_bytes, EC2* to_export);
|
void point_to_byte(uint8_t* pBufIdx, uint32_t field_size_bytes, EC2* to_export);
|
||||||
|
|
|
@ -18,7 +18,7 @@ class brickexp;
|
||||||
class pk_crypto {
|
class pk_crypto {
|
||||||
public:
|
public:
|
||||||
pk_crypto(seclvl sp, uint8_t* seed){};
|
pk_crypto(seclvl sp, uint8_t* seed){};
|
||||||
~pk_crypto(){};
|
virtual ~pk_crypto(){};
|
||||||
virtual num* get_num() = 0;
|
virtual num* get_num() = 0;
|
||||||
virtual num* get_rnd_num(uint32_t bitlen=0) = 0;
|
virtual num* get_rnd_num(uint32_t bitlen=0) = 0;
|
||||||
virtual fe* get_fe() = 0;
|
virtual fe* get_fe() = 0;
|
||||||
|
@ -45,7 +45,7 @@ protected:
|
||||||
class num {
|
class num {
|
||||||
public:
|
public:
|
||||||
num(){};
|
num(){};
|
||||||
~num(){};
|
virtual ~num(){};
|
||||||
virtual void set(num* src) = 0;
|
virtual void set(num* src) = 0;
|
||||||
virtual void set_si(int32_t src) = 0;
|
virtual void set_si(int32_t src) = 0;
|
||||||
virtual void set_add(num* a, num* b) = 0;
|
virtual void set_add(num* a, num* b) = 0;
|
||||||
|
@ -60,7 +60,7 @@ public:
|
||||||
class fe {
|
class fe {
|
||||||
public:
|
public:
|
||||||
fe(){};
|
fe(){};
|
||||||
~fe(){};
|
virtual ~fe(){};
|
||||||
virtual void set(fe* src) = 0;
|
virtual void set(fe* src) = 0;
|
||||||
virtual void set_mul(fe* a, fe* b) = 0;
|
virtual void set_mul(fe* a, fe* b) = 0;
|
||||||
virtual void set_pow(fe* b, num* e) = 0;
|
virtual void set_pow(fe* b, num* e) = 0;
|
||||||
|
@ -78,7 +78,7 @@ protected:
|
||||||
class brickexp {
|
class brickexp {
|
||||||
public:
|
public:
|
||||||
brickexp(){};
|
brickexp(){};
|
||||||
~brickexp(){};
|
virtual ~brickexp(){};
|
||||||
|
|
||||||
virtual void pow(fe* result, num* e) = 0;
|
virtual void pow(fe* result, num* e) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ class BaseOT
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BaseOT(crypto* crypt, field_type ftype){m_cCrypto = crypt; m_cPKCrypto = crypt->gen_field(ftype); };
|
BaseOT(crypto* crypt, field_type ftype){m_cCrypto = crypt; m_cPKCrypto = crypt->gen_field(ftype); };
|
||||||
~BaseOT(){delete m_cPKCrypto; };
|
virtual ~BaseOT(){delete m_cPKCrypto; };
|
||||||
|
|
||||||
virtual void Sender(uint32_t nSndVals, uint32_t nOTs, CSocket* sock, uint8_t* ret) = 0;
|
virtual void Sender(uint32_t nSndVals, uint32_t nOTs, CSocket* sock, uint8_t* ret) = 0;
|
||||||
virtual void Receiver(uint32_t nSndVals, uint32_t uint32_t, CBitVector& choices, CSocket* sock, uint8_t* ret) = 0;
|
virtual void Receiver(uint32_t nSndVals, uint32_t uint32_t, CBitVector& choices, CSocket* sock, uint8_t* ret) = 0;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "kk-ot-extension.h"
|
#include "kk-ot-extension.h"
|
||||||
|
|
||||||
|
#define TRUE 1 // as in Miracl
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ---------------------------------- OT Extension Sender Part --------------------------------------
|
* ---------------------------------- OT Extension Sender Part --------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -81,7 +81,7 @@ void NaorPinkas::Receiver(uint32_t nSndVals, uint32_t nOTs, CBitVector& choices,
|
||||||
delete bc;//BrickDelete(&bc);
|
delete bc;//BrickDelete(&bc);
|
||||||
delete bg;//BrickDelete(&bg);
|
delete bg;//BrickDelete(&bg);
|
||||||
|
|
||||||
delete [] pBuf;
|
free(pBuf);
|
||||||
free(PK_sigma);
|
free(PK_sigma);
|
||||||
free(pDec);
|
free(pDec);
|
||||||
free(pC);
|
free(pC);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user