Skip to content

Instantly share code, notes, and snippets.

@SaifRehman
Created September 22, 2018 21:08
Show Gist options
  • Save SaifRehman/afdd8589e76b29384a5c642e35c0182e to your computer and use it in GitHub Desktop.
Save SaifRehman/afdd8589e76b29384a5c642e35c0182e to your computer and use it in GitHub Desktop.
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