Skip to content

Conversation

@D-Sinus
Copy link
Contributor

@D-Sinus D-Sinus commented Dec 9, 2019

(Put an X inside the [ ] to denote check mark [X].)

  • If creating a new file :

    • added links to it in the README files ?
    • included tests with it ?
    • added description (overview of algorithm, time and space complexity, and possible edge case) in docstrings ?
  • if done some changes :

    • wrote short description in the PR explaining what the changes do ?
    • Fixes #[issue number] if related to any issue
  • other

@D-Sinus
Copy link
Contributor Author

D-Sinus commented Dec 9, 2019

To implement DH key exchange, prime_check.py (written by 'goswami-rahul' and 'Hai Honag Dang') and euler_totient function (written by 'goswami-rahul') is needed.
So I copy their code and write comment about that (this is not my code).
And also this requires algorithms that I commit before (find order/primitive root).
That's why the length of code of this algorithm is quite long.

Again, Please let me know if such usage is problematic.
Thanks.

Comment on lines 167 to 168
print ("Private key of Alice = %d" % a_pr_k)
print ("Public key of Alice = %d" % a_pu_k)
Copy link
Owner

Choose a reason for hiding this comment

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

could you make the print statements optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[Edit] Add optional parameter, and those statements only appears when that parameter is given.

I left shared-key print statements for comparison.
Do you think those statements should be optional also?
Please let me hear your opinion. Thanks.

p_root_list.index(a)
except ValueError as e:
print("%d is not a primitive root of %d" % (a, p))
return -1
Copy link
Owner

Choose a reason for hiding this comment

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

please raise error in this case so we can only return bool type.
If a function returns two types (-1, bool) the caller needs to branch out by the return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[Edit] For primitive root case, code now return False, for consistency

@keon keon merged commit 29b310d into keon:master Dec 22, 2019
@keon
Copy link
Owner

keon commented Dec 22, 2019

thanks so much for the contribution!

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.

2 participants