예제 #1
0
 def __init__(self, groupObj):
     IBEnc.__init__(self)
     global group, H, util
     group = groupObj
     H = lambda x: group.hash(('0', x), ZR)
     util = SecretShare(group, False)
     global v
예제 #2
0
    def testSecretShare(self):
        # Testing Secret sharing python API
          k = 3
          n = 4
          group = PairingGroup('SS512')

          s = SecretShare(group, False)
          sec = group.random(ZR)
          shares = s.genShares(sec, k, n)

          K = shares[0]
          if debug: print('\nOriginal secret: %s' % K)
          y = {group.init(ZR, long(1)):shares[1], group.init(ZR, long(2)):shares[2], group.init(ZR, long(3)):shares[3]}

          secret = s.recoverSecret(y)

          assert K == secret, "Could not recover the secret!"
          if debug: print("Successfully recovered secret: ", secret)
예제 #3
0
def getUserGlobals():
    global groupObjBuiltInFuncs, utilBuiltInFuncs, shareBuiltInFuncs

    if (groupObjBuiltInFuncs == None):
        groupObjBuiltInFuncs = PairingGroup(MNT160)

    if (utilBuiltInFuncs == None):
        utilBuiltInFuncs = SecretUtil(groupObjBuiltInFuncs, verbose=False)

    if (shareBuiltInFuncs == None):
        shareBuiltInFuncs = SecretShare(groupObjBuiltInFuncs, False)
예제 #4
0
    def testSecretShare(self):
        # Testing Secret sharing python API
        k = 3
        n = 4
        group = PairingGroup('SS512')

        s = SecretShare(group, False)
        sec = group.random(ZR)
        shares = s.genShares(sec, k, n)

        K = shares[0]
        if debug: print('\nOriginal secret: %s' % K)
        y = {
            group.init(ZR, long(1)): shares[1],
            group.init(ZR, long(2)): shares[2],
            group.init(ZR, long(3)): shares[3]
        }

        secret = s.recoverSecret(y)

        assert K == secret, "Could not recover the secret!"
        if debug: print("Successfully recovered secret: ", secret)