MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / sign

Function sign

src/highlevelcrypto.py:34–47  ·  view source on GitHub ↗
(msg,hexPrivkey)

Source from the content-addressed store, hash-verified

32 return cryptor.decrypt(msg)
33# Signs with hex private key
34def sign(msg,hexPrivkey):
35 # pyelliptic is upgrading from SHA1 to SHA256 for signing. We must
36 # upgrade PyBitmessage gracefully.
37 # https://github.com/yann2192/pyelliptic/pull/33
38 # More discussion: https://github.com/yann2192/pyelliptic/issues/32
39 digestAlg = BMConfigParser().safeGet('bitmessagesettings', 'digestalg', 'sha1')
40 if digestAlg == "sha1":
41 # SHA1, this will eventually be deprecated
42 return makeCryptor(hexPrivkey).sign(msg, digest_alg=OpenSSL.digest_ecdsa_sha1)
43 elif digestAlg == "sha256":
44 # SHA256. Eventually this will become the default
45 return makeCryptor(hexPrivkey).sign(msg, digest_alg=OpenSSL.EVP_sha256)
46 else:
47 raise ValueError("Unknown digest algorithm %s" % (digestAlg))
48# Verifies with hex public key
49def verify(msg,sig,hexPubkey):
50 # As mentioned above, we must upgrade gracefully to use SHA256. So

Callers

nothing calls this directly

Calls 4

BMConfigParserClass · 0.90
makeCryptorFunction · 0.85
safeGetMethod · 0.80
signMethod · 0.80

Tested by

no test coverage detected