Skip to main content

Build Status

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

    • JIT tested on OSX + LLVM, experimental

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, rebuild with:

MONERO_NO_AES=1 python setup.py install

JIT

The JIT optimization 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
MONERO_USE_CNV4_JIT=1 ./test.sh

To rebuild locally and test:

MONERO_NO_AES=0 MONERO_NO_JIT=0 python setup.py develop
MONERO_USE_CNV4_JIT=0 ./test.sh  # JIT disabled
MONERO_USE_CNV4_JIT=1 ./test.sh  # JIT enabled

For more info read JIT.md

Donations

Thanks for your support!

86SgqL4YwtWBgq65CitxbPC5ChUJrDkTVWJgtenuf6S68GTLWqPh3zydYpoFhr8JyVdWEZmoMMnhjdvoKQ9urZFfCXKmD93

Metadata

Release files for py-cryptonight 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-cryptonight 1.0.0
File Size Uploaded
py_cryptonight-1.0.0.tar.gz 574.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-cryptonight 1.0.0
File Interpreter ABI Platform
py_cryptonight-1.0.0-cp310-cp310-macosx_12_0_arm64.whl CPython 3.10 CPython 3.10 macOS 12.0+ ARM64 Details

Total release size: 961.7 kB

Release files / py_cryptonight-1.0.0.tar.gz

Download URL py_cryptonight-1.0.0.tar.gz
Size 574.4 kB
Tags Source
SHA-256 checksum
How to use checksums
622a7a81d8b2e4ebb2adaccfdb7d043072090e16b3d9a436d1f35e9e8fcd6f97
BLAKE2b-256 checksum
How to use checksums
de4c6a373ebf4ca60cdf3f210e7572d6e5c0a6cd6abc78557cad1f5e512028f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / py_cryptonight-1.0.0-cp310-cp310-macosx_12_0_arm64.whl

Download URL py_cryptonight-1.0.0-cp310-cp310-macosx_12_0_arm64.whl
Size 387.3 kB
Tags CPython 3.10 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
a69720e220595407c12d244ec42f84dc8b5d8af9f834c0f3e8b2b69fcc368172
BLAKE2b-256 checksum
How to use checksums
ae5008283297d2f3fe6fb827f85934889e7c8e0cc2f0f08006ff616bc9d45927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.3.4

1 release file

0.3.3

2 release files

0.3.2

1 release file

0.3.0

2 release files

0.2.4

2 release files

0.2.3

1 release file

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

1 release file

0.1.7

1 release file

0.1.5

3 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page