SECP256k2: A Modern Library for Elliptic Curve Cryptography
Introduction
SECP256k2 is a high-performance and easy-to-use library for working with the SECP256k1 elliptic curve. This library is meticulously designed to provide a robust set of functionalities needed for the development of secure, fast, and efficient cryptographic applications.
Features
- Optimized Performance: Leveraging optimized algorithms and efficient code structures for high-speed operations on the SECP256k1 curve.
- Comprehensive Toolset: Offering a wide array of functionalities ranging from basic arithmetic operations to advanced cryptographic protocols.
- Cross-Platform: Written in
C&Python, SECP256k2 is designed to be used on multiple operating systems including Windows and Linux & Mac.
Getting Started
Installation
windows with pip
pip install --upgrade secp256k2
linux and Mac with pip3
pip3 install --upgrade secp256k2
Generate and Converet 10,000 Key to Compress and Uncompress Address. ( Check Now in Google Colab )
import os, timeit
setup_code = """
from os import urandom
from secp256k2 import Contactor
cont = Contactor()
def test_Profile_1():
numd = urandom(32)[0]
caddr = cont.privatekey_to_address(0, True, numd)
uaddr = cont.privatekey_to_address(0, False, numd)
"""
# // Total Generated
num = 10000
time1 = timeit.timeit("test_Profile_1()", setup=setup_code, number=num)
print(f"Generated & Convereted {format(num, ',')} Key To : {time1:.6f} sec")
[!NOTE] Output :
Generated & Convereted 10,000 Key To : 0.393369 sec
Usage
A quick example to get you started with SECP256k2:
from secp256k2 import Contactor
cont = Contactor()
dec = 0x00000000000000000000000000000000000000000000001
wif_compress = cont.Decimal_To_Wif(dec, True)
wif_uncompress = cont.Decimal_To_Wif(dec, False)
compressed and uncompressed bitcoin address wallet from decimal (integer).
from secp256k2 import Contactor
# added Contactor class to project script
co = Contactor()
# dec
dec = 0xffffffffffffffffffffff880000000000000
compress_address = co.Decimal_To_Addr(dec, addr_type=0, compress=True)
uncompress_address = co.Decimal_To_Addr(dec, addr_type=0, compress=False)
Convert Decimal (Number) To Ethereum Address (Maximum Range: 115792089237316195423570985008687907852837564279074904382605163141518161494337):
from secp256k2 import Contactor
cont = Contactor()
dec_num = 1 # example , can use any range number to
# ethereum address generated from decimal number
eth_address = cont.Decimal_To_ETH_Addr(dec_num)
convert and Generated Wif Key from decimal Number:
from secp256k2 import Contactor
co = Contactor()
dec = 0xffffffffffffffffffffffffff8999999999333666666
wif_compress = co.Decimal_To_Wif(dec, True)
wif_uncompress = co.Decimal_To_Wif(dec, False)
Decimal to RIPEMD160
from secp256k2 import Contactor
co = Contactor()
dec = 0xfffffffffffffffffff99999999999
ripemd160 = co.Decimal_To_RIPEMD160(dec)
convert wif key to private key (hex):
from secp256k2 import Contactor
co = Contactor()
WIF = "WIF_KEY_HERE"
privatekey = co.Wif_To_Hex(WIF)
Convert Private Key To Wif Compressed and Uncompressed
from secp256k2 import Contactor
cont = Contactor()
privatekey = "PRIVATE_KEY_HERE"
wif_compress = cont.btc_pvk_to_wif(privatekey, True)
wif_uncompress = cont.btc_pvk_to_wif(privatekey, False)
Convert Wif to Private Key (integer/decimal):
from secp256k2 import Contactor
cont = Contactor()
wif = "WIF_KEY_HERE"
privatekey = cont.btc_wif_to_pvk_int(wif)
Convert Wif to Private Key (hex):
from secp256k2 import Contactor
cont = Contactor()
wif = "WIF_KEY_HERE"
privatekey = cont.btc_wif_to_pvk_hex(wif)
Convert Private Key (decimal) To RIPEMD160 (h160)
from secp256k2 import Contactor
cont = Contactor()
privatekey = 12345678901234567891234567891234567789
ripemd160 = cont.privatekey_to_h160(privatekey)
Convert Private Key (Decimal) To Compressed and uncompressed Address
- addr_type (int) : P2PKH =
0, P2SH =1, P2WPKH =2 - compress (bool) :
True: Compress,False: Uncompress - private key (decimal) :
0-115792089237316195423570985008687907852837564279074904382605163141518161494337
from secp256k2 import Contactor
cont = Contactor()
privatekey = 12345678901234567891234567891234567789
address_compress = cont.privatekey_to_address(0, True, privatekey)
address_uncompress = cont.privatekey_to_address(0, False, privatekey)
Documentation
For more detailed information and advanced usage, please refer to the full documentation.
Contribution
We welcome contributions from the open-source community. If you find any issues or would like to propose enhancements, please feel free to open an issue or submit a pull request.
License
SECP256k2 is licensed under MIT. For more information, please see the LICENSE file.
Donate:
Bitcoin:1MMDRZA12xdBLD1P5AfEfvEMErp588vmF9
Programmer And Owner : PyMmdrza
Email : Mmdrza@usa.com
official website : MMDRZA.COM
Metadata
Release files for secp256k2 1.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| secp256k2-1.4.6.tar.gz | 6.0 MB | Without provenance | Details for secp256k2-1.4.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| secp256k2-1.4.6-py3-none-any.whl | Python 3 | none | any | Details for secp256k2-1.4.6-py3-none-any.whl |
Total release size: 12.2 MB
Release files / secp256k2-1.4.6.tar.gz
| Download URL | secp256k2-1.4.6.tar.gz |
|---|---|
| Size | 6.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4efd223615987534f170e57c38901d4b489509dfb39ecc653ceba51814408c78
|
|
BLAKE2b-256 checksum How to use checksums |
4c4c3d538c11cf57b1f4ae692823d67cd484de73c24072268aaff3d0fd865eea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / secp256k2-1.4.6-py3-none-any.whl
| Download URL | secp256k2-1.4.6-py3-none-any.whl |
|---|---|
| Size | 6.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00c26e5a6187746c9a84bbfc87c9f870f903555d27beacbd39fa881f8737003c
|
|
BLAKE2b-256 checksum How to use checksums |
b1851e8c2ec27d4f382a63353182d0be3439434aa7775f932a9c929fd3949d40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for secp256k2 1.4.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.