JHUISI/charm

Not able to hash group element to binary string. Help!!

ashishlakraa opened this issue · 2 comments

I want to have a cryptographic hash function with the mapping as H: G2 → {0, 1}n for some n . But in charm-crypto we can only hash an element type/string to a specific field only.

I am implementing an algorithm for certificateless public encryption with keyword search and in the algorithm I need this hash function.

Can someone please help me how to facilitate this hash function H functionality in charm?

@ashishlakra01 you could do something like this:

from hashlib import sha256

group = ... # some PairingGroup
g2 = ... # element of G2
digest = sha256(group.serialize(g2)).digest()

@ashishlakra01 you could do something like this:

from hashlib import sha256

group = ... # some PairingGroup
g2 = ... # element of G2
digest = sha256(group.serialize(g2)).digest()

Thank you so much @lrusso96 I will try this out.