April 4, 2023
Math 302 Cryptography
Spring 2023

T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

SHA3-256 in Mathematica - Reminder from the fall

The command Hash[ x, “SHA3-256”] will apply the SHA3-256 hash function to the message x. 
If x is a string, then Mathematica will covert each letter to its UTF-8 representation. 

For example,

Hash["https://www.youtube.com/watch?v=oHg5SJYRHA0", "SHA3-256"]

Using Solve[ ] to retrieve the y-coordinates on an elliptic curve

If we know the x-value of a point on an elliptic curve, then we can find the y-values using Mathematica’s Solve[ ] command. 

For example, to find the y-values on E: Y^2 = X^3 + 4X + 56 over F_101 corresponding to x=42, we can use

Solve[y^2== 42^3 + 4*42+56, Modulus->101]

ECDSA example from class

Trusted Party publishes (p, A, B, G, q) = (101, 4, 56, (3,14), 89)

Sign the message “https://www.youtube.com/watch?v=oHg5SJYRHA0”
using secret key s=23 and ephemeral e=59

p=101; a=4;b=46; G={3,14}; q=89;
d=Hash["https://www.youtube.com/watch?v=oHg5SJYRHA0", "SHA3-256"]

Using http://www.christelbach.com/eccalculator.aspx

If we pick s=23 then V=sG=(37,85)
                     e=59 then eG=(85, 80)

s=23;
e=59;
s1=Mod[85,q]
s2= Mod[ (d+s * s1)* PowerMod[e,-1,q],q]

Thus, we would send (“https://www.youtube.com/watch?v=oHg5SJYRHA0”,  (85,8) )

The receiver would verify by calculating

s1=85;s2=8;
d=Hash["https://www.youtube.com/watch?v=oHg5SJYRHA0","SHA3-256"]
v1 = Mod[ d * PowerMod[s2,-1,q],q]
v2 = Mod[ s1 * PowerMod[s2,-1,q],q]

Now let’s use http://www.christelbach.com/eccalculator.aspx  to compute

v =   v1 G + v2 V 
   = 26 (3,14) + 44 (37,85)
   = (61,43) + (87,36)
   = (85, 80)
   
   And x(v) = s1   !   Woot!

Messages for In-Class Work

d1aMessage="Whoever invented stew was a genius. I mean, it's got milk in it, but it still tastes good."
d1bMessage="Someone hit the big score. They figured it out, that we're gonna do it anyway, even if doesn't pay."
d2Message="Give him some space, and let him do his thing. Make him feel safe, and listen to him sing."