@@ -4,9 +4,11 @@ import {
44 ciphertext ,
55 formPublicKey ,
66 formSecretKey ,
7- submissionSecretKey
7+ submissionSecretKey ,
8+ plainVerifiedText
89} from './resources/crypto-v3-data-20231207'
910import CryptoV3 from '../src/crypto-v3'
11+ import Crypto from '../src/crypto'
1012
1113const INTERNAL_TEST_VERSION = 3
1214
@@ -18,6 +20,7 @@ describe('CryptoV3', function () {
1820 afterEach ( ( ) => mockAxios . reset ( ) )
1921
2022 const crypto = new CryptoV3 ( )
23+ const cryptoV1 = new Crypto ( )
2124
2225 it ( 'should generate a keypair' , ( ) => {
2326 const keypair = crypto . generate ( )
@@ -126,4 +129,22 @@ describe('CryptoV3', function () {
126129
127130 expect ( decrypted ) . toBeNull ( )
128131 } )
132+
133+ it ( 'should be able to encrypt and decrypt submissions with verifiedContent from 2023-12-07 end-to-end successfully from the form private key' , ( ) => {
134+ // Arrange
135+ const { publicKey, secretKey } = crypto . generate ( )
136+
137+ // Act
138+ const ciphertext = crypto . encrypt ( plaintext , publicKey )
139+ const verifiedText = cryptoV1 . encrypt ( plainVerifiedText , publicKey )
140+ const decrypted = crypto . decrypt ( secretKey , {
141+ ...ciphertext ,
142+ verifiedContent : verifiedText ,
143+ version : INTERNAL_TEST_VERSION ,
144+ } )
145+ // Assert
146+ expect ( decrypted ) . toHaveProperty ( 'responses' , plaintext )
147+ expect ( decrypted ) . toHaveProperty ( 'verified' , plainVerifiedText )
148+
149+ } )
129150} )
0 commit comments