Skip to main content

Mind Network Randgen Hub Voter CLI & SDK

A Python-based Command Line Interface (CLI) and Software Development Kit (SDK) for interacting with the Randgen Hub on the Mind Network. This tool facilitates voter registration, reward checking, encryption, and secure anonymous voting using Fully Homomorphic Encryption (FHE).

The hub is live and accessible at Randgen Hub.


Features

  • Voter Registration: Register for voting in the Randgen Hub.
  • Reward Checking: Retrieve rewards linked to your wallet after voting.
  • Anonymous Voting: Cast encrypted votes in a secure and privacy-preserving manner using FHE.
  • Encryption: Encrypt data with the FHE keyset.
  • Vote Submission: Submit encrypted votes to the Randgen Hub.
  • Continuous Voting: Automatically vote in eligible rounds using the vote_nonstop functionality.
  • Python SDK for Integration: Use the SDK to integrate these features into your Python projects.

Installation

Prerequisites

  • Python 3.10+

Steps

  1. Clone the repository:

    git clone https://github.com/mind-network/mind-sdk-randgen-py.git
    
  2. Navigate to the project directory:

    cd mind-sdk-randgen-py
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Copy default configuration and modify as needed:

    cp mind_randgen_sdk/configs/default_config.json mind_randgen_sdk/configs/config.json
    
  5. Run the CLI:

    python cli.py --help
    

CLI Usage

The CLI provides commands to interact with the Randgen Hub. Below is a list of available commands:

register-voter

Registers a voter in the Randgen Hub.

python cli.py register-voter [--hot-wallet-private-key <key>] [--cold-wallet-address <address>]
  • Options:
    • --hot-wallet-private-key (optional): Private key of the hot wallet.
    • --cold-wallet-address (optional): Address of the cold wallet for receiving rewards.

check-voting-reward

Checks voting rewards for a specific wallet.

python cli.py check-voting-reward [--cold-wallet-address <address>]
  • Options:
    • --cold-wallet-address (optional): Address of the cold wallet.

print-fhe-keyset

Displays the Fully Homomorphic Encryption (FHE) keyset.

python cli.py print-fhe-keyset

encrypt

Encrypts a number using FHE.

python cli.py encrypt <number>
  • Arguments:
    • <number>: The number to encrypt.

submit-vote

Submits a vote using an encrypted ciphertext URL.

python cli.py submit-vote <ciphertextUrl> [--hot-wallet-private-key <key>]
  • Arguments:
    • <ciphertextUrl>: URL of the encrypted vote.
    • --hot-wallet-private-key (optional): Private key of the hot wallet.

vote-nonstop

Continuously votes in every eligible round of the Randgen Hub.

python cli.py vote-nonstop [--hot-wallet-private-key <key>]
  • Options:
    • --hot-wallet-private-key (optional): Private key of the hot wallet.

Using as an SDK

You can integrate this project into your Python applications programmatically by importing the RandgenLib class.

Installation

Install the SDK using pip:

pip install mind_randgen_sdk

Available Methods

The following methods are provided by the SDK:

  • register_voter(cold_wallet_address: str): Register a voter in the Randgen Hub.
  • check_cold_wallet_reward(cold_wallet_address: str): Check rewards associated with a cold wallet.
  • fetch_fhe_keyset(): Retrieve the FHE keyset.
  • encrypt(num: int): Encrypt a number using the FHE keyset.
  • submit_vote(cypher_text_url: str): Submit an encrypted vote.
  • vote_continuously(): Continuously vote in all eligible rounds.

Code Example

Below is an example of generating a random number, encrypting it, and submitting a vote:

from mind_randgen_sdk import RandgenLib

# Initialize the library
configs = {
    "hot_wallet_private_key": "your_private_key",
    "other_config_values": "..."
}
lib = RandgenLib(configs=configs)

# Generate a random number
random_number = 42
print(f"Generated random number: {random_number}")

# Encrypt the random number
encrypted_url = lib.encrypt(num=random_number)
print(f"Encrypted URL: {encrypted_url}")

# Submit the vote
result = lib.submit_vote(cypher_text_url=encrypted_url)
print("Vote submission result:", result)

Configuration

The CLI uses a configuration file located at configs/config.json if the file is present. For reference on the required settings, you can check the default configuration file at configs/default_config.json.


License

This project is licensed under the MIT License.


Contact

For questions or support, please contact Mind Network Official Channels.

Metadata

Release files for mind-randgen-sdk 0.9.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mind-randgen-sdk 0.9.3
File Size Uploaded
mind_randgen_sdk-0.9.3.tar.gz 787.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mind-randgen-sdk 0.9.3
File Interpreter ABI Platform
mind_randgen_sdk-0.9.3-py3-none-any.whl Python 3 none any Details

Total release size: 1.6 MB

Release files / mind_randgen_sdk-0.9.3.tar.gz

Download URL mind_randgen_sdk-0.9.3.tar.gz
Size 787.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bc71f2b4d9ac84b77497df3e3c4178459197c656cd21536fcc8d5112c1b20dfe
BLAKE2b-256 checksum
How to use checksums
ce103a617430bd7eba2bf6b5e5387ab9b0499b2196aa700598247ede5e65ac8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / mind_randgen_sdk-0.9.3-py3-none-any.whl

Download URL mind_randgen_sdk-0.9.3-py3-none-any.whl
Size 800.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8d60d96feec13a3ce8419113c74b43a1a8e8cc26f1d0dd653a6ef2f28db4ffe
BLAKE2b-256 checksum
How to use checksums
c8d3d545d674d25aed8aab42a283471f323e8eaaf4d6193d83852d83a7a60af6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.9.3 This release

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page