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
0c670fd7
Commit
0c670fd7
authored
Apr 22, 2019
by
THAKARE AKSHAY HARIBHAU
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'Nalgo'
# Conflicts: # README.md # Utility.py
parents
3169d637
9b7da117
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
22 deletions
+44
-22
README.md
README.md
+2
-3
Utility.py
Utility.py
+42
-19
No files found.
README.md
View file @
0c670fd7
...
...
@@ -12,9 +12,6 @@
`pip3 install -r requirements.txt `
*
Setup
...
...
@@ -24,3 +21,5 @@
*
How to run
### Nilesh doubts:
\ No newline at end of file
Utility.py
View file @
0c670fd7
from
ecdsa
import
SigningKey
,
SECP256k1
from
ecdsa.keys
import
BadSignatureError
from
numpy.random
import
randint
import
numpy
as
np
import
binascii
import
random
...
...
@@ -49,7 +51,7 @@ def verifyVRF(pk,hash,proof,seed):
def
sortition
(
sk
,
seed
,
rolecount
,
role
,
w
,
badaW
,
pk
):
'''
:param sk: secret
e
key
:param sk: secret key
:param seed:
:param rolecount: tou
:param role:
...
...
@@ -133,23 +135,23 @@ def verifySort(pk,hash,proof,seed,rolecount,role,w,badaW):
return
j
def
computeRange
():
badaW
=
10
lastValue
=
0
;
p
=
0.5
x
=
0.0023
j
=
0
if
(
x
<=
stats
.
binom
.
pmf
(
0
,
badaW
,
p
)):
j
=
0
else
:
for
k
in
range
(
0
,
badaW
+
1
):
lastValue
=
lastValue
+
stats
.
binom
.
pmf
(
k
,
badaW
,
p
)
nextvalue
=
lastValue
+
stats
.
binom
.
pmf
(
k
+
1
,
badaW
,
p
)
print
(
lastValue
)
print
(
nextvalue
)
print
(
"------------"
)
j
=
j
+
1
#
def computeRange():
#
badaW=10
#
lastValue = 0;
#
p = 0.5
#
x = 0.0023
#
j = 0
#
if (x<=stats.binom.pmf(0, badaW, p)):
#
j = 0
#
else :
#
for k in range(0,badaW+1):
#
lastValue = lastValue + stats.binom.pmf(k, badaW, p)
#
nextvalue =lastValue+ stats.binom.pmf(k+1, badaW, p)
#
print(lastValue)
#
print(nextvalue)
#
print("------------")
#
j =j+1
#
...
...
@@ -187,6 +189,26 @@ def testSortition():
print
(
proof
)
print
(
j
)
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
testVerifySort
():
sk
,
pk
=
genratePublicPrivateKey
()
seed
=
(
"a"
,
1
,
2
)
...
...
@@ -257,4 +279,5 @@ def testVerifyVRF():
if
__name__
==
'__main__'
:
# testSortition()
# testVerifyVRF()
testVerifySort
()
# testVerifySort(0
tester
()
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