gcevm-sdk


Namegcevm-sdk JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/soda-mpc/soda-sdk
SummarySoda SDK - Cryptographic functions for Soda Labs blockchain
upload_time2025-11-04 15:19:36
maintainerNone
docs_urlNone
authorSoda Labs
requires_python>=3.7
licenseMIT
keywords cryptography aes rsa ecdsa blockchain sodalabs mpc garbled-circuits encryption privacy
VCS
bugtrack_url
requirements pycryptodome eth-keys cryptography web3
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Soda-sdk

This SDK provides functionalities for AES and RSA encryption schemes, ECDSA signature scheme and some functionalities used for working with sodalabs interface.

## Table of Contents

- [Available functionalities](#available-functionalities)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Running tests](#running-tests)


## Available functionalities

The SDK supports the following functionalities:

* AES encryption scheme:

    * Generate AES key  
    * Write AES key
    * Load AES key
    * Encrypt
    * Decrypt

* RSA encryption scheme:

    * Generate RSA key pair
    * Encrypt
    * Decrypt

* ECDSA signature scheme:
    * Generate ECDSA private key
    * Sign

* Hash:
    * Keccak 256

* Functionalities related to sodalabs InputText: 
    * Sign InputText function

        This function gets:
        - sender address bytes
        - contract address bytes
        - hashed function signature bytes
        - ciphertext bytes
        - ECDSA private key bytes.

        It appends the addresses, signature and ciphertext and signs the appended string using the private key.

    * Verify IT (Available only in Golang)
        This function gets:
        - sender address bytes
        - contract address bytes
        - hashed function signature bytes
        - ciphertext bytes
        - signature

        It verify the signature against the received data

    * Prepare InputText function

        This function gets:
        - plaintext 
        - AES key 
        - sender address
        - contract address
        - function signature (as string in go and python case, or hashed in js case)
        - ECDSA private key.

        It encrypt the plaintext using the AES key to get the ciphertext, then sign the concatination of the addresses, hashed function signature and ciphertext using the ECDSA private key.
    * Get function signature

        This function get the function signature as a string and returned the keccak-256 value on the signature


### Prerequisites

Python should be installed on your system.

### Installation

```bash
pip install gcevm-sdk
```


### Usage

In order to use the functionalities of python SDK, first import the required modules. For example:

```python
from soda_python_sdk import prepare_IT, decrypt, get_func_sig, BLOCK_SIZE
from web3 import Account
from eth_keys import keys
```

Below is an example function that demonstrates using some of the SDK functionality. Let's break it down:

```python
def test_prepareIT(self):
    # Create inputs for prepare_IT function
    plaintext = 100                                                     # plaintext 
    userKey = bytes.fromhex("b3c3fe73c1bb91862b166a29fe1d63e9")         # AES key
    sender = Account()                                                  # Sender account
    sender.address = "0xd67fe7792f18fbd663e29818334a050240887c28"
    contract = Account()                                                # Contract account
    contract.address = "0x69413851f025306dbe12c48ff2225016fc5bbe1b"
    func_sig = "test(bytes)"                                            # function signature as string
    signingKey = bytes.fromhex("3840f44be5805af188e9b42dda56eb99eefc88d7a6db751017ff16d0c5f8143e")  # ECDSA private key

    # Call prepare_IT function with the plaintext, AES key, sender and contract accounts, function signature and ECDSA private key
    ct, signature = prepare_IT(plaintext, userKey, sender, contract, func_sig, signingKey)
    # prepare_IT returns the ciphertext and the signature

    # Verify the signature
    sender_address_bytes = bytes.fromhex(sender.address[2:])     # Get the bytes of the accounts addresses
    contract_address_bytes = bytes.fromhex(contract.address[2:])
    func_hash = get_func_sig(func_sig)                           # Create the function signature
    
    # Convert the integer to a byte slice with size aligned to 8
    ctBytes = ct.to_bytes((ct.bit_length() + 7) // 8, 'big')
    
    # Create the signed message 
    message = sender_address_bytes + contract_address_bytes + func_hash + ctBytes
    pk = keys.PrivateKey(signingKey)
    signature_obj = keys.Signature(signature)
    # Verify the signature against the message hash and the public key
    verified = signature_obj.verify_msg(message, pk.public_key)
    self.assertEqual(verified, True)

    # Decrypt the ciphertext using the AES key and check the decrypted value against the original plaintext
    # ctBytes is divided into two components: random and encrypted data. The decrypt function processes each component separately. 
    decrypted = decrypt(userKey, ctBytes[BLOCK_SIZE:], ctBytes[:BLOCK_SIZE])
    decrypted_integer = int.from_bytes(decrypted, 'big')
    self.assertEqual(plaintext, decrypted_integer)
```

This example uses the prepare_IT and decrypt functionalities of the python SDK.
More examples can be found in the test.py file.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/soda-mpc/soda-sdk",
    "name": "gcevm-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "cryptography, aes, rsa, ecdsa, blockchain, sodalabs, mpc, garbled-circuits, encryption, privacy",
    "author": "Soda Labs",
    "author_email": "meital@sodalabs.xyz",
    "download_url": "https://files.pythonhosted.org/packages/92/73/926fb4275a5e72b6c825ef9abea28551ff7bc814c1bb81a0ffe1276399c7/gcevm_sdk-0.0.5.tar.gz",
    "platform": null,
    "description": "# Soda-sdk\n\nThis SDK provides functionalities for AES and RSA encryption schemes, ECDSA signature scheme and some functionalities used for working with sodalabs interface.\n\n## Table of Contents\n\n- [Available functionalities](#available-functionalities)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Running tests](#running-tests)\n\n\n## Available functionalities\n\nThe SDK supports the following functionalities:\n\n* AES encryption scheme:\n\n    * Generate AES key  \n    * Write AES key\n    * Load AES key\n    * Encrypt\n    * Decrypt\n\n* RSA encryption scheme:\n\n    * Generate RSA key pair\n    * Encrypt\n    * Decrypt\n\n* ECDSA signature scheme:\n    * Generate ECDSA private key\n    * Sign\n\n* Hash:\n    * Keccak 256\n\n* Functionalities related to sodalabs InputText: \n    * Sign InputText function\n\n        This function gets:\n        - sender address bytes\n        - contract address bytes\n        - hashed function signature bytes\n        - ciphertext bytes\n        - ECDSA private key bytes.\n\n        It appends the addresses, signature and ciphertext and signs the appended string using the private key.\n\n    * Verify IT (Available only in Golang)\n        This function gets:\n        - sender address bytes\n        - contract address bytes\n        - hashed function signature bytes\n        - ciphertext bytes\n        - signature\n\n        It verify the signature against the received data\n\n    * Prepare InputText function\n\n        This function gets:\n        - plaintext \n        - AES key \n        - sender address\n        - contract address\n        - function signature (as string in go and python case, or hashed in js case)\n        - ECDSA private key.\n\n        It encrypt the plaintext using the AES key to get the ciphertext, then sign the concatination of the addresses, hashed function signature and ciphertext using the ECDSA private key.\n    * Get function signature\n\n        This function get the function signature as a string and returned the keccak-256 value on the signature\n\n\n### Prerequisites\n\nPython should be installed on your system.\n\n### Installation\n\n```bash\npip install gcevm-sdk\n```\n\n\n### Usage\n\nIn order to use the functionalities of python SDK, first import the required modules. For example:\n\n```python\nfrom soda_python_sdk import prepare_IT, decrypt, get_func_sig, BLOCK_SIZE\nfrom web3 import Account\nfrom eth_keys import keys\n```\n\nBelow is an example function that demonstrates using some of the SDK functionality. Let's break it down:\n\n```python\ndef test_prepareIT(self):\n    # Create inputs for prepare_IT function\n    plaintext = 100                                                     # plaintext \n    userKey = bytes.fromhex(\"b3c3fe73c1bb91862b166a29fe1d63e9\")         # AES key\n    sender = Account()                                                  # Sender account\n    sender.address = \"0xd67fe7792f18fbd663e29818334a050240887c28\"\n    contract = Account()                                                # Contract account\n    contract.address = \"0x69413851f025306dbe12c48ff2225016fc5bbe1b\"\n    func_sig = \"test(bytes)\"                                            # function signature as string\n    signingKey = bytes.fromhex(\"3840f44be5805af188e9b42dda56eb99eefc88d7a6db751017ff16d0c5f8143e\")  # ECDSA private key\n\n    # Call prepare_IT function with the plaintext, AES key, sender and contract accounts, function signature and ECDSA private key\n    ct, signature = prepare_IT(plaintext, userKey, sender, contract, func_sig, signingKey)\n    # prepare_IT returns the ciphertext and the signature\n\n    # Verify the signature\n    sender_address_bytes = bytes.fromhex(sender.address[2:])     # Get the bytes of the accounts addresses\n    contract_address_bytes = bytes.fromhex(contract.address[2:])\n    func_hash = get_func_sig(func_sig)                           # Create the function signature\n    \n    # Convert the integer to a byte slice with size aligned to 8\n    ctBytes = ct.to_bytes((ct.bit_length() + 7) // 8, 'big')\n    \n    # Create the signed message \n    message = sender_address_bytes + contract_address_bytes + func_hash + ctBytes\n    pk = keys.PrivateKey(signingKey)\n    signature_obj = keys.Signature(signature)\n    # Verify the signature against the message hash and the public key\n    verified = signature_obj.verify_msg(message, pk.public_key)\n    self.assertEqual(verified, True)\n\n    # Decrypt the ciphertext using the AES key and check the decrypted value against the original plaintext\n    # ctBytes is divided into two components: random and encrypted data. The decrypt function processes each component separately. \n    decrypted = decrypt(userKey, ctBytes[BLOCK_SIZE:], ctBytes[:BLOCK_SIZE])\n    decrypted_integer = int.from_bytes(decrypted, 'big')\n    self.assertEqual(plaintext, decrypted_integer)\n```\n\nThis example uses the prepare_IT and decrypt functionalities of the python SDK.\nMore examples can be found in the test.py file.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Soda SDK - Cryptographic functions for Soda Labs blockchain",
    "version": "0.0.5",
    "project_urls": {
        "Bug Reports": "https://github.com/soda-mpc/soda-sdk/issues",
        "Documentation": "https://github.com/soda-mpc/soda-sdk#readme",
        "Homepage": "https://github.com/soda-mpc/soda-sdk",
        "Source": "https://github.com/soda-mpc/soda-sdk"
    },
    "split_keywords": [
        "cryptography",
        " aes",
        " rsa",
        " ecdsa",
        " blockchain",
        " sodalabs",
        " mpc",
        " garbled-circuits",
        " encryption",
        " privacy"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "390b9b7dfeafb4760956b671c3f320d6f79c76c13182c8f8d5e017aad24c1110",
                "md5": "b724411a1d1fa52b2a952f73e230bdc5",
                "sha256": "96535d0a131f8e0d767837b99ceb0633e865573b9ec4ae66b778ae005af98824"
            },
            "downloads": -1,
            "filename": "gcevm_sdk-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b724411a1d1fa52b2a952f73e230bdc5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9744,
            "upload_time": "2025-11-04T15:19:35",
            "upload_time_iso_8601": "2025-11-04T15:19:35.585029Z",
            "url": "https://files.pythonhosted.org/packages/39/0b/9b7dfeafb4760956b671c3f320d6f79c76c13182c8f8d5e017aad24c1110/gcevm_sdk-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9273926fb4275a5e72b6c825ef9abea28551ff7bc814c1bb81a0ffe1276399c7",
                "md5": "bc44f85957c5eb91d7f0326d5b0eadcc",
                "sha256": "ce64d42e5d5b550eb6f75279cf3866ab11af61eef58867c7036061027c9ec475"
            },
            "downloads": -1,
            "filename": "gcevm_sdk-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "bc44f85957c5eb91d7f0326d5b0eadcc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 11679,
            "upload_time": "2025-11-04T15:19:36",
            "upload_time_iso_8601": "2025-11-04T15:19:36.890682Z",
            "url": "https://files.pythonhosted.org/packages/92/73/926fb4275a5e72b6c825ef9abea28551ff7bc814c1bb81a0ffe1276399c7/gcevm_sdk-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-04 15:19:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "soda-mpc",
    "github_project": "soda-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pycryptodome",
            "specs": [
                [
                    ">=",
                    "3.10.0"
                ]
            ]
        },
        {
            "name": "eth-keys",
            "specs": [
                [
                    ">=",
                    "0.3.3"
                ]
            ]
        },
        {
            "name": "cryptography",
            "specs": [
                [
                    ">=",
                    "3.4.7"
                ]
            ]
        },
        {
            "name": "web3",
            "specs": [
                [
                    "==",
                    "6.11.2"
                ]
            ]
        }
    ],
    "lcname": "gcevm-sdk"
}
        
Elapsed time: 1.55053s