Skip to content
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

improvement #8

Closed
wants to merge 5 commits into from
Closed

improvement #8

wants to merge 5 commits into from

Conversation

Moustikitos
Copy link

  • formatters module compatibility for python 2.7
  • added rfc 6979 signature to ecschnorr module

Copy link
Owner

@cslashm cslashm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need usage ref for rf6979 in ecschnorr

int and encoding fixes are IMHO false.

@@ -149,6 +149,22 @@ def sign(self, msg, pv_key):
return sig
return None

def sign_rfc6979(self, msg, pv_key, hasher, canonical=False):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide real usage of ec-schnorr+rfc6979 ?

from builtins import int,pow
if sys.version_info[0] <= 2:
basint = lambda b:int.from_bytes(b, 'big')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from_bytes is New in version 3.2. so this wont work

r = int.from_bytes(sig[0], 'big')
s = int.from_bytes(sig[1], 'big')
return r,s

if fmt=="BTUPLE":
return (sig[0],sig[1])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ITUPLE is a tuple of ints, so r,s as int is just sig[0]/sig[1]
BTUPLE is a tuple of bytes, so decoding must be done.

I dont understand why you invert that?

if sys.version_info[0] <= 2:
basint = lambda b:int.from_bytes(b, 'big')
else:
basint = lambda b:int(b)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you cannot convert bytes to int like this.

Please give rational of what you are trying to do.

@Moustikitos
Copy link
Author

Moustikitos commented Jul 16, 2019

Hi,

rfc 6979 is just a protocol to do deterministic signature providing k parameter in a deterministic way. Because Schnorr uses elliptic curves with k parameter, I think sign_rfc_6979 is a "must have".

According to the int.from_bytes, the issues appears with python 2.7. Actually python 2.7 interpret elem[i] as a str if elem is an bytes string and then sig[0] + 2 raises error : cannot concatenate str and int...
the function basint is applied only when a single byte is extracted from a bytes string using __getitem__ operator.
Actually instead of int.from_bytes, ord operator should be use.

My mistake about BTUPPLE and ITUPPLE, i missed the fact that the code was in a decode function :).

BTW, I like your pacakge because it is simple and efficient. I replaced ecdsa lib with yours in my python app.

@Moustikitos Moustikitos mentioned this pull request Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants