@@ -70,6 +70,57 @@ describe('transaction-factory', () => {
70
70
) . toBe ( true ) ;
71
71
} , 10000 ) ;
72
72
73
+ it ( 'can create encrypted transaction with EthereumPrivateKeyCipherProvider' , async ( ) => {
74
+ const encryptedTx = await TransactionsFactory . createEncryptedTransactionInNewChannel (
75
+ data ,
76
+ [
77
+ TestData . idRaw1 . encryptionParams ,
78
+ TestData . idRaw2 . encryptionParams ,
79
+ TestData . idRaw3 . encryptionParams ,
80
+ ] ,
81
+ TestData . fakeEpkCipherProvider ,
82
+ ) ;
83
+ // eslint-disable-next-line no-magic-numbers
84
+
85
+ if ( encryptedTx . encryptedData ) {
86
+ // eslint-disable-next-line no-magic-numbers
87
+ // 'encryptedData not right'
88
+ expect ( encryptedTx . encryptedData . length ) . toBe ( 126 ) ;
89
+ // 'encryptedData not right'
90
+ expect ( encryptedTx . encryptedData . slice ( 0 , 2 ) ) . toEqual (
91
+ MultiFormatTypes . prefix . AES256_GCM_ENCRYPTED ,
92
+ ) ;
93
+ } else {
94
+ fail ( 'encryptedData should not be undefined' ) ;
95
+ }
96
+
97
+ // 'encryptionMethod not right'
98
+ expect ( encryptedTx . encryptionMethod ) . toEqual (
99
+ `${ EncryptionTypes . METHOD . ECIES } -${ EncryptionTypes . METHOD . AES256_GCM } ` ,
100
+ ) ;
101
+
102
+ // 'keys not right'
103
+ expect ( Object . keys ( encryptedTx . keys || { } ) . length ) . toEqual ( 3 ) ;
104
+ // 'keys not right'
105
+ expect ( Object . keys ( encryptedTx . keys || { } ) ) . toEqual ( [
106
+ MultiFormat . serialize ( TestData . idRaw1 . identity ) ,
107
+ MultiFormat . serialize ( TestData . idRaw2 . identity ) ,
108
+ MultiFormat . serialize ( TestData . idRaw3 . identity ) ,
109
+ ] ) ;
110
+
111
+ // 'encrypted keys looks wrong'
112
+ expect (
113
+ // eslint-disable-next-line no-magic-numbers
114
+ Object . values ( encryptedTx . keys || { } ) . every ( ( ek ) => ek . length === 260 ) ,
115
+ ) . toBe ( true ) ;
116
+ // 'encrypted keys looks wrong'
117
+ expect (
118
+ Object . values ( encryptedTx . keys || { } ) . every (
119
+ ( ek ) => ek . slice ( 0 , 2 ) === MultiFormatTypes . prefix . ECIES_ENCRYPTED ,
120
+ ) ,
121
+ ) . toBe ( true ) ;
122
+ } , 10000 ) ;
123
+
73
124
it ( 'can create encrypted transaction with Lit Protocol' , async ( ) => {
74
125
const encryptedTx = await TransactionsFactory . createEncryptedTransactionInNewChannel (
75
126
data ,
0 commit comments