-
Notifications
You must be signed in to change notification settings - Fork 0
Ozan/merkletree #32
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
Ozan/merkletree #32
Conversation
| * @param n number of elements to create | ||
| * @return a new skip list with n random elements | ||
| */ | ||
| public static MerkleTree createSkipList(int n) { |
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.
Seems like there are still residues of SkipList in this PR, please check and fix.
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.
fixed in 29bb463
| /** | ||
| * Encapsulates tests for an authenticated and concurrent implementation of SkipList ADS. | ||
| */ | ||
| public class MerkleTreeTest { |
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.
Please add a comment for each test briefly explaining what it evaluates.
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.
fixed in df3b433
| if (e == null) { | ||
| return null; | ||
| } |
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.
Invalid input must trigger an IllegalArgumentException, the get should explicitly list the exceptions it throws, and those exceptions must be bubbled up to the caller, literally safely fail the main. Also, please add a test covering this test case.
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.
fixed in 94cfe9b
| } | ||
| if (proof == null) { | ||
| return null; | ||
| } |
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.
On a happy path, do we expect to have a null proof? if we don't, then this line steps into an illegal state, and hence must throw an IllegalStateException. (Also, please add test covering this test case).
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.
fixed in 205970f
| } | ||
|
|
||
| private Proof getProof(Identifier id) { | ||
| Integer idx = leafNodesHashTable.get(hasher.computeHash(id)); |
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.
ids are unique, i.e., they correspond to the hash of entities they keep, hence, there is no need to hash them again, right?
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.
fixed in d3b1343
| if (e == null) { | ||
| lock.writeLock().unlock(); | ||
| return null; |
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.
Isn't it an IllegalArgumentException case?
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.
fixed in 94cfe9b
| } | ||
|
|
||
| @Override | ||
| public AuthenticatedEntity put(Entity e) { |
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.
A general comment about this and some subsequent methods, where unlocking the lock is happening on several disjoint execution paths. It makes the implementation daunting to keep track of lock-unlock state transitions and makes it bug-prone regarding the liveness issues. Hence, please use try-finally blocks to lock and unlock only once.
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.
fixed in ccffc17
| AuthenticatedEntity put(Entity e); | ||
|
|
||
| AuthenticatedEntity get(Identifier id); | ||
| AuthenticatedEntity get(Entity e); |
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 is wrong! get is utilized only when we have the id of the entity and not the entity itself. Please abide to the original interface.
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.
fixed in cc555b4
| * @return SHA3-256 hash object of the commutative concatenation (i.e. max(b1,b2) || min(b1,b2)) | ||
| * of the two byte arrays. | ||
| */ | ||
| public Sha3256Hash computeHash(byte[] b1, byte[] b2) { |
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.
why not always h(b1||b2)?
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.
fixed in d0f93ab
| Entity entity = new EntityFixture(); | ||
| try { | ||
| merkleTree.put(entity); | ||
| AuthenticatedEntity authenticatedEntity = merkleTree.get(entity); |
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.
get should be done in a separate for loop (sequentially), once all put threads are 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.
fixed in 8cdb9a2
* implements merkle tree implementation and insertion to it * implements merkle tree authentication * implements tests * implements hash table for searching in merkle tree * implements thread safety to merkle tree implementation * fixes lint & spotbugs issues * renames Merkle Tree creation function in MerkleTreeFixture.java * suppresses EI_EXPOSE_REP warnings in spotbugs * suppresses warnings in spotbugs * adds comments for unit tests * handles exceptions on MerkleTree.java * changes how id of an entity is stored on the merkle tree, changed from hash(id) to id * handles exceptions better for locks * changes get method in a way it gets the AuthenticatedEntity by id not Entity * improves thread safety check * improves exception handling1 * improves the hashing and how proofs are created in merkle tree * applies revisions * applies revisions * applies revisions * applies revisions * fixes lint * removes unnecessary setters * removes unnecessary setters * fixes a java doc * applies revisions * fixes lint * applies revisions Co-authored-by: Yahya <yhassanzadeh13@ku.edu.tr>
No description provided.