diff --git a/.gitignore b/.gitignore index f77f5a6..ef7d038 100644 --- a/.gitignore +++ b/.gitignore @@ -68,4 +68,8 @@ openapi-generator-cli.jar .idea -examples/secrets.py \ No newline at end of file +examples/secrets.py + +# Environment variables +.env +.env.* \ No newline at end of file diff --git a/lighter/signer_client.py b/lighter/signer_client.py index 662ad0a..bfb105b 100644 --- a/lighter/signer_client.py +++ b/lighter/signer_client.py @@ -35,6 +35,7 @@ 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" @@ -42,14 +43,15 @@ def _initialize_signer(): path_to_signer_folders = os.path.join(current_file_directory, "signers") if is_arm and is_mac: - logging.debug("Detected ARM architecture on macOS.") 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)." ) diff --git a/lighter/signers/.keep b/lighter/signers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/lighter/signers/README.md b/lighter/signers/README.md index c1e3962..f5295bb 100644 --- a/lighter/signers/README.md +++ b/lighter/signers/README.md @@ -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. \ No newline at end of file +# 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. \ No newline at end of file diff --git a/lighter/signers/signer-amd64.dll b/lighter/signers/signer-amd64.dll new file mode 100644 index 0000000..fad37af Binary files /dev/null and b/lighter/signers/signer-amd64.dll differ diff --git a/lighter/signers/signer-amd64.so b/lighter/signers/signer-amd64.so index 8cba2cd..4818681 100644 Binary files a/lighter/signers/signer-amd64.so and b/lighter/signers/signer-amd64.so differ diff --git a/lighter/signers/signer-arm64.dylib b/lighter/signers/signer-arm64.dylib index d05dd5b..e570d74 100644 Binary files a/lighter/signers/signer-arm64.dylib and b/lighter/signers/signer-arm64.dylib differ