Refactor using of crypto functions #1796
No reviewers
Labels
No Label
bug
build
dependencies
developers
documentation
duplicate
enhancement
formatting
invalid
legal
mobile
obsolete
packaging
performance
protocol
question
refactoring
regression
security
test
translation
usability
wontfix
No Milestone
No project
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Bitmessage/PyBitmessage-2024-12-06#1796
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "crypto"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In this branch I'm gonna cover by tests all the crypto functions used in code and do a refactoring. Basic points:
highlevelcrypto
should import frompyelliptic
highlevelcrypto
should not depend on the app state e.g. modulestate
orBMConfigparser()
instance (the same will be done forprotocol
in #1788)highlevelcrypto
should include hashes - double sha512, ripemd160pyelliptic
into the separate repo to show a possible way of addressing #886@ -59,3 +60,26 @@ class TestAddresses(unittest.TestCase):
sample_addr4, addresses.encodeBase58(sample_daddr4_512))
these binary data should also be a variable in samples.
@ -65,0 +85,4 @@
def test_random_keys(self):
"""Dummy checks for random keys"""
priv, pub = highlevelcrypto.random_keys()
self.assertEqual(len(priv), 32)
ideally
b'hello'
should also be a variable in samplesoverall nice work, although I haven't investigated it in depth
@ -65,0 +85,4 @@
def test_random_keys(self):
"""Dummy checks for random keys"""
priv, pub = highlevelcrypto.random_keys()
self.assertEqual(len(priv), 32)
It's from here: https://pybitmessage-test.readthedocs.io/en/doc/protocol.html#hashes
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.
@ -21,0 +84,4 @@
priv = hashlib.sha512(passphrase + nonce).digest()[:32]
pub = pointMult(priv)
return priv, pub
I'm not sure if these functions should return the pair or only the private key.