-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add IUdpEncryption API for test (#504)
Summary: Pull Request resolved: #504 Adding an abstract interface for UDP encryption. This allows adding a mock later for this interface Reviewed By: adshastri Differential Revision: D43576519 Privacy Context Container: L416713 fbshipit-source-id: 32191957d42eeb3cd346db61dd31f535cb008173
- Loading branch information
1 parent
f2bae56
commit 82b475e
Showing
3 changed files
with
66 additions
and
14 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
fbpcf/mpc_std_lib/unified_data_process/data_processor/IUdpEncryption.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <emmintrin.h> | ||
#include <cstddef> | ||
#include <vector> | ||
|
||
namespace fbpcf::mpc_std_lib::unified_data_process::data_processor { | ||
|
||
/** | ||
* This is merely an interface to accommodate mocking for test. | ||
**/ | ||
class IUdpEncryption { | ||
public: | ||
virtual ~IUdpEncryption() = default; | ||
|
||
virtual void prepareToProcessMyData(size_t myDataWidth) = 0; | ||
|
||
/** | ||
* Process my data via UDP encryption. This API should be called in coordinate | ||
* with "ProcessPeerData" on peer's side. If this API is ever called, calling | ||
* "getExpandedKey" to retrieve the expanded key for decryption later. | ||
*/ | ||
virtual void processMyData( | ||
const std::vector<std::vector<unsigned char>>& plaintextData) = 0; | ||
|
||
virtual std::vector<__m128i> getExpandedKey() = 0; | ||
|
||
virtual void prepareToProcessPeerData( | ||
size_t peerDataWidth, | ||
const std::vector<int32_t>& indexes) = 0; | ||
|
||
/* | ||
* process peer data via UDP encryption. This API should be called in | ||
* coordinate with "ProcessMyData" on peer's side. This API is ever | ||
* called, calling "getProcessedData" to retrive the cherry-picked | ||
* encryption later. | ||
*/ | ||
virtual void processPeerData(size_t dataSize) = 0; | ||
|
||
struct EncryptionResuts { | ||
std::vector<std::vector<unsigned char>> ciphertexts; | ||
std::vector<__m128i> nonces; | ||
std::vector<int32_t> indexes; | ||
}; | ||
|
||
// returning the ciphertext, nonce, and index of cherry-picked rows | ||
virtual EncryptionResuts getProcessedData() = 0; | ||
}; | ||
|
||
} // namespace fbpcf::mpc_std_lib::unified_data_process::data_processor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters