def splitGet(user, password, name): splits = getSplits(user, password) k = int(splits[0]) n = (len(splits) - 1)/2 assert int(n) == n assert k <= n keys = KeyDeriver(password) shares = {} # FIXME: obviously we should try all n until we get k splits for s in range(k): global host, port host = splits[2*s + 1] port = splits[2*s + 2] print "Getting split", s, "from", host + ":" + port records = baseGetList(user, password, 1, name) record = records[-1] share = unconcat(keys.decrypt(record['value'])) assert len(share) == 2 shares[bin2int(share[0])] = bin2int(share[1]) splitter = ShamirSplit() secret = splitter.recover(shares) print "value =", secret
def splitGet(user, password, name): splits = getSplits(user, password) k = int(splits[0]) n = (len(splits) - 1) / 2 assert int(n) == n assert k <= n keys = KeyDeriver(password) shares = {} # FIXME: obviously we should try all n until we get k splits for s in range(k): global host, port host = splits[2 * s + 1] port = splits[2 * s + 2] print "Getting split", s, "from", host + ":" + port records = baseGetList(user, password, 1, name) record = records[-1] share = unconcat(keys.decrypt(record['value'])) assert len(share) == 2 shares[bin2int(share[0])] = bin2int(share[1]) splitter = ShamirSplit() secret = splitter.recover(shares) print "value =", secret
def getSplits(user, password): records = baseGetList(user, password, 2, "split servers") record = records[-1] keys = KeyDeriver(password) splits = unconcat(keys.decrypt(record['value'])) return splits