ECDSA please help! I am using secp128r1 elliptic curve to do an encryption shceme. I got the DHKE to work but for some reason i
ECDSA please help!
I am using secp128r1 elliptic curve to do an encryption shceme. I got the DHKE to work but for some reason i cant get the digital signature. here is a snippet of my code. any help would be much appreciated! I can never get the x cooridinate of P (P[0]) to equal r which would mean the signature is verified. Im pretty sure all my elliptic curve multiplication and modinverse functions work so im not sure what i am doing wrong then.
my paremeters are:
prime = '00fffffffdffffffffffffffffffffffff'
A = '00fffffffdfffffffffffffffffffffffc'
B = '00e87579c11079f43dd824993c2cee5ed3'
generator = '161ff7528b899b2d0c28607ca52c5b86cf5ac8395bafeb13c02da292dded7a83' gx = '161ff7528b899b2d0c28607ca52c5b86' gy = 'cf5ac8395bafeb13c02da292dded7a83' gen = (gx,gy)
order = '00fffffffe0000000075a30d1b9038a115'
seed = '000e0d4d696e6768756151750cc03a4473d03679'
below is part of the code where i try to do the digital signature
###digital signature message = "sign this" msghash = hashlib.sha256(message).hexdigest()
truncateHash = int(msghash[:32],16)
##key gen
randomD = random.randint(2,intOrder) pointB = EccMultiply(intgen,randomD)
##signature
ke = random.randint(2,intOrder) Rsignpoint = EccMultiply(intgen,ke) r = Rsignpoint[0] % intOrder
s = ((truncateHash + randomD*r)*modinv(ke,intPrime)) % intOrder
#print s #verify signature w = modinv(s,intPrime) % intOrder u1 = (w*truncateHash) % intOrder u2 = (w*r) % intOrder P1 = EccMultiply(intgen,u1) P2 = EccMultiply(pointB,u2) P = ECadd(P1,P2)
#print P #print r
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started