-
- Notifications
You must be signed in to change notification settings - Fork 49.3k
Add garbled circuit and oblivious transfer #6042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ghost left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| from hashes.sha256 import SHA256 | ||
| | ||
| | ||
| def _generate_key(key_size: int) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/secure_computation/garble_circuit.py, please provide doctest for the function _generate_key
| return random.randrange(2 ** (key_size - 1), 2 ** (key_size)) | ||
| | ||
| | ||
| def _generate_label(label_size: int) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/secure_computation/garble_circuit.py, please provide doctest for the function _generate_label
| return random.randrange(2 ** (label_size - 1), 2 ** (label_size)) | ||
| | ||
| | ||
| def _enc(key: int, key_size: int = 128) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/secure_computation/garble_circuit.py, please provide doctest for the function _enc
| return int(SHA256(bytes(key)).hash, 16) % (2**key_size) | ||
| | ||
| | ||
| def _encrypt(keys: list[int], salt: int, secret: int, key_size: int = 128) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/secure_computation/garble_circuit.py, please provide doctest for the function _encrypt
| return _enc(key, key_size) ^ key ^ secret | ||
| | ||
| | ||
| def _decrypt( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/secure_computation/garble_circuit.py, please provide doctest for the function _decrypt
| self.random_messages = tuple(random.randrange(n) for _ in self._secret) | ||
| return self.random_messages | ||
| | ||
| def encrypt_secret(self, encrypted_choice: int) -> tuple[int, ...]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/transfer_protocol/oblivious_transfer.py, please provide doctest for the function encrypt_secret
| | ||
| | ||
| class Receiver: | ||
| def set_choice(self, index: int) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/transfer_protocol/oblivious_transfer.py, please provide doctest for the function set_choice
| def set_choice(self, index: int) -> None: | ||
| self._choice = index | ||
| | ||
| def encrypt_choice( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/transfer_protocol/oblivious_transfer.py, please provide doctest for the function encrypt_choice
| random_messages[self._choice] + self._salt**e | ||
| ) % n # Encrypt the salt and blind with the selected random message | ||
| | ||
| def decrypt_secret(self, encrypted_secrets: tuple[int, ...]) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/transfer_protocol/oblivious_transfer.py, please provide doctest for the function decrypt_secret
| ) # Unblind the secret with the salt | ||
| | ||
| | ||
| def main(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no test file in this pull request nor any test function or class in the file cryptograpic_algorithms/transfer_protocol/oblivious_transfer.py, please provide doctest for the function main
Please provide return type hint for the function: main. If the function does not return a value, please provide the type hint as: def function() -> None:
| This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
| In preparation for that denial-of-service attack that is Hacktoberfest, I am closing all pull requests that do not have tests. |
Describe your change:
Implement 2 algorithms (one of them is depending on the other).
Checklist:
Fixes: #{$ISSUE_NO}.