pybitmessage.highlevelcrypto module

High level cryptographic functions based on pyelliptic OpenSSL bindings.

Note

Upstream pyelliptic was upgraded from SHA1 to SHA256 for signing. We must upgrade PyBitmessage gracefully. More discussion.

decodeWalletImportFormat(WIFstring)[source]

Convert private key from base58 that’s used in the config file to 8-bit binary string.

encodeWalletImportFormat(privKey)[source]

Convert private key from binary 8-bit string into base58check WIF string.

randomBytes(n)[source]

Get n random bytes

to_ripe(signing_key, encryption_key)[source]

Convert two public keys to a ripe hash

double_sha512(data)[source]

Binary double SHA512 digest

calculateInventoryHash(data)[source]

Calculate inventory hash from object data

random_keys()[source]

Return a pair of keys, private and public

deterministic_keys(passphrase, nonce)[source]

Generate keys from passphrase and nonce (encoded as varint)

privToPub(privkey)[source]

Converts hex private key into hex public key

pointMult(secret)[source]

Does an EC point multiplication; turns a private key into a public key.

Evidently, this type of error can occur very rarely:

>>> File "highlevelcrypto.py", line 54, in pointMult
>>>  group = OpenSSL.EC_KEY_get0_group(k)
>>> WindowsError: exception: access violation reading 0x0000000000000008
makeCryptor(privkey, curve='secp256k1')[source]

Return a private pyelliptic.ECC instance

encrypt(msg, hexPubkey)[source]

Encrypts message with hex public key

sign(msg, hexPrivkey, digestAlg='sha256')[source]

Signs with hex private key using SHA1 or SHA256 depending on digestAlg keyword.

verify(msg, sig, hexPubkey, digestAlg=None)[source]

Verifies with hex public key using SHA1 or SHA256