Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
algorand
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nilak
algorand
Commits
2bd28bca
Commit
2bd28bca
authored
Apr 21, 2019
by
UNHALE NILESH ARUN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing
parent
3f7afffa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
0 deletions
+74
-0
OverlayNode.py
OverlayNode.py
+29
-0
README.md
README.md
+26
-0
Utility.py
Utility.py
+19
-0
No files found.
OverlayNode.py
View file @
2bd28bca
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
...
...
README.md
View file @
2bd28bca
#Algorand
*
Dsicrete Event Simulator
*
Gossip Protocol
*
Installation
`pip3 install -r requirements.txt `
*
Setup
*
Requirements
*
How to run
Utility.py
View file @
2bd28bca
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment