Commit 2bd28bca authored by UNHALE NILESH ARUN's avatar UNHALE NILESH ARUN

Changing

parent 3f7afffa
from Node import Node
import logging
import Utility
import hashlib
genesisBlock = "I am the first block"
class OverlayNode(Node):
def __init__(self,id,network):
......@@ -15,6 +19,31 @@ class OverlayNode(Node):
while True:
#increment round number
# Checking if I am a Block Propser
previousHash = hashlib.sha256(genesisBlock.encode('utf-8')).hexdigest()
currentRound = 0
step = 0
seed = ( previousHash,currentRound,blockHeight )
roleCount = 20
role = "BLOCK_PROPOSER"
w = self.w
badaW = 100
hash, proof, j = Utility.sortition(self.sk,seed,roleCount, role, w, badaW, self.pk)
if j > 0 :
min = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
for sub_user_index in range(w):
input_to_SHA256 = hash + sub_user_index # TODO : can concatenation means this
sha256_hash = hashlib.sha256(input_to_SHA256.encode('utf-8')).hexdigest()
if sha256_hash < min:
min_sha_priority = sha256_hash
min_sub_user_index = sub_user_index
msg_to_broadcast = ( roundNumber, hash , min_sub_user_index , min_sha_priority )
'''
TODo check if node is selected as BLOCK_PROPOSER
if yes
......
#Algorand
* Dsicrete Event Simulator
* Gossip Protocol
* Installation
`pip3 install -r requirements.txt `
* Setup
* Requirements
* How to run
......@@ -221,6 +221,25 @@ def testVerifySort():
print(y)
assert (y==0),"Test Verify sort failed : change of seed not detected"
def tester():
sk,pk = genratePublicPrivateKey()
seed = ("a",1,2)
roleCount = 26
role = "LEAD"
# w= randint(1,100000,10)
w = [ 1, 10,100, 500, 1000,5000, 8000, 10000 ]
w.sort()
print(w)
# w = 20
badaW = np.sum(w)
print(badaW)
for i in w:
hash,proof,j = sortition(sk,seed,roleCount,role,i,badaW,pk)
# print(hash) #this is a real content of hash it should be used as final thing and not hexlify
# print(binascii.hexlify(hash))
# print(proof)
print("w = " + str(i) , "w/badaW = ", str(i/badaW), "j = " ,str(j))
def testVerifyVRF():
sk,pk = genratePublicPrivateKey()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment