Commit 0c670fd7 authored by THAKARE AKSHAY HARIBHAU's avatar THAKARE AKSHAY HARIBHAU

Merge branch 'master' into 'Nalgo'

# Conflicts:
#   README.md
#   Utility.py
parents 3169d637 9b7da117
...@@ -12,9 +12,6 @@ ...@@ -12,9 +12,6 @@
`pip3 install -r requirements.txt ` `pip3 install -r requirements.txt `
* Setup * Setup
...@@ -24,3 +21,5 @@ ...@@ -24,3 +21,5 @@
* How to run * How to run
### Nilesh doubts:
\ No newline at end of file
from ecdsa import SigningKey,SECP256k1 from ecdsa import SigningKey,SECP256k1
from ecdsa.keys import BadSignatureError from ecdsa.keys import BadSignatureError
from numpy.random import randint
import numpy as np
import binascii import binascii
import random import random
...@@ -49,7 +51,7 @@ def verifyVRF(pk,hash,proof,seed): ...@@ -49,7 +51,7 @@ def verifyVRF(pk,hash,proof,seed):
def sortition(sk,seed,rolecount,role,w,badaW,pk): def sortition(sk,seed,rolecount,role,w,badaW,pk):
''' '''
:param sk: secrete key :param sk: secret key
:param seed: :param seed:
:param rolecount: tou :param rolecount: tou
:param role: :param role:
...@@ -133,23 +135,23 @@ def verifySort(pk,hash,proof,seed,rolecount,role,w,badaW): ...@@ -133,23 +135,23 @@ def verifySort(pk,hash,proof,seed,rolecount,role,w,badaW):
return j return j
def computeRange(): # def computeRange():
badaW=10 # badaW=10
lastValue = 0; # lastValue = 0;
p = 0.5 # p = 0.5
x = 0.0023 # x = 0.0023
j = 0 # j = 0
if (x<=stats.binom.pmf(0, badaW, p)): # if (x<=stats.binom.pmf(0, badaW, p)):
j = 0 # j = 0
else : # else :
for k in range(0,badaW+1): # for k in range(0,badaW+1):
lastValue = lastValue + stats.binom.pmf(k, badaW, p) # lastValue = lastValue + stats.binom.pmf(k, badaW, p)
nextvalue =lastValue+ stats.binom.pmf(k+1, badaW, p) # nextvalue =lastValue+ stats.binom.pmf(k+1, badaW, p)
print(lastValue) # print(lastValue)
print(nextvalue) # print(nextvalue)
print("------------") # print("------------")
j =j+1 # j =j+1
#
...@@ -187,6 +189,26 @@ def testSortition(): ...@@ -187,6 +189,26 @@ def testSortition():
print(proof) print(proof)
print(j) 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(): def testVerifySort():
sk, pk = genratePublicPrivateKey() sk, pk = genratePublicPrivateKey()
seed = ("a", 1, 2) seed = ("a", 1, 2)
...@@ -257,4 +279,5 @@ def testVerifyVRF(): ...@@ -257,4 +279,5 @@ def testVerifyVRF():
if __name__ == '__main__': if __name__ == '__main__':
# testSortition() # testSortition()
# testVerifyVRF() # testVerifyVRF()
testVerifySort() # testVerifySort(0
tester()
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