@@ -37,8 +37,7 @@ namespace electionguard
3737 // / <Summary>
3838 // / Make an elgamal keypair from a secret.
3939 // / </Summary>
40- static std::unique_ptr<ElGamalKeyPair> fromSecret (const ElementModQ &secretKey,
41- bool isFixedBase = true );
40+ static std::unique_ptr<ElGamalKeyPair> fromSecret (const ElementModQ &secretKey, bool isFixedBase = true );
4241
4342 private:
4443 class Impl ;
@@ -132,18 +131,23 @@ namespace electionguard
132131 // / <returns>A ciphertext tuple.</returns>
133132 // / </summary>
134133 EG_API std::unique_ptr<ElGamalCiphertext>
135- elgamalEncrypt_with_precomputed (uint64_t m, ElementModP &gToRho , ElementModP &pubkeyToRho);
134+ elgamalEncrypt_with_precomputed (uint64_t m, ElementModP &gToRho ,
135+ ElementModP &pubkeyToRho);
136136 // / <summary>
137137 // / Accumulate the ciphertexts by adding them together.
138138 // / </summary>
139139 EG_API std::unique_ptr<ElGamalCiphertext>
140140 elgamalAdd (const std::vector<std::reference_wrapper<ElGamalCiphertext>> &ciphertexts);
141141
142- #define HASHED_CIPHERTEXT_BLOCK_LENGTH 32U
143- #define _PAD_INDICATOR_SIZE sizeof (uint16_t )
142+ #define HASHED_CIPHERTEXT_BLOCK_LENGTH 32U
143+ #define _PAD_INDICATOR_SIZE sizeof (uint16_t )
144144
145145 typedef enum padded_data_size_e {
146146 NO_PADDING = 0 ,
147+ BYTES_32 = 32 - _PAD_INDICATOR_SIZE,
148+ BYTES_64 = 64 - _PAD_INDICATOR_SIZE,
149+ BYTES_128 = 128 - _PAD_INDICATOR_SIZE,
150+ BYTES_256 = 256 - _PAD_INDICATOR_SIZE,
147151 BYTES_512 = 512 - _PAD_INDICATOR_SIZE
148152 } padded_data_size_t ;
149153
@@ -155,7 +159,7 @@ namespace electionguard
155159 // / result. Create one with `hashedElgamalEncrypt`. Decrypt using one the
156160 // / 'decrypt' method.
157161 // / </summary>
158- class EG_API HashedElGamalCiphertext : public CryptoHashable
162+ class EG_API HashedElGamalCiphertext
159163 {
160164 public:
161165 HashedElGamalCiphertext (const HashedElGamalCiphertext &other);
@@ -203,17 +207,14 @@ namespace electionguard
203207 // / </Summary>
204208 std::vector<uint8_t > getMac () const ;
205209
206- virtual std::unique_ptr<ElementModQ> crypto_hash () override ;
207- virtual std::unique_ptr<ElementModQ> crypto_hash () const override ;
208-
209210 // / <summary>
210211 // / Decrypts ciphertext with the Auxiliary Encryption method (as specified in the
211212 // / ElectionGuard specification) given a random nonce, an ElGamal public key,
212213 // / and a description hash. The encrypt may be called to look for padding to
213214 // / verify and remove, in this case the plaintext will be smaller than
214215 // / the ciphertext, or not to look for padding in which case the
215- // / plaintext will be the same size as the ciphertext.
216- // /
216+ // / plaintext will be the same size as the ciphertext.
217+ // /
217218 // / <param name="nonce"> Randomly chosen nonce in [1,Q). </param>
218219 // / <param name="publicKey"> ElGamal public key. </param>
219220 // / <param name="descriptionHash"> Hash of the ballot description. </param>
@@ -231,7 +232,7 @@ namespace electionguard
231232 private:
232233 class Impl ;
233234#pragma warning(suppress : 4251)
234- std::unique_ptr<Impl> pimpl;
235+ std::unique_ptr<Impl> pimpl;
235236 };
236237
237238 // / <summary>
@@ -243,32 +244,24 @@ namespace electionguard
243244 // / This value indicates the maximum length of the plaintext that may be
244245 // / encrypted. The padding scheme applies two bytes for length of padding
245246 // / plus padding bytes. If padding is not to be applied then the
246- // / max_len parameter must be NO_PADDING. and the plaintext must
247+ // / max_len parameter must be NO_PADDING and the plaintext must
247248 // / be a multiple of the block length (32) and the ciphertext will be
248- // / the same size. If the max_len is set to something other than
249- // / NO_PADDING and the allow_truncation parameter is set to
250- // / true then if the message parameter data is longer than
251- // / max_len then it will be truncated to max_len. If the max_len is set to
252- // / something other than NO_PADDING and the allow_truncation parameter
253- // / is set to false then if the message parameter data is longer than
254- // / max_len then an exception will be thrown.
249+ // / the same size.
255250 // /
256- // / <param name="message "> Message to hashed elgamal encrypt. </param>
251+ // / <param name="plaintext "> Message to hashed elgamal encrypt. </param>
257252 // / <param name="nonce"> Randomly chosen nonce in [1,Q). </param>
258253 // / <param name="publicKey"> ElGamal public key. </param>
259254 // / <param name="descriptionHash"> Hash of the ballot description. </param>
260255 // / <param name="max_len"> If padding is to be applied then this indicates the
261256 // / maximum length of plaintext, must be one padded_data_size_t enumeration
262257 // / values. If padding is not to be applied then this parameter must use
263258 // / the NO_PADDING padded_data_size_t enumeration value.</param>
264- // / <param name="allow_truncation"> Truncates data to the max_len if set to
265- // / true. If max_len is set to NO_PADDING then this parameter is ignored. </param>
266259 // / <returns>A ciphertext triple.</returns>
267260 // / </summary>
268261 EG_API std::unique_ptr<HashedElGamalCiphertext>
269262 hashedElgamalEncrypt (std::vector<uint8_t > plaintext, const ElementModQ &nonce,
270263 const ElementModP &publicKey, const ElementModQ &descriptionHash,
271- padded_data_size_t max_len, bool allow_truncation );
264+ padded_data_size_t max_len);
272265
273266} // namespace electionguard
274267
0 commit comments