Created
September 22, 2018 21:08
-
-
Save SaifRehman/afdd8589e76b29384a5c642e35c0182e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def SignatureGeneration(genPoint,randomNumber,hashOfThingToSign) | |
q = EccMultiply(genPoint,randomNumber) | |
xRandSignPoint = q[0][0] | |
yRandSignPoint = q[0][1] | |
r = xRandSignPoint % $numberOfPointsInFeild; | |
s = ((hashOfThingToSign + (r*hextodec($privKey)))*(modInverse(randomNumber,$numberOfPointsInFeild))) % $numberOfPointsInFeild | |
return [r,s] | |
end | |
def SignatureVerification(s,r,hashOfThingToSign,publicKey) | |
w = modInverse(s,$numberOfPointsInFeild) | |
point1 = EccMultiply($point,((hashOfThingToSign * w) % $numberOfPointsInFeild)) | |
point2 = EccMultiply(publicKey,((r*w) % $numberOfPointsInFeild)) | |
q = ECadd(point1[0],point2[0]) | |
x = q[0] | |
y = q[1] | |
if(x === r) | |
return true | |
else | |
return false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment