-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Implemented Subtraction operation of FV Scheme #3775
Implemented Subtraction operation of FV Scheme #3775
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3775 +/- ##
==========================================
- Coverage 94.76% 94.68% -0.08%
==========================================
Files 186 186
Lines 18477 18571 +94
==========================================
+ Hits 17509 17584 +75
- Misses 968 987 +19
|
return self._add_plain_cipher(op2, op1) | ||
return self._sub_cipher_plain(op1, op2) | ||
|
||
elif isinstance(op1, PlainText) and isinstance(op2, CipherText): |
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.
Maybe a method for the ifs? to check if both are ciphertexts, different or throw exception.
to reduce the duplicated code.
class ParamTypes(Enum): | ||
"""Enumeration for type checking of parameters. | ||
""" | ||
|
||
CTCT = 1 | ||
PTPT = 2 | ||
CTPT = 3 | ||
PTCT = 4 | ||
|
||
|
||
def _typecheck(op1, op2): | ||
"""Check the type of parameters used and return correct enum type.""" | ||
if isinstance(op1, CipherText) and isinstance(op2, CipherText): | ||
return ParamTypes.CTCT | ||
elif isinstance(op1, PlainText) and isinstance(op2, PlainText): | ||
return ParamTypes.PTPT | ||
elif isinstance(op1, CipherText) and isinstance(op2, PlainText): | ||
return ParamTypes.CTPT | ||
elif isinstance(op1, PlainText) and isinstance(op2, CipherText): | ||
return ParamTypes.PTCT | ||
else: | ||
return 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.
@bcebere I have tried to update it as per your review, please check and suggest if anything better can be done 🙂
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.
Maybe throw directly, instead of renurning 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.
But then I would have to remove the name of operation. Can you suggest another error message without operation name.
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.
Just a small comment, otherwise LGTM! Great work!
class ParamTypes(Enum): | ||
"""Enumeration for type checking of parameters. | ||
""" | ||
|
||
CTCT = 1 | ||
PTPT = 2 | ||
CTPT = 3 | ||
PTCT = 4 | ||
|
||
|
||
def _typecheck(op1, op2): | ||
"""Check the type of parameters used and return correct enum type.""" | ||
if isinstance(op1, CipherText) and isinstance(op2, CipherText): | ||
return ParamTypes.CTCT | ||
elif isinstance(op1, PlainText) and isinstance(op2, PlainText): | ||
return ParamTypes.PTPT | ||
elif isinstance(op1, CipherText) and isinstance(op2, PlainText): | ||
return ParamTypes.CTPT | ||
elif isinstance(op1, PlainText) and isinstance(op2, CipherText): | ||
return ParamTypes.PTCT | ||
else: | ||
return 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.
Maybe throw directly, instead of renurning None?
3ea3fc5
to
53392bf
Compare
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.
LGTM! I just put some remarks about docs
ct (Ciphertext): First argument. | ||
pt (Plaintext): Second argument. |
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.
Can you describe what the argument is for the operation here?
ct (Ciphertext): First argument. | ||
pt (Plaintext): Second argument. |
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.
Can you describe what the argument is for the operation here?
ct1 (Ciphertext): First argument. | ||
ct2 (Ciphertext): Second argument. |
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.
Can you describe what the argument is for the operation here?
"""return subtraction of two polynomials with all coefficients of | ||
polynomial %q(coefficient modulus)""" |
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.
Can you describe what the arguments are for the operation here?
Description
closes #3702
Implemented Subtraction operation of the FV scheme.
Can Subtract two ciphertexts or a plaintext from a ciphertext.
Affected Dependencies
None
How has this been tested?
Checklist