-
Notifications
You must be signed in to change notification settings - Fork 55
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
Mascot preprocessing #214
Merged
Merged
Mascot preprocessing #214
Changes from all commits
Commits
Show all changes
527 commits
Select commit
Hold shift + click to select a range
475d7e6
Merging fun
n1v0lg ef1ae3b
Use new network constructor in demo
n1v0lg 80fea70
Changed names so it is not implied to be secure, rather a subsystem i…
pffrandsen 6410b47
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 5a75335
Fixed visibilty
pffrandsen 0fb5f37
Removed unneeded getmod
pffrandsen 0b0ef78
Renamed FrescoSerializer to ByteSerializer
pffrandsen f6d6130
Encapsulated fields
pffrandsen d1ef72c
Remove dead code and outdated TODOs
n1v0lg 2628bad
Don't package mascot
n1v0lg cddf71b
Killed some unused imports
n1v0lg 77293d3
Merge branch 'develop' into mascot-preprocessing
441faf1
Better naming
pffrandsen a4b0f7f
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen fee5111
Smaller, co-prime modulus for spdz-mascot tests
n1v0lg d29319b
Nice prime
n1v0lg c885ef0
Mascot input mask gen
n1v0lg ab27b7e
Spdz input mask tests
n1v0lg cde82cd
Use random element gen in supplier
n1v0lg 521683f
Fixed class cast exception
pffrandsen 3017f70
Mindre netværk i test
pffrandsen 2be3d88
Removed dummy override version
pffrandsen eba224d
Spdz is always spdz
pffrandsen a33e9d0
Spdz is always spdz
pffrandsen 0dc900b
Added javadoc and used the interface where intended
pffrandsen 39c9d0e
Excessive logging removed and cleanup of BatchedProtocolEvaluator
pffrandsen 9f0aa75
Changed loglevel for triplework
pffrandsen bcc7f97
Cleaned javadoc
pffrandsen e5664d7
Code style fixed
pffrandsen 1e71e63
Trivial optimization
pffrandsen f49ce5a
JAvadoc
pffrandsen a695da0
Tried to remove dependency on scapi, no longer needed with OT fully i…
pffrandsen d6843a3
Reverted
pffrandsen 2bec9f7
intellij code style
n1v0lg 7764a89
Again
n1v0lg ba4cea6
Modulus finder
n1v0lg 53aa0d1
Set bit length on tests
n1v0lg ad1f0dc
Some fixes and tests
n1v0lg 7a268ee
Redundant exceptions removed
pffrandsen 7e4bd14
Equality edge case tests
n1v0lg 2075162
Equality tests for negative numbers
n1v0lg 9ad92d6
Added massive test of Mascot to test it under realistic terms
pffrandsen a766dc8
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen b9ac7c7
Made the invoker busy wait
pffrandsen 25cd81a
Basic style fixes and documentation.
592c79d
Basic style fixes, also computes byte size from bitsize.
8bbe016
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
6fee855
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen b10cd9a
Added progress in the test
pffrandsen b657cbb
Merged with develop. Fixed conflicts
9973510
Changed Spdz mac check and input protocol to throw malicious exceptio…
7dccfbb
Configurable max bit length and mod bit length
n1v0lg 8a61bd5
Bit length params to fix LP
n1v0lg 4d570de
Increase blocking queue size in kry net
n1v0lg 0411b01
Adjust parameters in net manager and parallel mascot test
n1v0lg 3df34e7
Make max len in dummy test suite configurable and tests
n1v0lg 3e787c7
Remove long running mascot LP test
n1v0lg a09619d
Fix modulus finder test
n1v0lg 0c60216
Fixed kryonet test after change to limit within personal queue
70b1cc0
Organized imports.
d768dd2
Moved seed OTs out of extension
jot2re 42ff6d3
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
jot2re 72c079b
Some style and formatting fixes.
8720fb7
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
c14b09a
Some style and comment fixes.
3393d4d
Attempt at fixing the kryonet errors on travis
1767295
Added seedOts to Otextension resources
jot2re 7207137
Unoptimized square root mod p
n1v0lg 76a77ae
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg 0597689
Make exponents ints
n1v0lg 25c401b
Improved coverage
jot2re 78a9a18
Clearned up demo classes
jot2re 8674811
Cleaned up unit tests
jot2re d5a27be
Cleaned up Ot extension test context
jot2re 4200ed7
Partially Cleaned up Bristol OT functest
jot2re d4a348f
Get next bit
n1v0lg a3a723c
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg 8386976
Fixed compile error
jot2re 66b3704
Fix build
n1v0lg 5abc572
Remove old test
n1v0lg 7aad14d
Also remove calls to test
n1v0lg a592856
Move dummy ot back into main and make tests compile
n1v0lg 818d7f3
Added online multiplication protocol
n1v0lg 71701c9
In-mascot random bit generation
n1v0lg d3ed1de
Field element inverse and sqrt tests
n1v0lg 1dbd682
Online multiplication tests
n1v0lg 8e33202
Bit converter tests
n1v0lg afc916a
Correct test name
n1v0lg b545f66
Plug random bit gen into data supplier
n1v0lg ecbe998
Important todo
n1v0lg d76a04c
Fixed some issues with Mascot tests after refactoring
jot2re 14cbe15
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
jot2re 2926656
Fixed triple generation bug
jot2re f7a1bf9
Modulus related test changes and fixes
n1v0lg 8eff04f
Fix online mult protocol
n1v0lg b51e7a3
Kill some sysouts
n1v0lg 72ce3c2
Fixed bit converter protocol
n1v0lg d7c65fb
Refactored code so input and output to protocols are clearly seen
pffrandsen 3b006ea
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 90dd89e
Fix createRot test
n1v0lg 6f51b29
Kill dummy mascot resource poll
n1v0lg 3670904
Cleaned up OT tests
jot2re f664779
Use real ot in demo
n1v0lg 77a1284
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 97a73e4
Changed the test system to fail fast if any thread fails
pffrandsen 316877c
Refactored to be based on Lazy protocol constructions
pffrandsen fd164bc
Fixed OT bug
jot2re 4a35d27
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 1f1a98f
First stab at fixing mascot parallel
n1v0lg d894e9f
Cleaned up OT extension classes
jot2re a706b02
Add seed ot initialization to data supplier
n1v0lg bc8d0e1
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg a5f81d8
Remove slow lt test and adjust params
n1v0lg ff34421
Removed author tag from OT extension files
jot2re 5304bca
Fixed small problem in BristolRotBatch
jot2re 302c1ee
Small readability changes
n1v0lg 582e4d0
Another not equals
n1v0lg 7d2730f
Added description to the MaliciousException class
jot2re df12821
Updated description of the MaliciousException class
jot2re 474d959
Removed usages of MPCException
pffrandsen 2f8b599
Removed deprecated, dangerous, unused methods
pffrandsen 4ddc7ee
Fixed tests
pffrandsen 57beda6
Fix exp pipe test
n1v0lg c6e7acd
Fixed tests
pffrandsen 26ee9fe
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 700f39f
Added another IllegalArugment
pffrandsen 8ef1bfc
Moved ot init out of data supplier
n1v0lg 767ccdf
More illegal args
n1v0lg 8ded3d4
Removed MPC exception and replaced it - best estimate - of either a r…
pffrandsen a565a36
Do not catch exceptions to rethrow them
pffrandsen dafa76b
Temporary ignore test
pffrandsen 9504f54
Removed dead code from BitVector
jot2re 8a9fc0d
Added documentation to BitVector
jot2re 62b4cd8
Move secret-sharing in el gen to match paper
n1v0lg 0ef3293
Adressed review comments in StrictBitVectorSerializer
jot2re 822e277
Clean up padding prg
n1v0lg 6558b52
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg ed39ade
Use serializer instead of toByteArray
n1v0lg be95f5b
Renaming in element generation
n1v0lg 1004436
Removed dead code - round based exceptions never occurs
pffrandsen ed0deb3
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 36a12df
Added tests of error conditions
pffrandsen 7cbc4e1
Remove send and receive diff methods for mult classes
n1v0lg 355d257
Adressed issues with StrictBitVetor
jot2re 433a70b
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
jot2re d834519
Abstract classes where appropriate and docs
n1v0lg e47def4
Removed redundant code
pffrandsen 884bded
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen bf548fe
Cleaned NOT protocol
pffrandsen 8714c68
Added tests to StrictBitVectorSerializer
jot2re 3660d44
Removed redundant code in preprocess AND
pffrandsen 7a3ea70
Cleaned up AND
pffrandsen 4bc08be
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 00db1e6
Docs and clean-up in element generation
n1v0lg ac09a69
Fixed ssk generation in mascot data supplier
n1v0lg ae27bec
Clean-up and document arithmetic collection utils
n1v0lg 08f1df9
Mascot test cov back to 100
n1v0lg 013b563
Reverted changes, the test is written in a broken manner for windows …
pffrandsen 962f22b
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen aa49d75
Reverted changes, the test is written in a broken manner for windows …
pffrandsen 6cf5b41
Refactor multiplication protocols
n1v0lg cf5defc
More multiplication-related clean-up
n1v0lg 7d902d6
Dead code removed
pffrandsen 72f0ce1
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 8edb13d
Add instance id to data supplier
n1v0lg 75a9af3
Add createRot exception test
n1v0lg 87e7df7
Unused import
n1v0lg 8a77b1a
Correct test names
n1v0lg a139279
Refactoring and documentation.
4827507
Update strict bit vector equals method and more tests
n1v0lg 251f992
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
c4f8d58
Data supplier docs
n1v0lg e480087
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
18e2e06
More documentation of el gen and link to paper
n1v0lg 5409fd7
Add refs to paper to el gen
n1v0lg 134c7d4
Rename tests
n1v0lg 3ffb976
Added mechanism for running mac checks during online phase
n1v0lg 5225e32
Clean up broadcast validation
n1v0lg 4bbc40d
More cleanup
n1v0lg 2c47876
Multi-party coin tossing test etc
n1v0lg c4e7bb8
Add prg produces non-zero test etc
n1v0lg d2d95b5
Renamed tests to make codeCov happy
jot2re e24a032
Documented triple generation
n1v0lg 4adac97
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg 3721287
Minor formatting el gen
n1v0lg 6fa0fa0
Various javadoc and refactoring.
8959d7a
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
661ca23
Renamed tests to make codeCov happy
jot2re 8442274
Get rid off numLeftFactors in mult classes
n1v0lg fe39de3
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg 4f9ddc7
Moved multiply classes into triple package
n1v0lg 60bc41b
Formatting javadoc.
d97bbbc
Cleaned up Xor and tiny tables values
pffrandsen b690354
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 09a5e1c
Cleaned up preprocess and tiny tables values
pffrandsen 777058e
Remove party ids
n1v0lg eb0e283
Remove mod bit length from prg
n1v0lg 207793e
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
1dacaf0
Made the dependency on Rot runtime rather than compile time in Bristo…
pffrandsen 37f83f5
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen d67a139
Made the dependency on Rot runtime rather than compile time in BristolOt
pffrandsen 6f5165c
Remove mod bit length argument from field element
n1v0lg 437ba26
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg 75d5f85
Remove bit length from authenticated element
n1v0lg b553665
More reasonable toString methods
n1v0lg 1c536b9
FEUtils clean-up
n1v0lg 4a5bed9
Address more of psn comments
n1v0lg 292824a
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
880ca0f
Fixed compile error.
01e9333
Introduced interfaces to allow users of the framework to change behav…
pffrandsen a77dd25
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 69dbf23
Authenticated element docs
n1v0lg 386af02
otherId now an int
n1v0lg 22a0dda
Removed shared classes and delegation from base protocol
n1v0lg 6ae5248
Remove base and two party protocol
n1v0lg 6b0b324
Handled PFFs comments
jot2re 17bf5b8
First stab at cleaning up mascot res pool
n1v0lg 3352ffd
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg c9ba991
Docs for mascot res pool impl
n1v0lg cb5ed62
Mascot demo
n1v0lg 5f1d1d6
Temp fix for corr error in build
n1v0lg fb3f3a7
Fixed parallel Mascot problem
jot2re c407521
Fix coin tossing double init test
n1v0lg b976d0a
Remove mascot makefile
n1v0lg 3a44eb5
Changed issue with constructor in Naor-Pinkas
jot2re 32c4d6c
Made more variables in NaotPinkasOT
jot2re 6000178
Removed much of the shared classes from OT extension
jot2re a57251a
Use sec params and no of parties in test runtime
n1v0lg 21e9cb2
Added more comments to Naor Pinkas
jot2re 094104c
Added reference to Bristol OT
jot2re bf10664
Fixes to pom
n1v0lg 1c181bf
Merge branch 'mascot-preprocessing' of https://github.com/aicis/fresc…
n1v0lg 2714818
Changed naming of Rot and Cote to contain factory
jot2re 2c242e1
Changed Naor-Pinkas tests to securely generate DH parameters
jot2re c7636d4
Inline private fields
n1v0lg aa33a06
Remove ArithmeticCollectionUtils
n1v0lg dddb173
Minor changed to Bit vector classes according to review comments
jot2re 5451ba6
Fixed merge conflict
jot2re c13540a
Dead code
pffrandsen 5f83849
Merge remote-tracking branch 'origin/mascot-preprocessing' into masco…
pffrandsen 2a93dfd
Dead code
pffrandsen d258a94
final field
pffrandsen 06f4731
Renamed things and added comments to Naor Pinkas OT
jot2re c901c59
Changed Boolean to boolean
jot2re 6bd02da
Minor changes according to review
jot2re 8ad218e
Implement mod finder and misc tests
n1v0lg 3e61953
Removed redundant interface and made the RotFactory the actual (Abstr…
pffrandsen 0515efa
Addresed minor review comments
jot2re faa7e12
Handled minor review comments
jot2re fcc0a55
Added missing parens.
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
core/src/main/java/dk/alexandra/fresco/commitment/HashBasedCommitment.java
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,116 @@ | ||
package dk.alexandra.fresco.commitment; | ||
|
||
import dk.alexandra.fresco.framework.MaliciousException; | ||
import dk.alexandra.fresco.framework.util.Drbg; | ||
import dk.alexandra.fresco.framework.util.ExceptionConverter; | ||
import java.security.MessageDigest; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* Class representing a hash-based commitment. Secure assuming that SHA-256 is a | ||
* random oracle. An instantiated object represents a commitment by itself and | ||
* does <b>not</b> contain any secret information. An object gets instantiated | ||
* by calling the commit command. | ||
* <p> | ||
* The scheme itself is based on the ROM folklore scheme where the message to | ||
* commit to is concatenated with a random string and then hashed. The hash | ||
* digest serves as the commitment itself and the opening is the randomness and | ||
* the message committed to. | ||
* </p> | ||
* | ||
*/ | ||
public class HashBasedCommitment { | ||
|
||
private static final String HASH_ALGORITHM = "SHA-256"; | ||
/** | ||
* The length of the hash digest along with the randomness used. | ||
*/ | ||
public static final int DIGEST_LENGTH = 32; // 256 / 8 bytes | ||
/** | ||
* The actual value representing the commitment. | ||
*/ | ||
private byte[] commitmentVal = null; | ||
private final MessageDigest digest; | ||
|
||
/** | ||
* Constructs a new commitment, not yet committed to any value. | ||
*/ | ||
public HashBasedCommitment() { | ||
digest = ExceptionConverter.safe( | ||
() -> MessageDigest.getInstance(HASH_ALGORITHM), | ||
"Missing secure, hash function which is dependent in this library"); | ||
} | ||
|
||
/** | ||
* Initializes the commitment to commit to a specific value and returns the opening information. | ||
* | ||
* @param rand | ||
* A cryptographically secure randomness generator. | ||
* @param value | ||
* The element to commit to. | ||
* @return The opening information needed to open the commitment. | ||
*/ | ||
public byte[] commit(Drbg rand, byte[] value) { | ||
if (commitmentVal != null) { | ||
throw new IllegalStateException("Already committed"); | ||
} | ||
// Sample a sufficient amount of random bits | ||
byte[] randomness = new byte[DIGEST_LENGTH]; | ||
rand.nextBytes(randomness); | ||
// Construct an array to contain the bytes to hash | ||
byte[] openingInfo = new byte[value.length + randomness.length]; | ||
System.arraycopy(value, 0, openingInfo, 0, value.length); | ||
System.arraycopy(randomness, 0, openingInfo, value.length, | ||
randomness.length); | ||
commitmentVal = digest.digest(openingInfo); | ||
return openingInfo; | ||
} | ||
|
||
/** | ||
* Opens a committed object using information returned from the {@code commit} command. | ||
* | ||
* @param openingInfo | ||
* The data needed to open this given commitment. | ||
* @return The value that was committed to. | ||
*/ | ||
public byte[] open(byte[] openingInfo) { | ||
if (commitmentVal == null) { | ||
throw new IllegalStateException("No commitment to open"); | ||
} | ||
if (openingInfo.length < DIGEST_LENGTH) { | ||
throw new MaliciousException( | ||
"The opening info is too small to be a commitment."); | ||
} | ||
// Hash the opening info and verify that it matches the value stored in | ||
// "commitmentValue" | ||
byte[] digestValue = digest.digest(openingInfo); | ||
if (Arrays.equals(digestValue, commitmentVal)) { | ||
// Extract the randomness and the value committed to from the openingInfo | ||
// The value comes first | ||
byte[] value = new byte[openingInfo.length - DIGEST_LENGTH]; | ||
System.arraycopy(openingInfo, 0, value, 0, value.length); | ||
return value; | ||
} else { | ||
throw new MaliciousException("The opening info does not match the commitment."); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the byte array value that is the actual commitment. | ||
* | ||
* @return the byte array commitment | ||
*/ | ||
byte[] getCommitmentValue() { | ||
return commitmentVal; | ||
} | ||
|
||
/** | ||
* Sets the commitment value. | ||
* | ||
* @param commitmentValue | ||
* the commitment value | ||
*/ | ||
void setCommitmentValue(byte[] commitmentValue) { | ||
this.commitmentVal = commitmentValue; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
core/src/main/java/dk/alexandra/fresco/commitment/HashBasedCommitmentSerializer.java
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,63 @@ | ||
package dk.alexandra.fresco.commitment; | ||
|
||
import dk.alexandra.fresco.framework.network.serializers.ByteSerializer; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class HashBasedCommitmentSerializer implements ByteSerializer<HashBasedCommitment> { | ||
|
||
@Override | ||
public byte[] serialize(HashBasedCommitment comm) { | ||
return comm.getCommitmentValue(); | ||
} | ||
|
||
@Override | ||
public byte[] serialize(List<HashBasedCommitment> elements) { | ||
if (elements.isEmpty()) { | ||
return new byte[] {}; | ||
} | ||
// A serialized commitment only consists of its internal digest | ||
byte[] commList = new byte[elements.size() * HashBasedCommitment.DIGEST_LENGTH]; | ||
// Ensure all field elements are in the same field and have same bit length | ||
for (int i = 0; i < elements.size(); i++) { | ||
System.arraycopy(elements.get(i).getCommitmentValue(), 0, commList, | ||
i * HashBasedCommitment.DIGEST_LENGTH, HashBasedCommitment.DIGEST_LENGTH); | ||
} | ||
return commList; | ||
} | ||
|
||
@Override | ||
public HashBasedCommitment deserialize(byte[] data) { | ||
if (data.length != HashBasedCommitment.DIGEST_LENGTH) { | ||
throw new IllegalArgumentException( | ||
"The length of the byte array to deserialize is wrong."); | ||
} | ||
HashBasedCommitment comm = new HashBasedCommitment(); | ||
comm.setCommitmentValue(data.clone()); | ||
return comm; | ||
} | ||
|
||
@Override | ||
public List<HashBasedCommitment> deserializeList(byte[] data) { | ||
if (data.length % HashBasedCommitment.DIGEST_LENGTH != 0) { | ||
throw new IllegalArgumentException( | ||
"The length of the byte array to deserialize is wrong."); | ||
} | ||
if (data.length == 0) { | ||
return new ArrayList<>(); | ||
} | ||
// A serialized commitment only consists of its internal digest | ||
List<HashBasedCommitment> res = new ArrayList<>( | ||
data.length / HashBasedCommitment.DIGEST_LENGTH); | ||
for (int i = 0; i < data.length / HashBasedCommitment.DIGEST_LENGTH; i++) { | ||
HashBasedCommitment comm = new HashBasedCommitment(); | ||
byte[] commVal = new byte[HashBasedCommitment.DIGEST_LENGTH]; | ||
System.arraycopy(data, i * HashBasedCommitment.DIGEST_LENGTH, | ||
commVal, 0, HashBasedCommitment.DIGEST_LENGTH); | ||
comm.setCommitmentValue(commVal); | ||
res.add(comm); | ||
} | ||
return res; | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
core/src/main/java/dk/alexandra/fresco/framework/MPCException.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
core/src/main/java/dk/alexandra/fresco/framework/MaliciousException.java
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,16 @@ | ||
|
||
package dk.alexandra.fresco.framework; | ||
|
||
/** | ||
* Runtime exception to be thrown if and only if data received from another party does not follow | ||
* the protocol specification. By definition this is considered a malicious act. Data received is | ||
* not limited to raw data, but also any kind of local processing of raw data. | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class MaliciousException extends RuntimeException { | ||
|
||
public MaliciousException(String message) { | ||
super(message); | ||
} | ||
|
||
} |
54 changes: 46 additions & 8 deletions
54
core/src/main/java/dk/alexandra/fresco/framework/ProtocolEvaluator.java
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 |
---|---|---|
@@ -1,26 +1,64 @@ | ||
package dk.alexandra.fresco.framework; | ||
|
||
import dk.alexandra.fresco.framework.builder.ProtocolBuilder; | ||
import dk.alexandra.fresco.framework.network.Network; | ||
import dk.alexandra.fresco.framework.sce.resources.ResourcePool; | ||
|
||
/** | ||
* An evaluator is responsible for evaluating each native gate. Every protocol is reduced to a | ||
* number of native gates. These are then evaluated in batches (the amount of native protocols per | ||
* batch can be configured by the user). | ||
* An evaluator is responsible for evaluating each native protocol. Every computation is reduced to | ||
* a number of native protocols. These are then evaluated in batches (the amount of native | ||
* protocols per batch can be configured by the user). | ||
* | ||
* @param <ResourcePoolT> The type of resource pool | ||
* @param <Builder> The type of builder this evaluator supports | ||
*/ | ||
public interface ProtocolEvaluator<ResourcePoolT extends ResourcePool, Builder extends ProtocolBuilder> { | ||
public interface ProtocolEvaluator<ResourcePoolT extends ResourcePool> { | ||
|
||
/** | ||
* Evaluates all gates produced by a GateProducer. | ||
* Evaluates all gates produced by a ProtocolProducer. | ||
* | ||
* @param protocolProducer the protocol producer to evaluate | ||
* @param resourcePool the resource pool (for other resources than network) | ||
* @param network network to use for the evaluation | ||
* @return the overall statistics about the evaluation | ||
*/ | ||
void eval(ProtocolProducer protocolProducer, ResourcePoolT resourcePool, Network network); | ||
EvaluationStatistics eval( | ||
ProtocolProducer protocolProducer, ResourcePoolT resourcePool, Network network); | ||
|
||
/** | ||
* Overall statistics about protocol evaluation | ||
*/ | ||
class EvaluationStatistics { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we even need this? This should be part of the performance logging system. |
||
|
||
private final int nativeProtocols; | ||
private final int batches; | ||
|
||
/** | ||
* Createes a new statistics object. | ||
* | ||
* @param nativeProtocols the total number of native protocols in evaluation | ||
* @param batches the total of batches in the evaluation | ||
*/ | ||
public EvaluationStatistics(int nativeProtocols, int batches) { | ||
|
||
this.nativeProtocols = nativeProtocols; | ||
this.batches = batches; | ||
} | ||
|
||
/** | ||
* Returns the total number of native protocols in evaluation. | ||
* | ||
* @return the total number of native protocols in evaluation | ||
*/ | ||
public int getNativeProtocols() { | ||
return nativeProtocols; | ||
} | ||
|
||
/** | ||
* Returns the total of batches in the evaluation. | ||
* | ||
* @return the total of batches in the evaluation | ||
*/ | ||
public int getBatches() { | ||
return batches; | ||
} | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
core/src/main/java/dk/alexandra/fresco/framework/builder/numeric/NumericResourcePool.java
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,45 @@ | ||
package dk.alexandra.fresco.framework.builder.numeric; | ||
|
||
import dk.alexandra.fresco.framework.network.serializers.ByteSerializer; | ||
import dk.alexandra.fresco.framework.sce.resources.ResourcePool; | ||
import dk.alexandra.fresco.suite.ProtocolSuiteNumeric; | ||
import java.math.BigInteger; | ||
|
||
/** | ||
* Every resource pool must have a set of properties available, primarily | ||
* the modulus and a BigInteger serialization. | ||
* <p> | ||
* This is paired with the {@link ProtocolSuiteNumeric}. | ||
*/ | ||
public interface NumericResourcePool extends ResourcePool { | ||
|
||
/** | ||
* Gets the modulus. | ||
* | ||
* @return modulus | ||
*/ | ||
BigInteger getModulus(); | ||
|
||
/** | ||
* Gets a serializer for big integer that is aligned with the current system settings in this | ||
* invocation - hence byte length of big integer. | ||
* | ||
* @return the serializer | ||
*/ | ||
ByteSerializer<BigInteger> getSerializer(); | ||
|
||
/** | ||
* Takes a unsigned BigInteger and converts it (reasonable) to a signed version. | ||
* | ||
* @param bigInteger the unsigned BigInteger | ||
* @return the signed BigInteger | ||
*/ | ||
default BigInteger convertRepresentation(BigInteger bigInteger) { | ||
BigInteger modulus = getModulus(); | ||
BigInteger actual = bigInteger.mod(modulus); | ||
if (actual.compareTo(modulus.divide(BigInteger.valueOf(2))) > 0) { | ||
actual = actual.subtract(modulus); | ||
} | ||
return actual; | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This ought to have some documentation of how to interpret this type exception.
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.
It has been added in commit 7d2730f and df12821