Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions secp256k1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ git clone --recursive https://github.com/diybitcoinhardware/embit.git

This will automatically pull in the `libsecp256k1-zkp` repo and checkout the correct commit within that repo.

Alternatively, if you already have `embit` cloned, run:
```sh
git submodule update --recursive --init
```


## Building the library
This directory (`secp256k1/` in the `embit` root) already has a fully-configured Makefile to run the compilation for you.
Expand All @@ -22,6 +27,37 @@ On your target platform run:
make
```

This creates a platform-specific shared library under `secp256k1/build/`, for
example:

```sh
secp256k1/build/libsecp256k1_linux_x86_64.so
```

## Loading the local build in Python

`embit` looks for local libsecp256k1 artifacts in
`secp256k1/secp256k1-zkp/.libs/` before falling back to system library paths.
After running `make`, expose the helper Makefile output at that lookup path:

```sh
mkdir -p secp256k1-zkp/.libs
ln -sf ../../build/libsecp256k1_$(uname -s | tr A-Z a-z)_$(uname -m).so \
secp256k1-zkp/.libs/libsecp256k1.so
Comment on lines +45 to +46

@qlrd qlrd May 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These files are dynamically generated, right? maybe using find could work too, with less references to .so or .dylib.

Suggested change
ln -sf ../../build/libsecp256k1_$(uname -s | tr A-Z a-z)_$(uname -m).so \
secp256k1-zkp/.libs/libsecp256k1.so
src=$(find build -maxdepth 1 -name 'libsecp256k1_*' -print -quit)
ln -sf "../../$src" "secp256k1-zkp/.libs/libsecp256k1.${src##*.}"

Some output on my mac running this:

 lrwxr-xr-x@ 1 qlrd  staff  43 May 14 XX:XX secp256k1-zkp/.libs/libsecp256k1.dylib -> ../../build/libsecp256k1_darwin_arm64.dylib

```

Run those commands from the `secp256k1/` directory. On macOS, replace the
`.so` suffix with `.dylib`.
Comment on lines +49 to +50

You can verify that Python loaded the native backend from the repository root:

```sh
PYTHONPATH=src python -c "from embit.ec import secp256k1; print(hasattr(secp256k1, 'ecdh'), hasattr(secp256k1, 'rangeproof_rewind'))"
```

Both values should print `True`. If they do, the optional ECDH and Liquid/ZKP
tests can run instead of being skipped.

Install the resulting library into a standard system library location so the dynamic loader can find it (for example `/usr/local/lib` on Unix-like systems), then refresh your linker environment as needed for your platform.

Note: runtime lookup prefers local `secp256k1/secp256k1-zkp/.libs` and system library paths.
Expand Down
Loading