Refactor using of crypto functions #1796

Closed
g1itch wants to merge 14 commits from crypto into v0.6
g1itch commented 2021-07-28 23:18:09 +02:00 (Migrated from github.com)

In this branch I'm gonna cover by tests all the crypto functions used in code and do a refactoring. Basic points:

  • only highlevelcrypto should import from pyelliptic
  • highlevelcrypto should not depend on the app state e.g. module state or BMConfigparser() instance (the same will be done for protocol in #1788)
  • highlevelcrypto should include hashes - double sha512, ripemd160
  • finally I'm gonna detach pyelliptic into the separate repo to show a possible way of addressing #886
In this branch I'm gonna cover by tests all the crypto functions used in code and do a refactoring. Basic points: * only `highlevelcrypto` should import from `pyelliptic` * `highlevelcrypto` should not depend on the app state e.g. module `state` or `BMConfigparser()` instance (the same will be done for `protocol` in #1788) * `highlevelcrypto` should include hashes - double sha512, ripemd160 * finally I'm gonna detach `pyelliptic` into the separate repo to show a possible way of addressing #886
PeterSurda (Migrated from github.com) reviewed 2021-11-15 08:23:35 +01:00
@ -59,3 +60,26 @@ class TestAddresses(unittest.TestCase):
sample_addr4, addresses.encodeBase58(sample_daddr4_512))
PeterSurda (Migrated from github.com) commented 2021-11-15 08:23:35 +01:00

these binary data should also be a variable in samples.

these binary data should also be a variable in samples.
PeterSurda (Migrated from github.com) reviewed 2021-11-15 08:24:01 +01:00
@ -65,0 +85,4 @@
def test_random_keys(self):
"""Dummy checks for random keys"""
priv, pub = highlevelcrypto.random_keys()
self.assertEqual(len(priv), 32)
PeterSurda (Migrated from github.com) commented 2021-11-15 08:24:01 +01:00

ideally b'hello' should also be a variable in samples

ideally `b'hello'` should also be a variable in samples
PeterSurda commented 2021-11-15 08:25:53 +01:00 (Migrated from github.com)

overall nice work, although I haven't investigated it in depth

overall nice work, although I haven't investigated it in depth
g1itch (Migrated from github.com) reviewed 2021-11-15 13:10:44 +01:00
@ -65,0 +85,4 @@
def test_random_keys(self):
"""Dummy checks for random keys"""
priv, pub = highlevelcrypto.random_keys()
self.assertEqual(len(priv), 32)
g1itch (Migrated from github.com) commented 2021-11-15 13:10:44 +01:00
It's from here: https://pybitmessage-test.readthedocs.io/en/doc/protocol.html#hashes
g1itch commented 2021-11-15 13:16:44 +01:00 (Migrated from github.com)

overall nice work, although I haven't investigated it in depth

It seems that I misplaced (or misnamed) the signatures. I was going to regenerate them. And there is also a lot of unfinished changes here, mentioned in the PR description.

> overall nice work, although I haven't investigated it in depth It seems that I misplaced (or misnamed) the signatures. I was going to regenerate them. And there is also a lot of unfinished changes here, mentioned in the PR description.
g1itch (Migrated from github.com) reviewed 2021-12-10 18:02:15 +01:00
@ -21,0 +84,4 @@
priv = hashlib.sha512(passphrase + nonce).digest()[:32]
pub = pointMult(priv)
return priv, pub
g1itch (Migrated from github.com) commented 2021-12-10 18:02:14 +01:00

I'm not sure if these functions should return the pair or only the private key.

I'm not sure if these functions should return the pair or only the private key.
This repo is archived. You cannot comment on pull requests.
No description provided.