Python Cryptonight
Project description
Python binding for Monero hash functions cn_fast_hash, cn_slow_hash.
cn_fast_hash is used mainly for hashing to scalars / EC points.
cn_slow_hash is CryptoNight hash function used for mining and encryption key derivation for encrypted wallet files.
Supports CNv1, CNv2, CNv4
Py2, Py3 compatible + tests with Monero test vectors.
pip install py-cryptonight
Usage
import binascii
import pycryptonight
pycryptonight.cn_fast_hash(b'1')
# hexcoded: b'c89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6
pycryptonight.cn_slow_hash(b'1')
# hexcoded: b'cbdfba46388e040422b4a9daa471726be659ae184ee86420c2795647f0b301d5
# variant 1:
pycryptonight.cn_slow_hash(binascii.unhexlify(b'38274c97c45a172cfc97679870422e3a1ab0784960c60514d816271415c306ee3a3ed1a77e31f6a885c3cb'), 1) # variant 1
# hexcoded: b'ed082e49dbd5bbe34a3726a0d1dad981146062b39d36d62c71eb1ed8ab49459b
# variant 2:
pycryptonight.cn_slow_hash(b'1', 2) # variant 2
# hexcoded: b'44016d2376838d89b374e99a20118c0e8916e8c0a5b910744efc7d8f426509ca
# variant 4:
pycryptonight.cn_slow_hash(b'1', 4) # variant 4
# hexcoded: b'97db7e03629f7c17e4d78b36a2d247d226b88a8df6cf69f2e4cdae1f1b706b4a
# variant 4, height:
pycryptonight.cn_slow_hash(b'1', 4, prehashed=0, height=1) # variant 4, height 1
# hexcoded: b'09bcf4997132dc3d7980125620724acc9c90dc393cb6694097a7d745c57b6b5b
Build problems
The extension builds with AES extension by default. To disable this:
MONERO_USE_AES=0 python setup.py install
The JIT is disabled by default as the implementation was not properly tested. If you want to experiment with JIT you need to compile with:
MONERO_NO_JIT=0 python setup.py install
Donations
Thanks for your support!
47BEukN83whUdvuXbaWmDDQLYNUpLsvFR2jioQtpP5vD8b3o74b9oFgQ3KFa3ibjbwBsaJEehogjiUCfGtugUGAuJAfbh1Z
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for py_cryptonight-0.2.0-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09e604c324b8d181bbf9bb640d25d0cceca588d1270636599e64fb5dc8039d3a |
|
MD5 | 1b75096d535b503354aa32d58f5eebe5 |
|
BLAKE2b-256 | e5af0acd4369fae3937b978f443e5fe1a612ccaca24aa58cc6d9dbe8cf466470 |