Title: iceland secp256k1 import in python Post by: yoshimitsu777 on January 05, 2023, 01:45:07 PM i downloaded
https://github.com/iceland2k14/secp256k1 into directory /home/yin4/secp256k1 Code: yin4@qq:~ ls secp256k1 when i am inside this directory it works good and i can import with command Code: yin4@qq:~/secp256k1$ python3 but i want to have this working also if i start python3 console from /other/directory i created sys environment variable Code: yin4@qq:/other/directory$ export PYTHONPATH=/home/yin4/secp256k1 Code: yin4@qq:/other/directory$ python3 Code: >>> ice.__ then i try Code: >>> from secp256k1 import secp256k1 as ice what is wrong how can i fix and use library from all directorys? Title: Re: iceland secp256k1 import in python Post by: citb0in on January 05, 2023, 01:57:54 PM I am not a Python expert, but as far as I understand it correctly, it is because the library is not found. Look at line 27 of secp256k1.py there you can see how iceland tries to load the needed ice_secp256k1.so file. You could try to put the absolute path there, e.g. like this:
Code: #dllfile = 'ice_secp256k1.so' this should work but I bet there is a more convenient and best-practice way to achieve this. You will certainly get some better ideas on this from other users... Title: Re: iceland secp256k1 import in python Post by: yoshimitsu777 on January 05, 2023, 03:45:22 PM fantastic now works
thanks. is there more elegant way to solve this? Title: Re: iceland secp256k1 import in python Post by: NotATether on January 05, 2023, 06:13:16 PM fantastic now works thanks. is there more elegant way to solve this? Python has a "get home folder" and "get current directory" functions in tho os module, you can look into those. Especially if you never change directories and just want your CWD to be the same folder your binary (and libs) are located at. Title: Re: iceland secp256k1 import in python Post by: citb0in on January 06, 2023, 01:10:19 PM fantastic now works thanks. is there more elegant way to solve this? yes there is. I have written a patch that allows you to import iceland's secp256k1 module from any folder ==> PATCH (https://github.com/iceland2k14/secp256k1/pull/39/commits/f2b3aefd54b5bcd9d09d2a1e01630ac3bd30d2a0) <== https://i.ibb.co/dMgNBgh/2023-01-06-14-03-45.png (https://ibb.co/dMgNBgh) You can get the patch or clone the patched version from my git repository (https://github.com/citb0in/ice_secp256k1). Without the patch, it would be necessary to change to the directory where iceland's secp256k1 files are located. Then you would run Python console with "python" or "python3" and import the module with: Code: import secp256k1 as ice With the patch you can do it from any working directory, it doesn't matter then which is your working directory. The module will always find its required shared library "ice_secp256k1.so". Additional note: Since many users use both the standard Python module secp256k1 (https://pypi.org/project/secp256k1/) as well as iceland2k14/secp256k1 (https://github.com/iceland2k14/secp256k1) I would personally recommend renaming iceland's module to e.g. ice_secp256k1. Because the two modules are different. This will prevent you from shadowing the other module when importing one of the two modules. I myself have placed all 3rd party python modules in ~/foo/python/modules Iceland's secp256k1 module is located in ~/foo/python/modules/ice_secp256k1 To allow Python to search for modules in ~/foo/python/modules you can use the PYTHONPATH environment variable: Code: export PYTHONPATH=$PYTHONPATH:/home/citb0in/foo/python/modules Code: echo $PYTHONPATH Whenever I need iceland's secp256k1 module, I import it like that: Code: python3 Whenever I need Python's standard module "secp256k1" I just ue Code: import secp256k1 This way you can clearly distinguish between the two modules with the same name and you do not run the risk of confusion and problems. Title: Re: iceland secp256k1 import in python Post by: COBRAS on January 06, 2023, 05:25:13 PM :-XHow to use this lib for scalar to scalar/number's multiplication , addition, substraction ?
what function of modular inversion ? Br Title: Re: iceland secp256k1 import in python Post by: citb0in on January 06, 2023, 05:27:09 PM RTFM and see what functions are available and how they are used?
https://github.com/iceland2k14/secp256k1/blob/main/README.md Title: Re: iceland secp256k1 import in python Post by: COBRAS on January 06, 2023, 05:41:26 PM RTFM and see what functions are available and how they are used? https://github.com/iceland2k14/secp256k1/blob/main/README.md Can't find function for scalar. Only mul pub to priv, no function priv * priv for ex. Title: Re: iceland secp256k1 import in python Post by: citb0in on January 06, 2023, 05:51:59 PM RTFM and see what functions are available and how they are used? https://github.com/iceland2k14/secp256k1/blob/main/README.md Can't find function for scalar. Only mul pub to priv, no function priv * priv for ex. https://github.com/iceland2k14/secp256k1/blob/main/secp256k1.py you can only use what's available or develop and extend the program and contribute to the project Title: Re: iceland secp256k1 import in python Post by: yoshimitsu777 on January 07, 2023, 12:17:01 PM ecdsa123 is not human but ai bot and posting into forum with crazy things not fitting to topic or without questions.
this bot tries to reply in context but often fails see here https://bitcointalk.org/index.php?topic=5433136.msg61556811#msg61556811 https://bitcointalk.org/index.php?topic=5433027.msg61544585#msg61544585 https://bitcointalk.org/index.php?topic=5432839.msg61542178#msg61542178 ecdsa123 (https://bitcointalk.org/index.php?action=profile;u=3476535) is same bot as Nt013 (https://bitcointalk.org/index.php?action=profile;u=3526597) and some other names in forum Quote from: citb0in yes there is. I have written a patch that allows you to import iceland's secp256k1 module from any folder perfect==> PATCH (https://github.com/iceland2k14/secp256k1/pull/39/commits/f2b3aefd54b5bcd9d09d2a1e01630ac3bd30d2a0) <== You can get the patch or clone the patched version from my git repository (https://github.com/citb0in/ice_secp256k1). thanks a lot |