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
38 changes: 19 additions & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
export TARGET=all
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo

- name: Build
run: |
export CC=gcc-11
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
emmake make -j$(nproc)
cd ..
cp build_em/threshold_encryption/encrypt.* node/

- name: Calculate version
run: |
export BRANCH=${GITHUB_REF##*/}
Expand All @@ -111,36 +111,36 @@ jobs:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

- name: Resolve skale_te version and library path
- name: Resolve t-encrypt version and library path
run: |
lib_path="${PWD}/build/threshold_encryption/libskale_te_python.so"
echo "SKALE_TE_LIB_PATH=${lib_path}" >> "$GITHUB_ENV"
lib_path="${PWD}/build/threshold_encryption/libt_encrypt_python.so"
echo "T_ENCRYPT_LIB_PATH=${lib_path}" >> "$GITHUB_ENV"

# Calculate Python package version
cd python
BASE_VERSION=$(python3 setup_te.py --version)
BASE_VERSION=$(python3 setup_t_encrypt.py --version)
cd ..
PACKAGE_NAME="skale-te"

PACKAGE_NAME="t-encrypt"
VERSION=$(bash ./scripts/calculate_version_pypi.sh $PACKAGE_NAME $BASE_VERSION ${{ env.BRANCH }})

echo "PACKAGE_VERSION=${VERSION}" >> "$GITHUB_ENV"

echo "Using lib: ${lib_path}"
echo "Publishing skale-te version: ${VERSION}"
echo "Publishing t-encrypt version: ${VERSION}"

- name: Build skale-te Python distributions
- name: Build t-encrypt Python distributions
working-directory: python
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
SKALE_TE_LIB_PATH: ${{ env.SKALE_TE_LIB_PATH }}
T_ENCRYPT_LIB_PATH: ${{ env.T_ENCRYPT_LIB_PATH }}
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel twine
python setup_te.py sdist bdist_wheel
python setup_t_encrypt.py sdist bdist_wheel
python -m twine check dist/*

- name: Publish skale-te to PyPI
- name: Publish t-encrypt to PyPI
working-directory: python
env:
TWINE_USERNAME: ${{ secrets.PIP_USERNAME }}
Expand All @@ -153,7 +153,7 @@ jobs:
run: |
cd node
export PACKAGE_NAME=$(jq -r '.name' package.json)
export JS_LIBRARY_BASE_VERSION="$(npm run --silent version)"
export JS_LIBRARY_BASE_VERSION="$(npm run --silent version)"
export JS_LIBRARY_VERSION=$(bash ./../scripts/calculate_version_npm.sh $PACKAGE_NAME $JS_LIBRARY_BASE_VERSION $BRANCH)
npm version $JS_LIBRARY_VERSION --no-git-tag-version
npm publish --access public --tag ${{ env.BRANCH }}
Expand All @@ -180,7 +180,7 @@ jobs:

- name: Upload bls_glue to Release
uses: actions/upload-release-asset@latest
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
Expand All @@ -190,7 +190,7 @@ jobs:

- name: Upload hash_g1 to Release
uses: actions/upload-release-asset@latest
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
Expand All @@ -200,7 +200,7 @@ jobs:

- name: Upload verify_bls to Release
uses: actions/upload-release-asset@latest
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
Expand Down
2 changes: 1 addition & 1 deletion python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
recursive-include skale_te *.so
recursive-include t_encrypt *.so
10 changes: 5 additions & 5 deletions python/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ ldd ./build/lib.linux-x86_64-3.6/dkgpython.cpython-36m-x86_64-linux-gnu.so
mv ./build/lib.linux-x86_64-3.6/dkgpython.cpython-36m-x86_64-linux-gnu.so dkgpython.so
echo ================ setup done ===============

echo ================ building skale_te ===============
# Note: This assumes libskale_te_python.so has been built in ../build/ via cmake
python3 $CWD/setup_te.py install --user
echo ================ building t-encrypt ===============
# Note: This assumes libt_encrypt_python.so has been built in ../build/ via cmake
python3 $CWD/setup_t_encrypt.py install --user
if [[ $? -ne 0 ]] ; then
echo "Error installing skale_te. Ensure you have built the C++ library (make skale_te_python)"
echo "Error installing t-encrypt. Ensure you have built the C++ library (make t_encrypt_python)"
exit 1
fi
echo ================ setup skale_te done =============
echo ================ setup t-encrypt done =============
14 changes: 7 additions & 7 deletions python/setup_te.py → python/setup_t_encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
from setuptools.command.build_py import build_py

# Configuration
PACKAGE_NAME = 'skale_te'
PACKAGE_NAME = 't_encrypt'
LIB_NAME = 'libencrypt.so'
BUILD_TARGET_NAME = 'libskale_te_python.so'
BUILD_TARGET_NAME = 'libt_encrypt_python.so'


def resolve_built_library_path() -> str:
override_path = os.environ.get('SKALE_TE_LIB_PATH')
override_path = os.environ.get('T_ENCRYPT_LIB_PATH')
if override_path:
if not os.path.exists(override_path):
raise FileNotFoundError(
f"SKALE_TE_LIB_PATH points to missing file: {override_path}"
f"T_ENCRYPT_LIB_PATH points to missing file: {override_path}"
)
return override_path
else:
raise RuntimeError(
"Environment variable SKALE_TE_LIB_PATH is not set. ")
"Environment variable T_ENCRYPT_LIB_PATH is not set. ")

class CustomBuildPy(build_py):
"""
Expand All @@ -40,14 +40,14 @@ def run(self):
super().run()

setup(
name='skale-te',
name='t-encrypt',
version='0.0.1',
description='Python bindings for SKALE Threshold Encryption',
author='SKALE Network',
packages=find_packages(),
include_package_data=True,
package_data={
'skale_te': ['*.so'],
't_encrypt': ['*.so'],
},
cmdclass={
'build_py': CustomBuildPy,
Expand Down
11 changes: 0 additions & 11 deletions python/skale_te/exceptions.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
This module provides a Python interface to the SKALE Threshold Encryption C++ library.
This module provides a Python interface to the t-encrypt C++ library.
It allows encrypting messages using BLS keys.
"""
from .core import encrypt_message, encrypt_message_dual_key, encrypt_message_mockup
from .exceptions import SkaleTEError, LibraryNotFoundError, EncryptionError
from .exceptions import TEncryptError, LibraryNotFoundError, EncryptionError

__all__ = [
'encrypt_message',
'encrypt_message_dual_key',
'encrypt_message_mockup',
'SkaleTEError',
'TEncryptError',
'LibraryNotFoundError',
'EncryptionError',
]
2 changes: 1 addition & 1 deletion python/skale_te/core.py → python/t_encrypt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _load_library():
# Check if we can find it in common build locations relative to this file
current_dir = os.path.dirname(__file__)
possible_paths = [
os.path.abspath(os.path.join(current_dir, '../../build/threshold_encryption/libskale_te_python.so')),
os.path.abspath(os.path.join(current_dir, '../../build/threshold_encryption/libt_encrypt_python.so')),
]
for path in possible_paths:
if os.path.exists(path):
Expand Down
11 changes: 11 additions & 0 deletions python/t_encrypt/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class TEncryptError(Exception):
"""Base exception for t-encrypt errors."""
pass

class LibraryNotFoundError(TEncryptError):
"""Raised when the shared library cannot be found or loaded."""
pass

class EncryptionError(TEncryptError):
"""Raised when encryption fails."""
pass
20 changes: 10 additions & 10 deletions threshold_encryption/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ if (LIBBLS_BUILD_TESTS)
# Helper function to add tests
function(add_te_test name source)
add_executable(${name} ${source} ../test/utils.cpp) # Includes utils only for tests
target_include_directories(${name} SYSTEM PRIVATE
${THIRD_PARTY_DIR}
target_include_directories(${name} SYSTEM PRIVATE
${THIRD_PARTY_DIR}
boost_program_options
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
../test
)

Expand All @@ -89,13 +89,13 @@ if (LIBBLS_BUILD_TESTS)
add_test(NAME te_tests COMMAND te_unit_test)

if(NOT EMSCRIPTEN AND NOT APPLE)
add_executable(te_sample_sgx ../test/te_sample_sgx.cpp ../test/utils.cpp)
add_executable(te_sample_sgx ../test/te_sample_sgx.cpp ../test/utils.cpp)
target_include_directories(te_sample_sgx SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${THIRD_PARTY_DIR} ../test)
target_link_libraries(te_sample_sgx PRIVATE te bls ${CRYPTOPP_LIBRARY} jsonrpccpp-client jsonrpccpp-server jsonrpccpp-common jsoncpp curl pthread ssl crypto z idn2)
endif()

if(NOT EMSCRIPTEN AND NOT APPLE)
add_executable(decrypt_message ../tools/decryptMessage.cpp)
add_executable(decrypt_message ../tools/decryptMessage.cpp)
target_include_directories(decrypt_message SYSTEM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${THIRD_PARTY_DIR})
target_link_libraries(decrypt_message PRIVATE te bls ${CRYPTOPP_LIBRARY})
endif()
Expand Down Expand Up @@ -125,19 +125,19 @@ endif()

if (NOT EMSCRIPTEN)
# Build python threshold_encryption shared library
add_library(skale_te_python SHARED ../threshold_encryption/encryptMessage.cpp)
add_library(t_encrypt_python SHARED ../threshold_encryption/encryptMessage.cpp)
get_directory_property(PARENT_DIR PARENT_DIRECTORY)
target_include_directories(skale_te_python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${PARENT_DIR})
target_include_directories(t_encrypt_python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${PARENT_DIR})
if(APPLE)
target_link_libraries(skale_te_python PRIVATE
target_link_libraries(t_encrypt_python PRIVATE
-Wl,-force_load,$<TARGET_FILE:te>
-Wl,-force_load,$<TARGET_FILE:bls>
-Wl,-force_load,$<TARGET_FILE:common_utils>
backend ${FOLLY_STATIC_LIBS} ${CRYPTOPP_LIBRARY})
# Explicitly add dependencies for Apple builds because they are hidden inside linker flags
add_dependencies(skale_te_python te bls common_utils)
add_dependencies(t_encrypt_python te bls common_utils)
else()
target_link_libraries(skale_te_python PRIVATE
target_link_libraries(t_encrypt_python PRIVATE
-Wl,--whole-archive te bls common_utils -Wl,--no-whole-archive
backend ${FOLLY_STATIC_LIBS} ${CRYPTOPP_LIBRARY})
endif()
Expand Down
Loading