Commit badde1b9 authored by UNHALE NILESH ARUN's avatar UNHALE NILESH ARUN

completed algorand implementation

parent 24319984
...@@ -2,7 +2,7 @@ lambda_proposer = 30# wait time for priority messages to be received ...@@ -2,7 +2,7 @@ lambda_proposer = 30# wait time for priority messages to be received
tou_proposer = 20 # proposer rolecount tou_proposer = 20 # proposer rolecount
ROLE_BLOCK_PROPOSER = 'BLOCK_PROPOSER' ROLE_BLOCK_PROPOSER = 'BLOCK_PROPOSER'
tou_step = 20 # tou is expected number of users that sortition selects for committee tou_step = 28 # tou is expected number of users that sortition selects for committee
ROLE_COMMITEE_FOR_VOTE = 'committee' ROLE_COMMITEE_FOR_VOTE = 'committee'
lambda_block = 300 #seconds lambda_block = 300 #seconds
...@@ -13,7 +13,16 @@ BLOCK_PROPOSAL_MSG_type = 'BLOCK_PROPOSAL_MSGs' ...@@ -13,7 +13,16 @@ BLOCK_PROPOSAL_MSG_type = 'BLOCK_PROPOSAL_MSGs'
PRIORITY_MSG_type = 'PRIORITY_MSG' PRIORITY_MSG_type = 'PRIORITY_MSG'
COMMITTEE_VOTE_MSG_type = "COMMITTEE_VOTE" COMMITTEE_VOTE_MSG_type = "COMMITTEE_VOTE"
TIMEOUT = "TIMEOUT" TIMEOUT = "TIMEOUT"
T = 2/3 # T isa a fraction of expected committee size that defines BA*`s voting thershold T = 0.001 # 2/3 # T isa a fraction of expected committee size that defines BA*`s voting thershold
NUMBER_OF_NODES_IN_NETWORK = 50 T_FINAL = 0.001
tou_FINAL = 28
FINALIZED_BLOCK_msg_type = "FINALIZED_BLOCK"
TENTATIVE_BLOCK_msg_type = "TENTATIVE_BLOCK"
NUMBER_OF_NODES_IN_NETWORK = 30
MAXSTEP = 15
FINAL_STEP = 9999999999
0 21 0 19
0 39 0 24
1 32 0 27
1 29 1 2
2 34 1 20
2 44 1 19
3 16 2 6
3 25 3 22
3 42 3 12
3 35 4 16
4 18 4 7
4 37 4 25
4 43 5 28
4 30 5 15
5 37 6 8
5 11 6 26
5 23
6 41
6 46
7 14
7 47
7 28 7 28
8 15 7 23
8 44 8 13
8 35 8 18
9 27 9 22
9 46 9 24
9 13 10 21
9 49 10 16
10 27 11 19
10 48
10 35
11 29
11 23 11 23
12 22 12 22
12 42 12 17
13 26 13 29
13 33 14 25
14 24 14 15
14 27 14 26
14 39 15 29
15 40 16 20
16 22 17 24
16 40 18 23
16 42 18 21
17 23 18 22
17 45 23 27
18 48 25 28
19 27
19 31
20 46
20 45
20 38
21 24
21 37
21 30
23 42
25 29
26 41
28 34
29 49
30 31
30 38
31 36
31 34
32 35
32 39
33 47
36 43
37 38
39 47
40 47
41 46
41 49
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
...@@ -33,7 +33,11 @@ class Network(): ...@@ -33,7 +33,11 @@ class Network():
:return: :return:
''' '''
w = randint(1, 51, Config.NUMBER_OF_NODES_IN_NETWORK) # 51 is excluded - range (1,50) w = randint(1, 51, Config.NUMBER_OF_NODES_IN_NETWORK) # 51 is excluded - range (1,50)
print('Stakes that are given to the nodes are : \n')
print(w)
print('\n')
self.badaW = np.sum(w) self.badaW = np.sum(w)
print(self.badaW)
i = 0 i = 0
with open('Nodes1.dat', 'r') as f: with open('Nodes1.dat', 'r') as f:
reader = csv.reader(f) reader = csv.reader(f)
......
...@@ -28,23 +28,3 @@ ...@@ -28,23 +28,3 @@
27 27
28 28
29 29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
This diff is collapsed.
...@@ -64,6 +64,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk): ...@@ -64,6 +64,7 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk):
newseed = (seed,role) newseed = (seed,role)
hash,proof = VRF(sk, newseed, pk) hash,proof = VRF(sk, newseed, pk)
p = rolecount/badaW p = rolecount/badaW
# p = 0.5
j=0 j=0
#simplifying the computation : hash/(2**hashlen) #simplifying the computation : hash/(2**hashlen)
...@@ -88,6 +89,12 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk): ...@@ -88,6 +89,12 @@ def sortition(sk,seed,rolecount,role,w,badaW,pk):
break break
j = j+1 j = j+1
# added by nilesh
if j > 0 :
print('\n')
print('===============> The j value is >>>' , j)
print('\n')
return (hash,proof,j) return (hash,proof,j)
...@@ -256,7 +263,7 @@ def tester(): ...@@ -256,7 +263,7 @@ def tester():
roleCount = 26 roleCount = 26
role = "LEAD" role = "LEAD"
# w= randint(1,100000,10) # w= randint(1,100000,10)
w = [ 1, 10,100, 500, 1000,5000, 8000, 10000 ] w = randint(1, 51, 50)
w.sort() w.sort()
print(w) print(w)
# w = 20 # w = 20
......
import hashlib
h1 = hashlib.sha256((str('asda')).encode('utf-8'))
h1hex = h1.hexdigest()
print(int(h1hex,16)% 2)
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