diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 149f3966..6bd22bcd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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##*/} @@ -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 }} @@ -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 }} @@ -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 }} @@ -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 }} @@ -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 }} diff --git a/python/MANIFEST.in b/python/MANIFEST.in index d8f47436..5f4a094b 100644 --- a/python/MANIFEST.in +++ b/python/MANIFEST.in @@ -1 +1 @@ -recursive-include skale_te *.so +recursive-include t_encrypt *.so diff --git a/python/setup.sh b/python/setup.sh index 9105c904..0fbea6cf 100755 --- a/python/setup.sh +++ b/python/setup.sh @@ -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 ============= diff --git a/python/setup_te.py b/python/setup_t_encrypt.py similarity index 80% rename from python/setup_te.py rename to python/setup_t_encrypt.py index 1bfec660..c20525e1 100755 --- a/python/setup_te.py +++ b/python/setup_t_encrypt.py @@ -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): """ @@ -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, diff --git a/python/skale_te/exceptions.py b/python/skale_te/exceptions.py deleted file mode 100644 index 0ab49ff9..00000000 --- a/python/skale_te/exceptions.py +++ /dev/null @@ -1,11 +0,0 @@ -class SkaleTEError(Exception): - """Base exception for skale_te errors.""" - pass - -class LibraryNotFoundError(SkaleTEError): - """Raised when the shared library cannot be found or loaded.""" - pass - -class EncryptionError(SkaleTEError): - """Raised when encryption fails.""" - pass diff --git a/python/skale_te/__init__.py b/python/t_encrypt/__init__.py similarity index 61% rename from python/skale_te/__init__.py rename to python/t_encrypt/__init__.py index 2f5c9733..742e4d0b 100644 --- a/python/skale_te/__init__.py +++ b/python/t_encrypt/__init__.py @@ -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', ] diff --git a/python/skale_te/core.py b/python/t_encrypt/core.py similarity index 99% rename from python/skale_te/core.py rename to python/t_encrypt/core.py index ad973be5..c5a487d4 100644 --- a/python/skale_te/core.py +++ b/python/t_encrypt/core.py @@ -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): diff --git a/python/t_encrypt/exceptions.py b/python/t_encrypt/exceptions.py new file mode 100644 index 00000000..2bb03aa8 --- /dev/null +++ b/python/t_encrypt/exceptions.py @@ -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 diff --git a/threshold_encryption/CMakeLists.txt b/threshold_encryption/CMakeLists.txt index e192ea54..58d6684b 100644 --- a/threshold_encryption/CMakeLists.txt +++ b/threshold_encryption/CMakeLists.txt @@ -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 ) @@ -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() @@ -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,$ -Wl,-force_load,$ -Wl,-force_load,$ 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()