iceland2k14 / secp256k1 Goto Github PK
View Code? Open in Web Editor NEWPython Library for Secp256k1 Bitcoin curve to do fast ECC calculation
License: MIT License
Python Library for Secp256k1 Bitcoin curve to do fast ECC calculation
License: MIT License
ChatGPT says, the 'ice.privatekey_to_address' function requires the private key to be a 32-byte integer. is it right or not? can you explain?
Hello.
p = ice.scalar_multiplication(1000)
ice.point_sequential_decrement(5, p).hex()
when I subtract 5 from the public key, I expect it to be P - 5, but not like 5 keys merged into one line:
049680241112d370b56da22eb535745d9e314380e568229e09f7241066003bc471ddac2d377f03c201ffa0419d6596d10327d6c70313bb492ff495f946285d8f38049cdcd2993ddab3f04295805f1592e62d44c4925347b4f066e8fadb77ea2320031f80dc7e5d772faee50abe1d1c7370bf769df6d92c99800a04bd032e7663b668048409463a521404a5a2d8aa90050e3ad8ec5d6faf870333b06dd4f63e8354a655cc99452b85092ca539cc1b6683b7ab371b8a6525269a1ecf91b857bee1db3bd40401066e87de95cf0f41441556f537cd51aede25adf58d2e34f3edc2d1d4821e2c8ea6cf3ac1c9c8682b0ba76b6d26316998557f3d94bc066d6af1dc04d02c2a6504f8821e1fdfdf9fc81e3acb3c1d1d7a65f710be2d94a193550721cb9361549597bb507868c1e0528251b635b9dcf28e5ac5770c05c7afc2a3f4b4c45b7d8993ec
Let's say I have a key
p2 = ice.scalar_multiplication(181786578786240192808009809421)
I need to subtract another 19184787898211 from p2 key and find out what public key it will be, how can I do this?
please add privatekey to pubkey function....
pubkey_to_ETH_address_bytes
can you add node.js support?
Hi
a1 = ice.get_sha256('test')
print(a1)
a2 = ice.get_sha256('test2')
print(a2)
print(a1)
return
b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'
b'`0:\xe2+\x99\x88a\xbc\xe3\xb2\x8f3\xee\xc1\xbeu\x8a!<\x86\xc9<\x07m\xbe\x9fU\x8c\x11\xc7R'
b'`0:\xe2+\x99\x88a\xbc\xe3\xb2\x8f3\xee\xc1\xbeu\x8a!<\x86\xc9<\x07m\xbe\x9fU\x8c\x11\xc7R'
How to fix this without unnecessary action
a1 = bytearray.fromhex(ice.get_sha256('test').hex())
I need a return in bytes
pls add function privkey to public key
I get about 400/second with point_multiplication, while scalar_multiplication is about 23K/second.
Please advice
EDIT: fixed typo
Hello! Can u add support for TRX please!
I did not find how to get the public key from the private key. Is this possible with this code?
Python 3.9.12 under (windows 10 Pro)
Traceback (most recent call last):
File "H:\Ramset\RANDBITS\random bits\Random.seed\BTC RANDOM SEED #64 II.py", line 4, in
import secp256k1 as ice
File "H:\Ramset\RANDBITS\random bits\Random.seed\secp256k1.py", line 22, in
ice = ctypes.CDLL(pathdll)
File "C:\Programs\Python\Python38\lib\ctypes_init_.py", line 374, in init
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'H:\Ramset\RANDBITS\random bits\Random.seed\ice_secp256k1.dll' (or one of its dependencies). Try using the full path with constructor syntax.
This problem occurs since windows 10 update to version 21H2... the dll file is not found even though it is present in the folder..
Good afternoon, please add to the DLL possibly recalculating SHA256 as many times as needed.
e.g. get_sha256(input_bytes, iteration)
get_sha256(b'a', 2048)
Hi there:
Quick question.
I am using this library with pypy3 and seems to work fine with compress and uncompress btc address.
But when try something like that:
mykey = int(key,16)
hash160 = ice.privatekey_to_h160(0, True, mykey).hex()
print(hash160)
I just got only 40 zeros = 0000000000000000000000000000000000000000
Can you spot a solution, thanks!
aka long bech32 addresses.
thank you.
why didn't you add it?
def upub2cpub(upub_bytes):
x1 = upub_bytes[1:33]
prefix = str(2 + int(upub_bytes[33:].hex(), 16)%2).zfill(2)
return bytes.fromhex(prefix)+x1
Please add in the next version. This is what I needed.
Please delete it
if you share source code we could learn about itegration py with c
P4 = ice.point_sequential_increment(500000, P)
P4[:65].hex()
: '046ebfe8cd423c6c16fa29ce8aae12fa15b4ab78314773aa6453aa98b2bdcc10f66a43166c2f45267331dcf4a113aa584cd040fb0f8fe07326c28a8cb6b0f84149'
above example print one line 65byte
without this print is like first 10 pubkeys like this
04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a04f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67204e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd1351ed993ea0d455b75642e2098ea51448d967ae33bfbdfe40cfe97bdc47739922042f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d604fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556ae12777aacfbb620f3be96017f45c560de80f0f6518fe4a03c870c36b075f297045cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da042f01e5e15cca351daff3843fb70f3c2f0a1bdd05e5af888a67784ef3e10a2a015c4da8a741539949293d082a132d13b4c2e213d6ba5b7617b5da2cb76cbde90404acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbecc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c3704a0434d9e47f3c86235477c7b1ae6ae5d3442d49b1943c2b752a68e2a47e247c7893aba425419bc27a3b6c7e693a24c696f794c2ed877a1593cbee53b037368d704774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cbd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b
how to get line by line print of selected 10, P or 500000, P ???
also mention line by line cpub print please...
Hi there,
I get a segmentation fault when running the script:
python3 getz_input.py -txid ced1d50363efafad90f479c9e1702d783ec6dbc20a70344ff041b78
Segmentation fault (core dumped)
any idea how to fix it?
Thanks.
если запустить много раз в разных потоках память уменьшается (сильно)
addr = secp256k1_lib.privatekey_to_ETH_address(pvk_int)
is it possible to add support for Ice.get_Y_to_X ?
1y=3x
Hello
please check how privatekey_to_h160 works
m/0'/1'/9
world evolve cry outer garden common differ jump few diet cliff lumber bd85556143de177ed9781ac3b24ba33d0bc4f8d6f34d9eaa1d9b8ab0ee3a7e84d42638b520043234bcedb4e869464b9f964e7e8dbf1588395f7a7782588ae664
dbb4ccf92b0a0742016c915585864a8261994ec2 | 1DMtkFF6J1abNqgVmpL5WtZZkcJtaCeW7d |
42a38914e258e63e4baaff51a62d61df0236f6d1 | 1DFWG8gL7jqRdwCogdKhXC9FRXuRb5Ed7X |
How to run on GPU ?
Hello! Please, add support for MacOS system.
Hello, little problem.
`
P='02504673bb8f9a16e40227b4ee12fb8d940630cb687fbc98c1747493d18e22f39c'
P = ice.pub2upub('02504673bb8f9a16e40227b4ee12fb8d940630cb687fbc98c1747493d18e22f39c')
xx=ice._point_sequential_decrement(15, P)
for t in range(10):
OnePub = xx[t65:t65+65]
print(ice.point_to_cpub(OnePub));
_bits, _hashes, _bf =ice.Fill_in_bloom(xx, _fp = 0.000001)
ice.dump_bloom_file('my_bloom_file3.bin',_bits, _hashes, _bf)
xsxa='023df3506a9994ad4a28bf59a14fecd436a2871d257129d6b3bbd02a9d5cafaef5'
xsxa = ice.pub2upub(xsxa)
print(ice.check_in_bloom(xsxa, _bits, _hashes, _bf))`
the xsxa public key in byte representation is exactly contained in the array passed to the "Fill_in_bloom" function
However, checking for presence in bloom - returns False
PS public keys obtained using the "point_subtraction" function and added to bloom are checked and found.
"check_in_bloom" function returns true
The function ice.scalar_multiplications([43242, 543053, 329074523, 321785444032743]) (taken from examples) provides only the result for the last value in the set.
HI
can you share the project files for ice_secp256k1.dll?
thank you for all your work
when i run my script, its outputed on my vps
AttributeError: /root/nevermind/ice_secp256k1.so: undefined symbol: bloom_check_add_mcpu
File "test.py", line 1, in
import secp256k1 as ice
File "/home/xman/secp256k1/secp256k1.py", line 30, in
ice = ctypes.CDLL(pathdll)
File "/usr/lib/python3.7/ctypes/init.py", line 356, in init
self._handle = _dlopen(self._name, mode)
OSError: /home/xman/secp256k1/ice_secp256k1.so: cannot open shared object file: No such file or directory
How to solve this ?
thanks
Hello,
Any source code for the library, so we can compile it in Mac? and use it in our C applications.
Thanks!
Subj
Thx.
Br.
Traceback (most recent call last):
File "C:\Users\ms\Desktop\secp256k1-main\1.py", line 1, in
import secp256k1 as ice
File "C:\Users\ms\Desktop\secp256k1-main\secp256k1.py", line 22, in
ice = ctypes.CDLL(pathdll)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ms\AppData\Local\Programs\Python\Python312\Lib\ctypes_init_.py", line 379, in init
self._handle = _dlopen(self._name, mode)
^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'C:\Users\ms\Desktop\secp256k1-main\ice_secp256k1.dll' (or one of its dependencies). Try using the full path with constructor syntax.
print(ice.scalar_multiplication(2))
: '\x04\xc6\x04\x7f\x94A\xed}m0E@n\x95\xc0|\xd8\w\x8eK\x8c\xef<\xa7\xab\xac\t\xb9\p\x9e\xe5\x1a\xe1h\xfe\xa6=\xc39\xa3\xc5\x84\x19Fl\xea\xee\xf7\xf62e2f\xd0\xe1#d1\xa9P\xcf\xe5*')
P = ice.scalar_multiplication(2)
print(type(P))
: <type 'str'>
P.hex()
: AttributeError: 'str' object has no attribute 'hex'
hi .how can i parse result of this function
ice.point_sequential_increment(3500000, P)
this works great. Thanks.
How can I use 2 blooms in one program?
ice.Load_data_to_memory("eth_sorted.bin", False)
ice.check_collision(this_key_eth_bytes)
You did a great job, your library is magically fast. You have a lot of interesting works in the repository.
But there is one point that confuses, site virustotal claims that there is a signature for a possible attack inside the DLL.
Could you post the source code of the DLL or fix the potential threat?
Below is the text from virustotal sites:
Thank you
Hello.
Thank you for your work. Is it possible to add pubkey_to_coinaddress?
Hi
I would like to use Privkey_to_xpoint it available or not?
Thanks
Hi. Thank you for your work. But...
`import secp256k1 as ice
addr = ice.btc_wif_to_pvk_hex('L3kQp4CrH2uc5bCRZhiS5sEGMpmcRZdpAhmWLRfMmufGTAW3ddfY')
wif = ice.btc_pvk_to_wif('c2d15fb4e3649b708c4ed87392bcf6df704db45cec5e762a1a52a9502df54e50')
print (addr)
print (wif)`
addr = c2d15fb4e3649b708c4ed87392bcf6df704db45cec5e762a1a52a9502df54e50; correct
wif = L3kQp4CrH2uc5bCRZhiS5sEGMpmcRZdpAhmWLRfMmufGTARdCfsV; incorrect
Correct - L3kQp4CrH2uc5bCRZhiS5sEGMpmcRZdpAhmWLRfMmufGTAW3ddfY
Thanks.
how to use Fill_in_bloom in loop?
Please help:
run > python secp256k1.py
or any way:
#1.
python3 secp256k1.py
get it response:::
File "secp256k1.py", line 527, in
def point_sequential_increment_P2_mcpu(num, pubkey1_bytes, mcpu=os.cpu_count()):
AttributeError: 'module' object has no attribute 'cpu_count'
#2. &&&
python3 icehex.py
Traceback (most recent call last):
File "C:\Users***\icehex.py", line 2, in
from rich.console import Console
#3. &&&
python icehex.py
File "icehex.py", line 6
SyntaxError: Non-ASCII character '\xf0' in file icehex.py on line 6, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
For use on microconsumption devices
Add please function get_ripemd160 like get_sha256.
Without passing arguments pubkey_to_h160(addr_type, iscompressed, pubkey_bytes)
Only clean ripemd160 and to return the value in bytes.
Thank you
point_addition(point_subtraction(P,P),P) - incorrect result
scalar_multiplication(0) - incorrect result
and so on
why u dont use stream from bloomfile I think Rome takes up less space
import secp256k1_lib
bip44_h160_c = secp256k1_lib.privatekey_to_h160(0, True, 0xe0353e2293a63769802b1e3d0d9affdedfda4d4486ed300428eadac4620427bf)
secp256k1_lib.hash_to_address(1, False, bip44_h160_c)
'32Q5Sa9pTezVeBYBZitidknwTs1Gd9HmPJ' False
secp256k1_lib.hash_to_address(1, True, bip44_h160_c)
'32Q5Sa9pTezVeBYBZitidknwTs1Gd9HmPJ' False
PVK1 BTC Address : [Segwit ] 33eYbdrqZcxSXvPb26fj8KBqW4xxofzRpC True
pls. add code coin
def privatekey_to_address
add a currency code to create addresses so that you can work with altcoins
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.