Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168732
Image: ubuntu2004
# Diffie-Helmann Key Exchange Protocol: # how to exchange a secret number over insecure channels # Alice and Bob agree on a large prime p and a primitive root, r, modulo p. This information is public. # I am Alice. You are Bob. # We agree that p will be: p = next_prime(19648400) p
19648459
# And we ask sage to find a primitive root for us: r = primitive_root(p) r
2
# Let's exchange a secret number. Your assignment is to send me the numbers B and C defined as follows. # How to use sage: # click on each cell. # a blue "evaluate" appears beneath it. # click on "evaluate" to evaluate the cell.
# Alice chooses a secret random integer a (1 < a < p-1) and sends A = r^a mod p to Bob. # a = ??? # A = power_mod(r, a, p) A = 17525235
# Bob chooses a secret random integer b (1 < b < p-1) and sends B = r^b mod p to Alice. # b = pick a number, any number, fill in the blank below: b = B = power_mod(r, b, p) B # Give me B.
# Alice knows B. She computes B^a mod p. # C = power_mod(B, a, p)
# Bob knows A. He computes A^b mod p. C = power_mod(A, b, p) # C is the secret number shared by both Alice and Bob. # Give me C.