@@ -39,11 +39,12 @@ describe("Phase", () => {
3939 } ) ;
4040
4141 describe ( "Encryption" , ( ) => {
42+ const APP_ID =
43+ "phApp:v1:cd2d579490fd794f1640590220de86a3676fa7979d419056bc631741b320b701" ;
44+ const APP_SECRET =
45+ "pss:v1:a7a0822aa4a4e4d37919009264200ba6ab978d92c8b4f7db5ae9ce0dfaf604fe:801605dfb89822ff52957abe39949bcfc44b9058ad81de58dd54fb0b110037b4b2bbde5a1143d31bbb3895f72e4ee52f5bd:625d395987f52c37022063eaf9b6260cad9ca03c99609213f899cae7f1bb04e7" ;
46+
4247 test ( "Check if Phase encrypt returns a valid ph" , async ( ) => {
43- const APP_ID =
44- "phApp:v1:cd2d579490fd794f1640590220de86a3676fa7979d419056bc631741b320b701" ;
45- const APP_SECRET =
46- "pss:v1:a7a0822aa4a4e4d37919009264200ba6ab978d92c8b4f7db5ae9ce0dfaf604fe:801605dfb89822ff52957abe39949bcfc44b9058ad81de58dd54fb0b110037b4b2bbde5a1143d31bbb3895f72e4ee52f5bd:625d395987f52c37022063eaf9b6260cad9ca03c99609213f899cae7f1bb04e7" ;
4748 const phase = new Phase ( APP_ID , APP_SECRET ) ;
4849 const plaintext = "Signal" ;
4950 const tag = "Phase Tag" ;
@@ -59,6 +60,20 @@ describe("Phase", () => {
5960 expect ( segments [ 2 ] ) . toMatch ( / ^ [ 0 - 9 a - f ] + $ / ) ;
6061 expect ( segments [ 3 ] ) . toMatch ( / ^ [ 0 - 9 a - f ] + $ / ) ;
6162 } ) ;
63+
64+ test ( "Check if Phase encrypt always produces ciphertexts (ph:*) of the same length for the same plaintext" , async ( ) => {
65+ const phase = new Phase ( APP_ID , APP_SECRET ) ;
66+ const data = "hello world" ;
67+ const numOfTrials = 10 ;
68+ const ciphertextLengths = new Set < number > ( ) ;
69+
70+ for ( let i = 0 ; i < numOfTrials ; i ++ ) {
71+ const ciphertext = await phase . encrypt ( data ) ;
72+ ciphertextLengths . add ( ( ciphertext as string ) . length ) ;
73+ }
74+
75+ expect ( ciphertextLengths . size ) . toBe ( 1 ) ;
76+ } ) ;
6277 } ) ;
6378
6479 describe ( "Decryption" , ( ) => {
0 commit comments