-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtrans.c
67 lines (55 loc) · 1.11 KB
/
trans.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* trans.c
*
* Created on: 13.03.2012
* Author: michaelbrenner
*/
#include "trans.h"
void trans_int2adr(int i,_fhe_int *adr,fhe_pk_t pk)
{
for(int a=0,mask=1;a<ADR_BITS;a++,mask*=2)
{
if(i&mask)
fhe_int_encrypt(&adr[a],pk,1);
else
fhe_int_encrypt(&adr[a],pk,0);
(&adr[a])->noise=1;
}
}
void trans_adr2int(int i,_fhe_int *adr,fhe_pk_t pk)
{
}
void trans_int2data(int i,_fhe_int *data,fhe_pk_t pk)
{
for(int a=0,mask=1;a<DATA_BITS;a++,mask*=2)
{
if(i&mask)
fhe_int_encrypt(&data[a],pk,1);
else
fhe_int_encrypt(&data[a],pk,0);
(&data[a])->noise=1;
}
}
void trans_int2vec(int i,_fhe_int *data,int size,fhe_pk_t pk)
{
for(int a=0,mask=1;a<size;a++,mask*=2)
{
if(i&mask)
fhe_int_encrypt(&data[a],pk,1);
else
fhe_int_encrypt(&data[a],pk,0);
(&data[a])->noise=1;
}
}
void trans_data2int(int i,_fhe_int *data,fhe_pk_t pk)
{
}
void trans_int2mem(int i,int memaddr,fhe_pk_t pk)
{
trans_int2vec(i,&access_array[WORD_SIZE*memaddr],WORD_SIZE,pk);
}
void trans_print(_fhe_int *data,int len,fhe_sk_t sk)
{
for(int i=0;i<len;i++)
printf("%d ",fhe_decrypt((&data[i])->mpz,sk));
}