-
Notifications
You must be signed in to change notification settings - Fork 47
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
ON HOLD: Double spending prevention using Secp256k1 keys on TrustChain #68
Conversation
Can one of the admins verify this patch? |
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 doesn't pass the tests 🙍
b01940f
to
b30809a
Compare
retest this please |
1 similar comment
retest this please |
ipv8/attestation/trustchain/block.py
Outdated
@@ -273,6 +290,14 @@ def err(reason): | |||
linklinked = database.get_linked(link) | |||
if linklinked is not None and linklinked.hash != self.hash: | |||
err("Double countersign fraud") | |||
if 'double_sig' in self.transaction and self.transaction['double_sig'] \ | |||
and 'double_sig' in linklinked.transaction and linklinked.transactino['double_sig']: |
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.
transactino
?
9818aeb
to
265fc07
Compare
return self.point(x, y) | ||
|
||
def sub(self, lhs, rhs): | ||
return lhs + -rhs |
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.
+ -
is redundant
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 the way it should be. Point negation and addition.
test/util.py
Outdated
@@ -166,4 +166,4 @@ def twisted_wrapper(arg): | |||
""" | |||
if isinstance(arg, (int, long)): | |||
return lambda x: deferred(arg)(inlineCallbacks(x)) | |||
return deferred(timeout=1)(inlineCallbacks(arg)) | |||
return deferred(timeout=10)(inlineCallbacks(arg)) |
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 change this per test, not globally.
1d6dc0d
to
3e3f2e5
Compare
retest this please |
52790c6
to
f9fbb01
Compare
retest this please |
|
Updated test timeouts to fit for signatures
Changed test timeout Using gmpy2 integer for field operations
1367765
to
040ced3
Compare
test/base.py
Outdated
@@ -95,7 +95,7 @@ def add_node_to_experiment(self, node): | |||
self.nodes.append(node) | |||
|
|||
@inlineCallbacks | |||
def deliver_messages(self, timeout=.1): | |||
def deliver_messages(self, timeout=10): |
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 don't change the base timeouts.
040ced3
to
05f9674
Compare
retest this please |
retest this please |
7 similar comments
retest this please |
retest this please |
retest this please |
retest this please |
retest this please |
retest this please |
retest this please |
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 looks ok but I have some minor comments.
In general, I would like to know more about the performance. Can we get some numbers to quantify the overhead of the double spend detection (not for this PR)?
@@ -2,6 +2,7 @@ | |||
|
|||
import time | |||
|
|||
from ipv8.keyvault import doublesign |
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.
Shouldn't we use relative imports everywhere?
@@ -117,8 +118,9 @@ def pack(self, signature=True): | |||
:param signature: False to pack EMPTY_SIG in the signature location, true to pack the signature field | |||
:return: the buffer the data was packed into | |||
""" | |||
raw_transaction = {i:self.transaction[i] for i in self.transaction if i != 'double_sig'} |
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 space after the first :
for clarity.
@@ -292,15 +317,22 @@ def err(reason): | |||
err("Next hash is not equal to the hash id of the block") | |||
# Again, this might not be fraud, but fixing it can only result in fraud. | |||
|
|||
return result[0], errors | |||
return result[0], errors, result[1] |
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.
We're already returning a tuple with three results now. Maybe we should convert to a namedtuple
?
|
||
def sign(self, key): | ||
def sign(self, key, double_sign=False): |
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 docstring about the double_sign
parameter 👍
@staticmethod | ||
def double_spend(): | ||
""" | ||
The block violates at least one validation rule |
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.
Does the docstring match with the method name?
@@ -51,11 +51,13 @@ class TrustChainCommunity(Community): | |||
def __init__(self, *args, **kwargs): | |||
working_directory = kwargs.pop('working_directory', '') | |||
db_name = kwargs.pop('db_name', self.DB_NAME) | |||
double_sign = kwargs.pop('double_sign', False) |
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 rename this to check_for_double_sign
or something similar 👍
|
||
def is_valid_double_signature(self, data, signature): | ||
""" | ||
Returns True if signature is valid |
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.
Minor detail: please be consistent with ending docstrings with a period or not :)
retest this please |
Merged into the |
Double spending prevention using Secp256k1 signatures on transactions.