Lab6
Lab6
𝐹 = {𝑓0 , 𝑓1 , 𝑓2 , 𝑓3 , 𝑓4 } = {77,13,29,42,51}
A user wants to download the third files (𝑓2 = 29) from the server while keeping his download
private.
Suppose the database is distributed across two non-colluding servers, 𝑆1 and 𝑆2 . The user
queries both servers independently to retrieve 𝑓2 .
a) Design a two-server PIR protocol using random splitting of queries
Solution.
𝑞 = (𝑞1 + 𝑞2 ) 𝑚𝑜𝑑 𝑝
For each 𝑞1 [𝑖] index (from 0 to 4), the element is chosen randomly modulo 𝑝, and 𝑞2 is
computed as:
𝑟1 = ∑ 𝑞1 [𝑖] × 𝑓𝑖
𝑖=0
- Server 𝑆2 computes:
1
4
𝑟2 = ∑ 𝑞2 [𝑖] × 𝑓𝑖
𝑖=0
𝑟2 = (23 ⋅ 77) + (46 ⋅ 13) + (68 ⋅ 29) + (78 ⋅ 42) + (57 ⋅ 51)
= 1771 + 598 + 1972 + 3276 + 2907 = 10524
That is
4
Hence
c) Explain why the protocol guarantees query privacy when 𝑆1 and 𝑆2 do not collude.
2
The PIR protocol relies on random splitting, ensuring that neither 𝑆1 nor 𝑆2 can deduce the
queried file index. Privacy is maintained because 𝑞1 and 𝑞2 are independent modulo 𝑝, and
their combined sum is only meaningful to the user.
Since 𝑞1 and 𝑞2 are random vectors, neither 𝑆1 nor 𝑆2 can infer which data is being queried.
The individual queries appear as noise without the combined context. Privacy is maintained as
long as 𝑆1 and 𝑆2 do not collude, ensuring the user's data choice remains hidden.
Exercise 2. (Computational Information Theoretic PIR).
Consider a remote server 𝑅 with a database consisting of encrypted information about
Cryptocurrency Wallet information of 416-bits, with the Cryptocurrency address size is 160-
bit hash (160-bit hash of Public Key), and the Private Key size is 256-bit. In this database
server, the information was encrypted by the algorithm AES-256.
Example:
• Bitcoin Address: 1NFPDBfhRFEpC7dw1U8Y31QAuEpT63QJdA
• Private Key: L3ka79fsWouqrr7Tqv6XEHDXyz9YxCKYECT7oTpsqFwKvZ5sMVKT
A user wants to download his encrypted Cryptocurrency Wallet information (512-bits), from
the server while keeping his request private. Let assume that the server database has 216 bits
(65536 bits) of information, which contains many encrypted Cryptocurrency Wallet
information, and that the user knows exactly the position of its encrypted Wallet.
Example:
• wallet start at bit number 514.
• wallet end at bit number 1026.
With the use of Quadratic Residuosity theorem, with 𝑝 = 71 and 𝑞 = 97:
a) How many queries we should generate in order to extract all encrypted Wallet bits.
b) Determine the number of all possible elements which are quadratic residuosity 𝑚𝑜𝑑 6887.
c) Give 20 elements which are quadratic residuosity 𝑚𝑜𝑑 6887.
d) Give 10 elements which are quadratic non-residuosity 𝑚𝑜𝑑 6887.
e) Explain mathematically how you will construct a query to get the value of the encrypted
Wallet information.
Solution.
Let assume that the database is a binary sequence 𝑋 = (𝑥0 , 𝑥2 , ⋯ , 𝑥216 −1 ) with 𝑥𝑖 𝜖 {0,1} is a
binary value.
a) We should generate (1026 – 514 = 512) queries since each query return 1 bit at time.
b) The number of all possible elements which are quadratic residuosity 𝑚𝑜𝑑 6887 is 1764.
(See appendix)
c) See appendix and choose 20 number from the list. Attention, avoid the number 0 and the
number 1.
d) See appendix and choose 10 number not in the list.
3
e) If the user wants to retrieve 𝑥𝑖 then he sends a query 𝑞 = (𝑞0 , 𝑞2 , ⋯ , 𝑞216 −1 ) to the server
consisting of:
❑ A quadratic residue 𝑚𝑜𝑑 6887 for all indices except for the 𝑞𝑖 item (we want 𝑥𝑖 ).
❑ A random quadratic non-residue 𝑚𝑜𝑑 6887 in the 𝑞𝑖 item (that we want).
Upon receiving the query 𝑞 = (𝑞0 , 𝑞2 , ⋯ , 𝑞216 −1 ), the server computes a response 𝑟
216 −1
𝑥
𝑟 = ∏ 𝑞𝑖 𝑖
𝑖=0
The server has no idea which 𝑞𝑖 values are quadratic residues or quadratic non-residues, but
the user knows. Due to this distinction, the responses 𝑟 behave differently:
❑ 𝑟 is a quadratic residue 𝑚𝑜𝑑 6887 if 𝑥𝑖 = 0
❑ 𝑟 is a quadratic non-residue 𝑚𝑜𝑑 6887 if 𝑥𝑖 = 1
Therefore, the user will generate 512 queries like the following:
- Query number 0:
❑ A quadratic residue 𝑚𝑜𝑑 6887 for all indices except for 𝑞514
❑ A quadratic non-residue 𝑚𝑜𝑑 6887 for 𝑞514
- Query number 1:
❑ A quadratic residue 𝑚𝑜𝑑 6887 for all indices except for 𝑞515
❑ A quadratic non-residue 𝑚𝑜𝑑 6887 for 𝑞515
⋮
- Query number 512:
❑ A quadratic residue 𝑚𝑜𝑑 6887 for all indices except for 𝑞1026
❑ A quadratic non-residue 𝑚𝑜𝑑 6887 for 𝑞1026
Notice:
From the server’s perspective, it receives a query with random values (𝑞0 , 𝑞2 , ⋯ , 𝑞216 −1 ) , and
computes a response based on these values. Since determining whether a 𝑞𝑖 is a quadratic
residue modulo 𝑁 is computationally hard without knowing the factorization of 6887, the
server cannot distinguish which index 𝑥𝑖 the user is interested in. Thus, the privacy of user
request is protected.
Exercise 3.
In the hospital database, we have 12 records of patients admitted to a healthcare facility. To
ensure patient privacy, the hospital has set fixed levels which are:
▪ At least level 4-anonymity.
▪ At least, level 3 diversity.
▪ At most, level 0.1-closeness.
4
ID Age Zip Code Diagnosis
1 22 13053 Cancer
2 27 13053 Heart Disease
3 29 13076 Cancer
4 26 13068 Viral Infection
5 50 14850 Heart Disease
6 55 14865 Cancer
7 49 14854 Cancer
8 52 14867 Viral Infection
9 32 13067 Heart Disease
10 38 13477 Heart Disease
11 37 13255 Cancer
12 35 13555 Viral Infection
Depending on this level of anonymity, show the final format of the data which will be exported
in later.
Solution.
In this database, we have:
❑ Quasi identifiers: are Age and Zip Code
❑ Sensitive attributes: Diagnosis
5
❑ Level 4-Anonymity: At least three records share the same attribute combination,
reducing re-identification risk.
❑ Level 3 Diversity: Each sensitive attribute (e.g., Diagnosis) has at least three different
values in any equivalence class.
❑ 0.1-Closeness: Ensures the distribution of sensitive values is similar within each group,
preserving privacy. This is done by measuring the distance between the distribution of
a sensitive attribute in a group and the distribution of the attribute in the entire database.
This distance should not exceed a threshold of 0.1 that is 10 %.
6
Appendix - all elements which are quadratic residuosity 𝑚𝑜𝑑 6887
[0, 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 25, 27, 32, 36, 43, 48, 49,
50, 54, 64, 72, 73, 75, 79, 81, 86, 89, 91, 95, 96, 98, 100, 101,
103, 108, 109, 119, 121, 128, 129, 144, 145, 146, 147, 150, 151,
158, 161, 162, 167, 169, 172, 178, 182, 185, 190, 191, 192, 196,
200, 202, 206, 216, 218, 219, 221, 225, 229, 237, 238, 242, 243,
256, 258, 267, 273, 285, 287, 288, 289, 290, 292, 293, 294, 299,
300, 302, 303, 309, 313, 316, 322, 324, 327, 334, 338, 341, 344,
355, 356, 357, 361, 363, 364, 370, 379, 380, 382, 384, 385, 387,
391, 392, 400, 404, 412, 413, 415, 419, 431, 432, 435, 436, 438,
441, 442, 450, 453, 458, 463, 469, 474, 476, 483, 484, 486, 497,
501, 503, 507, 509, 512, 516, 517, 521, 529, 533, 534, 535, 546,
547, 551, 555, 557, 570, 571, 573, 574, 576, 578, 580, 583, 584,
586, 588, 593, 598, 600, 604, 606, 613, 617, 618, 625, 626, 632,
643, 644, 647, 648, 654, 655, 657, 663, 668, 671, 675, 676, 677,
679, 682, 687, 688, 697, 703, 710, 711, 712, 714, 715, 722, 726,
728, 729, 740, 758, 760, 764, 767, 768, 770, 774, 782, 784, 785,
787, 800, 801, 808, 811, 819, 824, 826, 829, 830, 838, 841, 855,
857, 861, 862, 864, 867, 870, 871, 872, 876, 877, 879, 881, 882,
884, 889, 895, 897, 900, 906, 909, 916, 923, 926, 927, 935, 938,
939, 943, 948, 952, 959, 961, 966, 968, 971, 972, 973, 981, 994,
995, 997, 1002, 1003, 1006, 1013, 1014, 1018, 1019, 1023, 1024,
1031, 1032, 1034, 1042, 1043, 1051, 1058, 1065, 1066, 1067, 1068,
1069, 1070, 1071, 1073, 1075, 1083, 1085, 1089, 1092, 1094, 1102,
1103, 1110, 1114, 1115, 1129, 1137, 1139, 1140, 1142, 1146, 1148,
1152, 1155, 1156, 1160, 1161, 1163, 1165, 1166, 1168, 1172, 1173,
1176, 1186, 1196, 1200, 1207, 1208, 1211, 1212, 1213, 1217, 1225,
1226, 1234, 1236, 1237, 1239, 1243, 1245, 1250, 1252, 1255, 1257,
1261, 1264, 1265, 1267, 1279, 1283, 1286, 1288, 1293, 1294, 1296,
1297, 1305, 1308, 1310, 1314, 1315, 1323, 1326, 1327, 1336, 1342,
1349, 1350, 1352, 1354, 1355, 1357, 1358, 1359, 1361, 1364, 1367,
1369, 1374, 1376, 1385, 1389, 1394, 1406, 1407, 1420, 1422, 1423,
1424, 1428, 1430, 1439, 1444, 1447, 1449, 1452, 1456, 1457, 1458,
1463, 1477, 1480, 1491, 1499, 1503, 1509, 1516, 1520, 1521, 1527,
1528, 1534, 1536, 1540, 1541, 1548, 1549, 1551, 1555, 1563, 1564,
1568, 1570, 1574, 1577, 1587, 1599, 1600, 1602, 1605, 1616, 1622,
1633, 1637, 1638, 1641, 1643, 1645, 1648, 1649, 1651, 1652, 1653,
1657, 1658, 1660, 1665, 1671, 1673, 1676, 1681, 1682, 1693, 1697,
1710, 1713, 1714, 1719, 1722, 1724, 1728, 1734, 1740, 1742, 1744,
1747, 1749, 1752, 1754, 1758, 1762, 1764, 1768, 1777, 1778, 1779,
1781, 1790, 1793, 1794, 1795, 1799, 1800, 1807, 1811, 1812, 1818,
1825, 1832, 1835, 1839, 1846, 1847, 1849, 1851, 1852, 1854, 1855,
1861, 1865, 1870, 1875, 1876, 1878, 1886, 1891, 1896, 1904, 1918,
1922, 1929, 1932, 1936, 1937, 1941, 1942, 1944, 1946, 1949, 1962,
1965, 1967, 1971, 1975, 1988, 1989, 1990, 1993, 1994, 2004, 2006,
2012, 2013, 2015, 2025, 2026, 2028, 2031, 2033, 2036, 2037, 2038,
2045, 2046, 2048, 2059, 2061, 2062, 2064, 2068, 2069, 2084, 2086,
2091, 2099, 2102, 2107, 2109, 2116, 2123, 2130, 2131, 2132, 2133,
2134, 2135, 2136, 2138, 2140, 2142, 2145, 2146, 2150, 2159, 2166,
2167, 2170, 2178, 2184, 2187, 2188, 2204, 2206, 2207, 2209, 2213,
2219, 2220, 2225, 2228, 2230, 2231, 2233, 2237, 2239, 2249, 2255,
2258, 2274, 2275, 2278, 2280, 2281, 2284, 2292, 2296, 2297, 2301,
2304, 2310, 2312, 2317, 2320, 2322, 2326, 2329, 2330, 2332, 2336,
7
2344, 2346, 2352, 2353, 2355, 2359, 2361, 2363, 2372, 2375, 2381,
2392, 2393, 2400, 2401, 2403, 2407, 2414, 2416, 2417, 2419, 2422,
2423, 2424, 2426, 2429, 2433, 2434, 2441, 2443, 2450, 2452, 2457,
2468, 2472, 2474, 2478, 2486, 2487, 2489, 2490, 2491, 2495, 2497,
2500, 2504, 2510, 2514, 2521, 2522, 2523, 2525, 2528, 2530, 2533,
2534, 2549, 2557, 2558, 2565, 2566, 2571, 2572, 2575, 2576, 2583,
2586, 2588, 2592, 2594, 2601, 2610, 2613, 2616, 2620, 2627, 2628,
2630, 2631, 2635, 2637, 2643, 2646, 2651, 2652, 2654, 2663, 2667,
2672, 2681, 2684, 2685, 2691, 2698, 2700, 2704, 2707, 2708, 2710,
2713, 2714, 2716, 2717, 2718, 2722, 2725, 2727, 2728, 2734, 2738,
2741, 2743, 2747, 2748, 2752, 2769, 2770, 2777, 2778, 2781, 2788,
2789, 2801, 2805, 2807, 2809, 2812, 2814, 2817, 2819, 2829, 2840,
2844, 2845, 2846, 2848, 2849, 2856, 2860, 2867, 2877, 2878, 2883,
2885, 2888, 2894, 2898, 2904, 2911, 2912, 2913, 2914, 2916, 2919,
2921, 2926, 2935, 2941, 2943, 2954, 2959, 2960, 2971, 2975, 2982,
2983, 2985, 2991, 2998, 3001, 3006, 3007, 3009, 3011, 3018, 3019,
3025, 3031, 3032, 3039, 3040, 3042, 3054, 3055, 3056, 3057, 3061,
3068, 3069, 3071, 3072, 3073, 3077, 3080, 3082, 3093, 3096, 3098,
3101, 3102, 3103, 3107, 3110, 3113, 3126, 3128, 3129, 3136, 3139,
3140, 3148, 3151, 3153, 3154, 3169, 3174, 3195, 3197, 3198, 3199,
3200, 3201, 3203, 3204, 3205, 3207, 3210, 3213, 3219, 3225, 3232,
3233, 3244, 3245, 3249, 3255, 3266, 3267, 3271, 3274, 3276, 3282,
3286, 3290, 3295, 3296, 3298, 3302, 3304, 3306, 3309, 3314, 3316,
3320, 3323, 3330, 3341, 3342, 3345, 3346, 3347, 3352, 3362, 3364,
3373, 3377, 3386, 3387, 3391, 3394, 3395, 3397, 3401, 3411, 3413,
3417, 3420, 3426, 3427, 3428, 3438, 3444, 3445, 3448, 3456, 3457,
3465, 3468, 3480, 3481, 3483, 3484, 3488, 3489, 3491, 3494, 3495,
3498, 3503, 3504, 3508, 3516, 3517, 3519, 3524, 3527, 3528, 3536,
3539, 3553, 3554, 3556, 3558, 3562, 3565, 3577, 3580, 3586, 3587,
3588, 3590, 3593, 3595, 3598, 3600, 3607, 3614, 3621, 3622, 3624,
3625, 3633, 3636, 3637, 3639, 3650, 3651, 3653, 3659, 3661, 3664,
3670, 3675, 3678, 3685, 3692, 3694, 3695, 3697, 3698, 3702, 3704,
3708, 3710, 3711, 3717, 3719, 3721, 3722, 3729, 3730, 3735, 3740,
3750, 3752, 3756, 3765, 3767, 3771, 3772, 3775, 3779, 3781, 3782,
3783, 3787, 3792, 3795, 3799, 3801, 3808, 3827, 3836, 3837, 3844,
3849, 3853, 3858, 3864, 3871, 3872, 3874, 3877, 3879, 3882, 3883,
3884, 3888, 3891, 3892, 3898, 3905, 3907, 3911, 3913, 3915, 3923,
3924, 3929, 3930, 3934, 3941, 3942, 3945, 3950, 3953, 3955, 3959,
3965, 3969, 3976, 3977, 3978, 3979, 3980, 3981, 3985, 3986, 3988,
3995, 4001, 4008, 4012, 4013, 4021, 4024, 4025, 4026, 4030, 4047,
4049, 4050, 4052, 4056, 4062, 4063, 4065, 4066, 4071, 4072, 4074,
4076, 4077, 4083, 4085, 4090, 4092, 4096, 4101, 4105, 4107, 4118,
4121, 4122, 4123, 4124, 4127, 4128, 4136, 4138, 4147, 4155, 4163,
4167, 4168, 4172, 4175, 4182, 4189, 4193, 4195, 4198, 4204, 4207,
4214, 4218, 4219, 4221, 4225, 4232, 4237, 4243, 4246, 4260, 4262,
4264, 4265, 4266, 4268, 4269, 4270, 4272, 4276, 4279, 4280, 4284,
4290, 4292, 4300, 4303, 4317, 4318, 4332, 4333, 4334, 4340, 4341,
4343, 4347, 4349, 4356, 4361, 4363, 4367, 4368, 4369, 4371, 4374,
4376, 4381, 4389, 4408, 4412, 4414, 4418, 4426, 4427, 4429, 4431,
4438, 4440, 4450, 4451, 4456, 4459, 4460, 4462, 4466, 4473, 4474,
4478, 4489, 4493, 4497, 4498, 4505, 4509, 4510, 4511, 4516, 4523,
4527, 4537, 4547, 4548, 4550, 4553, 4556, 4559, 4560, 4562, 4563,
4568, 4571, 4581, 4584, 4592, 4594, 4602, 4608, 4620, 4621, 4623,
4624, 4625, 4631, 4634, 4640, 4644, 4645, 4647, 4652, 4653, 4655,
4658, 4660, 4664, 4665, 4672, 4687, 4688, 4689, 4691, 4692, 4704,
4705, 4706, 4710, 4718, 4722, 4726, 4729, 4731, 4735, 4744, 4750,
8
4757, 4759, 4761, 4762, 4765, 4769, 4775, 4777, 4784, 4786, 4789,
4797, 4800, 4802, 4806, 4807, 4814, 4815, 4817, 4828, 4832, 4834,
4838, 4844, 4846, 4847, 4848, 4852, 4853, 4858, 4866, 4868, 4877,
4882, 4885, 4886, 4899, 4900, 4903, 4904, 4911, 4914, 4915, 4923,
4929, 4931, 4935, 4936, 4939, 4944, 4947, 4948, 4949, 4953, 4956,
4959, 4963, 4971, 4972, 4974, 4978, 4979, 4980, 4982, 4990, 4994,
4995, 4997, 5000, 5008, 5013, 5019, 5020, 5028, 5041, 5042, 5043,
5044, 5045, 5046, 5047, 5050, 5053, 5056, 5060, 5066, 5068, 5071,
5077, 5079, 5091, 5098, 5105, 5114, 5116, 5117, 5130, 5132, 5137,
5139, 5141, 5142, 5144, 5149, 5150, 5152, 5157, 5166, 5172, 5176,
5184, 5185, 5188, 5189, 5191, 5195, 5202, 5203, 5207, 5213, 5220,
5226, 5232, 5237, 5240, 5241, 5247, 5254, 5256, 5260, 5262, 5263,
5269, 5270, 5273, 5274, 5281, 5286, 5291, 5292, 5299, 5302, 5303,
5304, 5308, 5311, 5326, 5327, 5329, 5331, 5333, 5334, 5335, 5337,
5341, 5343, 5344, 5357, 5362, 5368, 5370, 5379, 5382, 5383, 5385,
5389, 5396, 5397, 5399, 5400, 5401, 5405, 5408, 5414, 5416, 5420,
5421, 5423, 5426, 5428, 5432, 5433, 5434, 5436, 5441, 5444, 5450,
5454, 5456, 5467, 5468, 5475, 5476, 5479, 5482, 5485, 5486, 5494,
5496, 5497, 5504, 5505, 5507, 5517, 5521, 5525, 5527, 5531, 5538,
5540, 5541, 5547, 5553, 5554, 5556, 5562, 5565, 5576, 5578, 5583,
5595, 5602, 5610, 5614, 5615, 5617, 5618, 5624, 5625, 5627, 5628,
5629, 5634, 5638, 5657, 5658, 5659, 5669, 5673, 5680, 5688, 5690,
5692, 5696, 5698, 5699, 5705, 5707, 5712, 5717, 5720, 5723, 5725,
5729, 5734, 5754, 5755, 5756, 5759, 5766, 5767, 5770, 5771, 5776,
5787, 5788, 5789, 5796, 5808, 5809, 5811, 5822, 5823, 5824, 5826,
5828, 5831, 5832, 5838, 5842, 5847, 5851, 5852, 5867, 5870, 5882,
5886, 5893, 5895, 5899, 5901, 5905, 5908, 5909, 5911, 5913, 5917,
5918, 5920, 5923, 5925, 5929, 5933, 5941, 5942, 5950, 5953, 5964,
5965, 5966, 5967, 5970, 5979, 5982, 5983, 5989, 5996, 6002, 6012,
6013, 6014, 6018, 6022, 6036, 6038, 6039, 6041, 6045, 6047, 6050,
6062, 6064, 6067, 6075, 6078, 6080, 6084, 6089, 6093, 6095, 6099,
6107, 6108, 6109, 6110, 6111, 6112, 6114, 6115, 6122, 6133, 6135,
6136, 6138, 6142, 6143, 6144, 6146, 6154, 6155, 6160, 6164, 6177,
6181, 6183, 6186, 6192, 6196, 6197, 6202, 6204, 6206, 6207, 6209,
6214, 6217, 6220, 6226, 6235, 6241, 6251, 6252, 6256, 6257, 6258,
6272, 6273, 6278, 6280, 6293, 6296, 6297, 6302, 6305, 6306, 6308,
6321, 6323, 6327, 6329, 6337, 6338, 6348, 6349, 6355, 6359, 6367,
6369, 6377, 6390, 6391, 6393, 6394, 6396, 6398, 6399, 6400, 6402,
6405, 6406, 6408, 6410, 6414, 6420, 6426, 6427, 6433, 6435, 6438,
6450, 6463, 6464, 6466, 6467, 6477, 6481, 6488, 6490, 6491, 6493,
6497, 6498, 6499, 6501, 6510, 6511, 6515, 6521, 6532, 6534, 6535,
6542, 6547, 6548, 6552, 6561, 6564, 6569, 6572, 6580, 6590, 6592,
6596, 6604, 6605, 6607, 6608, 6612, 6618, 6621, 6623, 6627, 6628,
6632, 6639, 6640, 6643, 6646, 6657, 6660, 6661, 6675, 6677, 6682,
6684, 6689, 6690, 6692, 6693, 6694, 6699, 6701, 6704, 6711, 6717,
6724, 6728, 6746, 6747, 6754, 6755, 6757, 6763, 6765, 6772, 6774,
6781, 6782, 6788, 6790, 6793, 6794, 6799, 6802, 6817, 6821, 6822,
6825, 6826, 6834, 6840, 6843, 6852, 6854, 6856, 6865, 6876]