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 @@
`pip3 install -r requirements.txt `
* Setup
......@@ -24,3 +21,5 @@
* How to run
### Nilesh doubts:
\ No newline at end of file
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: secrete 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()
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