Semantron 21 Summer 2021

Cryptography

if gcd(e,t)== 1: break #end if

#next e

for i in range(1,10): x = 1 + i*t if x % e == 0: d = int(x/e) break #end if #next i

#encryption: plain text to power e, mod n ctt = Decimal(0) ctt = pow(no,e) ct = ctt % n #decryption: cipher text to power of d, mod n dtt = Decimal(0) dtt = pow(ct,d) dt = dtt % n

#print values to screen print('n = '+str(n)+' e = '+str(e)+' t = '+str(t)+' d = '+str(d)+' cipher text = '+str(ct)+' decrypted text = '+str( dt))

Elliptic Curve Cryptography / Elliptic Curve Digital Signature Algorithm (ECDSA)

Elliptic Curve Cryptography (ECC) is favoured over RSA because the key sizes are much smaller and are still secure in comparison. For example, a 256-bit ECC key can be considered equivalent to a 3072-bit RSA key. Thus, this reduces the computational power needed to produce the key. An elliptic curve is a plane curve over a finite field (rather than real numbers) which consists of the points satisfying the equation y 2 = x 3 + Ax + B , where both A and B are integers. The y 2 means that for any x coordinate there will be two y coordinates. The SHA1 (Secure Hash Algorithm) algorithm is used in conjunction to produce a fixed size string that looks nothing like the original. The algorithm is designed to be a one- way function, also meaning irreversible. The encrypted string will also change drastically if a single bit of the data is modified in the file. The modulo of the function is a prime number which makes sure that the values are within the range of the length of the SHA1 hashed string, it also allows the use of modular square root and modular multiplicative inverse mathematics making it easier to calculate things. Since we have mod p , it means that the possible values of y 2 is between 0 and p – 1, thus giving us p total possible values. Since only integers are being used, a smaller subset of the total possible values will be a perfect square, which gives us N possible points on the curve where N < p , where N is the number of perfect squares between 0 and p . The next step is point addition, where adding point P + Q it will intersect the curve at point S (labelled P + Q below), and a third value at point R (negative S, R = -S).

183

Made with FlippingBook Digital Publishing Software