{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "wocBrqRCifQA", "outputId": "489980ff-edec-49ef-dc7a-c2036a459211" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "The private key of Lisa: 7\n", "The private key of Taylor: 6\n", "The secret key of Lisa: 11\n", "The secret key of Taylor: 11\n" ] } ], "source": [ "from random import randint\n", "p = 37\n", "g = 5\n", "a = 7\n", "b = 6\n", "x = int(pow(g, a, p))\n", "y = int(pow(g, b, p))\n", "ka = int(pow(y, a, p))\n", "kb = int(pow(x, b, p))\n", "print(\"The private key of Lisa:\", a)\n", "print(\"The private key of Taylor:\", b)\n", "print(\"The secret key of Lisa:\", ka)\n", "print(\"The secret key of Taylor:\", kb)" ] } ] }