Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ openapi-generator-cli.jar

.idea

examples/secrets.py
examples/secrets.py

# Environment variables
.env
.env.*
8 changes: 5 additions & 3 deletions lighter/signer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@ class StrOrErr(ctypes.Structure):
def _initialize_signer():
is_linux = platform.system() == "Linux"
is_mac = platform.system() == "Darwin"
is_windows = platform.system() == "Windows"
is_x64 = platform.machine().lower() in ("amd64", "x86_64")
is_arm = platform.machine().lower() == "arm64"

current_file_directory = os.path.dirname(os.path.abspath(__file__))
path_to_signer_folders = os.path.join(current_file_directory, "signers")

if is_arm and is_mac:
logging.debug("Detected ARM architecture on macOS.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep the debug logs, and also add one for Win as well?
I merged something about logs which we handled incorrectly in #53 and I think they should be fineish now; they help when people are having issues but IDK. I can go either way.

return ctypes.CDLL(os.path.join(path_to_signer_folders, "signer-arm64.dylib"))
elif is_linux and is_x64:
logging.debug("Detected x64/amd architecture on Linux.")
return ctypes.CDLL(os.path.join(path_to_signer_folders, "signer-amd64.so"))
elif is_windows and is_x64:
return ctypes.CDLL(os.path.join(path_to_signer_folders, "signer-amd64.dll"))
else:
raise Exception(
f"Unsupported platform/architecture: {platform.system()}/{platform.machine()} only supports Linux(x86) and Darwin(arm64)"
f"Unsupported platform/architecture: {platform.system()}/{platform.machine()}. "
"Currently supported: Linux(x86_64), macOS(arm64), and Windows(x86_64)."
)


Expand Down
Empty file removed lighter/signers/.keep
Empty file.
58 changes: 57 additions & 1 deletion lighter/signers/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
Check the [go-sdk](https://github.com/elliottech/lighter-go) to see the source code for the binaries or to generate them youself.
# Lighter Signers

This directory contains various signer implementations for the Lighter Protocol.

## Available Signers

### Native Binary Signers

- `signer-amd64.so` - Linux AMD64 native signer
- `signer-arm64.dylib` - macOS ARM64 native signer
- `signer-amd64.dll` - Windows AMD64 native signer

These binaries are compiled from the Go implementation in [lighter-go](https://github.com/elliottech/lighter-go) and
provide high-performance cryptographic operations for the Lighter Protocol.

## Usage

The Python SDK automatically selects the correct native binary signer based on your platform:

- ✅ **Linux (x86_64)**: Uses `signer-amd64.so`
- ✅ **macOS (ARM64)**: Uses `signer-arm64.dylib`
- ✅ **Windows (x86_64)**: Uses `signer-amd64.dll`

No additional configuration is required - the SDK detects your platform and loads the appropriate signer.

## Building Signers

All native signers are built from the Go implementation in [lighter-go](https://github.com/elliottech/lighter-go).

To build signers locally,Import lighter-go repo:

```bash
# From lighter-go/ directory
just build-linux-local # Linux AMD64
just build-darwin-local # macOS ARM64
just build-windows-local # Windows AMD64
```

Or use Docker for cross-compilation:

```bash
just build-linux-docker
just build-windows-docker
```

## Supported Platforms

The Python SDK supports the following platforms out of the box:

| Platform | Architecture | Binary |
|----------|-----------------------|----------------------|
| Linux | x86_64 | `signer-amd64.so` |
| macOS | ARM64 (Apple Silicon) | `signer-arm64.dylib` |
| Windows | x86_64 | `signer-amd64.dll` |

If you encounter issues with missing binaries, ensure the appropriate signer binary is present in this directory. You
can build it from `lighter-go/` using the commands above.
Binary file added lighter/signers/signer-amd64.dll
Binary file not shown.
Binary file modified lighter/signers/signer-amd64.so
Binary file not shown.
Binary file modified lighter/signers/signer-arm64.dylib
Binary file not shown.