charm icon indicating copy to clipboard operation
charm copied to clipboard

Use multi authorities to encrypt and decrypt message using DACMACS

Open ihsanhaikalz opened this issue 6 years ago • 2 comments

I came across your library and I am interested to use DACMACS (https://github.com/JHUISI/charm/blob/dev/charm/schemes/abenc/abenc_dacmacs_yj14.py) for my own research. I tried to use multi-authorities scenario where user encrypts a message using attributes coming from two authorities but it gave me an error. My code is something like this:

groupObj = PairingGroup('SS512')
dac = DACMACS(groupObj)
GPP, GMK = dac.setup()

users = {}  # public user data
authorities = {}

authorityAttributes = ["ONE", "TWO", "THREE", "FOUR"]
authority1 = "authority1"

authorityAttributes2 = ["FIVE", "SIX", "SEVEN", "EIGHT"]
authority2 = "authority2"


dac.setupAuthority(GPP, authority1, authorityAttributes, authorities)
dac.setupAuthority(GPP, authority2, authorityAttributes2, authorities)



alice = {'id': 'alice', 'authoritySecretKeys': {}, 'keys': None}
alice['keys'], users[alice['id']] = dac.registerUser(GPP)

for attr in authorityAttributes[0:-1]:
    dac.keygen(GPP, authorities[authority1], attr, users[alice['id']], alice['authoritySecretKeys'])

for attr in authorityAttributes2[0:-1]:
    dac.keygen(GPP, authorities[authority2], attr, users[alice['id']], alice['authoritySecretKeys'])



k = groupObj.random(GT)

policy_str = '((FIVE or SIX) and (SEVEN or EIGHT))'

print(authorities[authority1])
print(authorities[authority2])

CT = dac.encrypt(GPP, policy_str, k, authorities)
TK = dac.generateTK(GPP, CT, alice['authoritySecretKeys'], alice['keys'][0])
PT = dac.decrypt(CT, TK, alice['keys'][1])
print(k)
print(PT)

The error given is like this:

Traceback (most recent call last):
  File "/home/ihsan/Documents/dacmacs-python/dacmacs/test.py", line 44, in <module>
    CT = dac.encrypt(GPP, policy_str, k, authorities)
  File "/home/ihsan/Downloads/charm/charm/schemes/abenc/abenc_dacmacs_yj14.py", line 111, in encrypt
    _, APK, authAttrs = authority
ValueError: not enough values to unpack (expected 3, got 2)

I know from the code that for encrypt function it is only able to encrypt using attributes coming from one authority but in the scenario coming from the original paper it should also be able to encrypt with multiple authorities.

Any suggestion?

ihsanhaikalz avatar Apr 17 '18 11:04 ihsanhaikalz

You will have to modify the encryption function that was implemented for the dacmacs scheme. The current implementation does not handle multiple authorities properly. I had to modify it at my end for it to work.

chisomiloks avatar May 21 '19 16:05 chisomiloks

@chisomiloks could you share your modification of dac-macs?

ihsanhaikalz avatar May 22 '19 11:05 ihsanhaikalz