@@ -4,19 +4,19 @@ import babyStepGiantStep from "@/algorithms/baby-step-giant-step";
44import euclidean from "@/algorithms/euclidean" ;
55import fastModularExponentiation from "@/algorithms/fast-modular-exponentiation" ;
66import primitiveRootSearch from "@/algorithms/primitive-root-search" ;
7- import { EActors } from "@/shared/constants" ;
7+ import { ACTORS } from "@/shared/constants" ;
88import { log , inquire , wrap } from "@/shared/utilities" ;
99import { randomBigIntBetween } from "@/shared/random" ;
1010
1111export async function prompt ( ) {
1212 try {
1313 console . log ( "There are three people in this ElGamal encryption process:" ) ;
1414 console . log (
15- `\t${ EActors . Alice } - Receiver\n\t${ EActors . Bob } - Sender\n\t${ EActors . Eve } - Eavesdropper` ,
15+ `\t${ ACTORS . ALICE } - Receiver\n\t${ ACTORS . BOB } - Sender\n\t${ ACTORS . EVE } - Eavesdropper` ,
1616 ) ;
1717
1818 const [ p , g , r , x , y ] = await inquire . continue (
19- `${ EActors . Alice } is going to pick prime number P, generator g, and random numbers r and x:` ,
19+ `${ ACTORS . ALICE } is going to pick prime number P, generator g, and random numbers r and x:` ,
2020 ( ) => {
2121 const [ p ] = wrap . randomize ( 8 , 8 , 1 ) ;
2222 const [ , roots ] = primitiveRootSearch ( Number ( p ) ) ;
@@ -34,14 +34,14 @@ export async function prompt() {
3434 { name : "x" , value : x } ,
3535 ] ) ;
3636
37- console . log ( `\n\t${ EActors . Alice } generates y:` ) ;
37+ console . log ( `\n\t${ ACTORS . ALICE } generates y:` ) ;
3838 const y = fastModularExponentiation ( g , x , p ) ;
3939 console . log ( `\ty: ${ chalk . gray ( y ) } ` ) ;
4040
4141 console . log (
42- `\n\t${ EActors . Alice } sends ${ chalk . bold . bgCyan (
42+ `\n\t${ ACTORS . ALICE } sends ${ chalk . bold . bgCyan (
4343 "(g, r, p, y)" ,
44- ) } as the public key to ${ EActors . Bob } and ${ EActors . Eve } .`,
44+ ) } as the public key to ${ ACTORS . BOB } and ${ ACTORS . EVE } .`,
4545 ) ;
4646
4747 return [ p , g , r , x , y ] ;
@@ -50,7 +50,7 @@ export async function prompt() {
5050
5151 const message = "This is a hardcoded secret message." ;
5252 const [ keyEncrypted , arrayOfEncryptedCode ] = await inquire . continue (
53- `${ EActors . Bob } encrypts the message and sends it back to ${ EActors . Alice } (while ${ EActors . Eve } is eavesdropping).` ,
53+ `${ ACTORS . BOB } encrypts the message and sends it back to ${ ACTORS . ALICE } (while ${ ACTORS . EVE } is eavesdropping).` ,
5454 ( ) => {
5555 const keyEncrypted = fastModularExponentiation ( g , r , p ) ;
5656 const sharedSecret = fastModularExponentiation ( y , r , p ) ;
@@ -70,21 +70,21 @@ export async function prompt() {
7070 ) ;
7171 console . log (
7272 `\n\t${
73- EActors . Alice
73+ ACTORS . ALICE
7474 } can decrypt the message since she has the random number ${ chalk . bold . bgCyan (
7575 "(x)" ,
7676 ) } .\n\tDecrypted message: ${ chalk . gray ( messageDecrypted ) } \n\t${
77- EActors . Alice
78- } verifies the message with ${ EActors . Bob } privately.`,
77+ ACTORS . ALICE
78+ } verifies the message with ${ ACTORS . BOB } privately.`,
7979 ) ;
8080 return [ keyEncrypted , arrayOfEncryptedCode ] ;
8181 } ,
8282 ) ;
8383
8484 await inquire . continue (
85- `${ EActors . Eve } is going to decrypt the secret message.` ,
85+ `${ ACTORS . EVE } is going to decrypt the secret message.` ,
8686 ( ) => {
87- console . log ( `\tNow ${ EActors . Eve } has the following stuff:` ) ;
87+ console . log ( `\tNow ${ ACTORS . EVE } has the following stuff:` ) ;
8888 log . list ( [
8989 { name : "g" , value : g } ,
9090 { name : "r" , value : r } ,
@@ -95,7 +95,7 @@ export async function prompt() {
9595 ] ) ;
9696
9797 console . log (
98- `\n\t${ EActors . Eve } is going to figure out what the random number x is using Discrete Log with the information she has.` ,
98+ `\n\t${ ACTORS . EVE } is going to figure out what the random number x is using Discrete Log with the information she has.` ,
9999 ) ;
100100
101101 const xEavesdropped = babyStepGiantStep ( g , y , p ) ;
@@ -118,8 +118,8 @@ export async function prompt() {
118118 ) ;
119119 console . log (
120120 `\tDecrypted message: ${ chalk . gray ( messageEavesdropped ) } \n\t${
121- EActors . Eve
122- } verifies the message with ${ EActors . Bob } .`,
121+ ACTORS . EVE
122+ } verifies the message with ${ ACTORS . BOB } .`,
123123 ) ;
124124 } ,
125125 ) ;
0 commit comments