Skip to content

Commit 02c6e19

Browse files
committed
Preliminary high level SP-IBBE
1 parent ab64600 commit 02c6e19

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

sp-ibbe.py

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
'''
2+
Implementation of SP-IBBE,
3+
i.e. Secured & Partitioned - Identity Based Broadcast Encryption.
4+
5+
Author: Stefan Contiu <[email protected]>
6+
7+
Published under Apache v2 License:
8+
https://www.apache.org/licenses/LICENSE-2.0.txt
9+
10+
Remark(s):
11+
This file holds high level operations of the SP-IBBE scheme.
12+
The administrators have a HONEST-BUT-CURIOUS trust model, meaning they
13+
will execute what is asked from them but without confidentiality
14+
guarantees.
15+
'''
16+
17+
import numpy as np
18+
19+
MAX_USERS_PER_PARTITION = 1000
20+
21+
22+
def add_user_to_group(user_name, group_name):
23+
# 1. get partition id
24+
partition_id = compute_partition_id(user_name, group_name)
25+
26+
# 2. get [Members List] and [C1, C2]
27+
members = []
28+
g_meta = []
29+
30+
# 3. append new member
31+
members.append(user_name)
32+
33+
# 4. modify C2
34+
35+
# 5. get a signed hash of new data
36+
37+
# 6. push to cloud
38+
39+
pass
40+
41+
def remove_user_from_group(user_name, group_name):
42+
pass
43+
44+
def compute_partition_id(user_name, group_name):
45+
gp = GroupPartitionsMeta()
46+
47+
# do we need more partitions for the group ?
48+
current_free_space = gp.get_remaining_space(group_name);
49+
if (current_free_space < free_space_treshold):
50+
# add some more partitions
51+
52+
# weighted sampling
53+
partitions = range(partitions_count)
54+
weights = gp.group_free_space_histogram(group_name)
55+
i = np.random.choice(vec,size=1,replace=False, p=partitions)
56+
57+
return group_name + "_" + i
58+
59+
class GroupPartitionsMeta:
60+
61+
group_free_space = dict()
62+
63+
user_partitions = dict()
64+
65+
group_partitions_count = dict()
66+
67+
def __init__(self, arg):
68+
pass
69+
70+
def get_remaining_space(self, group):
71+
# if group_free_space does not have group, create partition table
72+
return group_free_space[group]
73+
74+
def add_partitions(self, group_name, new_partitions_count):
75+
# add
76+
77+
def group_free_space_histogram(self, group_name):
78+
# todo this method should be modified to return percents
79+
return group_partitions_count[group_name]
80+
81+
def main():
82+
generate_partition_id("[email protected]", "friends")
83+
84+
if __name__ == "__main__":
85+
main()

0 commit comments

Comments
 (0)