- random hash (not questioned) - sha256 of a bitstring - 32 bytes - first 3 bytes of hash are hashed. - last byte is directly compared to last ip bytes - closest eligible ip is voted for """ from libs.utils import random_hash from libs.utils import shuffle_ip_score, save_whois from libs.nodesreader import NodesReader if __name__ == "__main__": readers = [] for i in range(5): readers.append(NodesReader("NODES/nodes.{}".format(i + 1))) # save_whois() for test in range(1000): cycle_hash = random_hash() # print("Run {}".format(test)) winners = [] for i in range(5): winner = readers[i].winner(cycle_hash, scoring=shuffle_ip_score) ip_class = readers[i].verifiers[winner][1] ip_class_count = readers[i].ip_classes[ip_class][0] # print(winner.hex(), ip_class, ip_class_count) winners.append(winner) # exit() full = True for i in range(4):
""" Many draws on a single "nodes" file, to analyse odds and bias. """ from libs.utils import random_hash from libs.utils import hashed_class_mix_score, shuffle_mix from libs.nodesreader import NodesReader if __name__ == "__main__": reader = NodesReader("NODES/nodes.1") # save_whois() for test in range(100000): cycle_hash = random_hash() shuffle_mix(cycle_hash) # print("Run {}".format(test)) winner = reader.winner(cycle_hash, scoring=hashed_class_mix_score) ip, ip_class = reader.verifiers[winner][:2] ip_class_count = reader.ip_classes[ip_class][0] print("{},{},{}".format(ip, ip_class, ip_class_count))
""" Many draws on a single "nodes" file, to analyse odds and bias. """ from libs.utils import random_hash from libs.utils import linear_ip_score4, shuffle from libs.nodesreader import NodesReader if __name__ == "__main__": reader = NodesReader("NODES/nodes.1") # save_whois() for test in range(100000): cycle_hash = random_hash() # print("Run {}".format(test)) winner = reader.winner(cycle_hash) ip, ip_class = reader.verifiers[winner][:2] ip_class_count = reader.ip_classes[ip_class][0] print("{},{},{}".format(ip, ip_class, ip_class_count))
""" Simulation with lottery in shuffled linear ip space - random hash (not questioned) - sha256 of a bitstring - 32 bytes - first 4 bytes of hash are converted to an int. - ip is converted to a 4 bytes int as well - first 2 bytes of ip are shuffled via a pseudo random lookup table, fed from the hash, to account for non uniform density in public ip v4 - closest eligible ip is voted for Many draws on a single "nodes" file, to analyse odds and bias. """ from libs.utils import random_hash from libs.utils import linear_ip_score2, shuffle from libs.nodesreader import NodesReader if __name__ == "__main__": reader = NodesReader("NODES/nodes.1") # save_whois() for test in range(100000): cycle_hash = random_hash() shuffle(cycle_hash) # print("Run {}".format(test)) winner = reader.winner(cycle_hash, scoring=linear_ip_score2) ip, ip_class = reader.verifiers[winner][:2] ip_class_count = reader.ip_classes[ip_class][0] print("{},{},{}".format(ip, ip_class, ip_class_count))