-
Notifications
You must be signed in to change notification settings - Fork 58
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
Naor-Pinkas Base OT optimization with elliptic curves #378
Conversation
acdb912
to
e4423cb
Compare
e4423cb
to
63ddfd8
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.
Thanks for your PR! It looks great but we have a few comments - both on smaller issues and a few larger ones. My main concern is that the old OT seems to disappear - do you think it's possible to retain the original OT and add yours as a new one to optionally use?
core/src/main/java/dk/alexandra/fresco/framework/util/ByteAndBitConverter.java
Outdated
Show resolved
Hide resolved
tools/ot/src/main/java/dk/alexandra/fresco/tools/ot/base/BigIntElement.java
Outdated
Show resolved
Hide resolved
tools/ot/src/main/java/dk/alexandra/fresco/tools/ot/base/BouncyCastleECCElement.java
Outdated
Show resolved
Hide resolved
tools/ot/src/main/java/dk/alexandra/fresco/tools/ot/base/ECCelerateElement.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
} | ||
package dk.alexandra.fresco.suite.tinytables.ot; |
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 you have committed files with a different line? It's odd that the diff insists that you changed all lines in the files
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.
I think that was a problem with the line seperators, should be fixed now
import dk.alexandra.fresco.tools.ot.base.AbstractNaorPinkasOT; | ||
import dk.alexandra.fresco.tools.ot.base.BouncyCastleNaorPinkas; | ||
|
||
public class TinyTablesNaorPinkasOt implements TinyTablesOt { |
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.
Could you implement your OT as a new OT and keep the old TinyTablesNaorPinkasOt?
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.
TinyTablesNaorPinkasOt uses stillt the old Naor Pinkas Implementation, just with the new name (BigIntNaorPinkas)
} | ||
|
||
@Override | ||
public InterfaceNaorPinkasElement groupOp(InterfaceNaorPinkasElement other) { |
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.
I think this could be done more elegantly by adding a generic parameter to InterfaceNaorPinkasElement to avoid type casting
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.
Now uses templates, no cast needed anymore
@@ -229,8 +226,7 @@ private Drbg getDrbg(int myId, int prgSeedLength) { | |||
Map<Integer, RotList> seedOts = new HashMap<>(); | |||
for (int otherId = 1; otherId <= parties; otherId++) { | |||
if (myId != otherId) { | |||
DHParameterSpec dhSpec = DhParameters.getStaticDhParams(); | |||
Ot ot = new NaorPinkasOt(otherId, drbg, network, dhSpec); | |||
AbstractNaorPinkasOT ot = new BigIntNaorPinkas(otherId, drbg, network); |
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.
BigIntNaorPinkas has the same functionality as the old NaorPinkasOt.
The name is just different to differentiate between different NaorPinkas implementations.
Class clazz = this.testClass; | ||
Constructor[] constructors = clazz.getConstructors(); | ||
Ot otSender = (AbstractNaorPinkasOT) constructors[0] | ||
.newInstance(2, rand, network); |
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.
Used to get the constructor via reflection. Is not the most beautiful solution, but the best I could come up with without changing too much of the existing code
Codecov Report
@@ Coverage Diff @@
## master #378 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 3598 3618 +20
===========================================
Files 404 408 +4
Lines 10177 10209 +32
Branches 776 776
===========================================
+ Hits 10177 10209 +32
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Thanks for the review!
The old one doesn't disappear (at least not the functionality), I just refactored it and it is now just called BigIntNaorPinkas. If you don't want the version using elliptic curves, just use that one. |
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.
Looks good, but I think in general it is better to switch to Curve25519 as it is generally regarded as safer.
public void createElement() { | ||
Long baseNumber = 2L; | ||
MersennePrimeFieldDefinition fieldDefintion = new MersennePrimeFieldDefinition(4, 2); | ||
MersennePrimeFieldElement elementFromString = (MersennePrimeFieldElement) fieldDefintion.createElement(baseNumber.toString()); |
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.
I think something should be checked here since the code coverage says that not all versions FieldDefintion.createElement
gets called.
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.
No idea why that is, as highlighted from you, it is called and should therefore be in the code coverage
tools/ot/src/main/java/dk/alexandra/fresco/tools/ot/base/BouncyCastleNaorPinkas.java
Outdated
Show resolved
Hide resolved
tools/ot/src/main/java/dk/alexandra/fresco/tools/ot/base/BouncyCastleNaorPinkas.java
Outdated
Show resolved
Hide resolved
…tleNaorPinkas to only use one ECPoint import
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.
Looks good! Thanks a lot for your contribution!
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.
Okay, I was a bit too quick approving. I see the build service has an issue building the project. It gi ved the following error /home/runner/work/fresco/fresco/core/src/test/java/dk/alexandra/fresco/framework/builder/numeric/field/MersennePrimeFieldDefinitionTest.java:[36,39] error: cannot find symbol
However, I did not have that issue when running the branch locally.
Comparing it with what is shown here at GitHub it seems that there is an a weird whitespace symbol on this line. I tries to fix it but I am not authorised to push to your branch.
I also didnt have the problem locally. I also dont see the whitespace problem, but I hope I fixed it. |
I tried running the github actions on a different branch on my repository, and there I didn't get the error |
I haven't run the code myself, but I think it's because the extractValue method on FieldElement was renamed to toBigInteger in september last year: f128d39 |
Looks good. Thanks for your contribution :) |
1 similar comment
Looks good. Thanks for your contribution :) |
Closes #375
This PR optimizes the base Naor-Pinkas OT through the use of elliptic curves.
For this the curve p-256 is used (but can be changed easily).
The PR adds 3 new optional dependencies to the ot submodule.
1 For bouncy castle,
2 for the use of the commercial ECCelerate Library.
These dependencies are optional, the dependency and the corresponding files can be deleted if they are not wanted.
But at least one of those two is needed to use the optimization.