Skip to main content

Blockchain Lab Package

A comprehensive Python package containing various blockchain implementations and cryptographic utilities developed for blockchain laboratory exercises.

Features

  • RSA Key Generator: Generate RSA key pairs using OpenSSL
  • Simple Blockchain: Basic blockchain implementation with proof-of-work
  • Wallet Shell: Interactive crypto wallet shell using Web3
  • Merkle Blockchain: Advanced blockchain with Merkle tree verification
  • Solidity Contracts: Smart contracts including BalanceTransfer and LabCoin

Installation

Option 1: Install from source

cd blockchain-lab-7th-sem
pip install -e .

Option 2: Install dependencies manually

pip install web3

Usage

Import and use modules

# Import the package
import blockchain_lab_package

# List available modules
blockchain_lab_package.list_modules()

# Print source code of any module
blockchain_lab_package.print_source('simple_blockchain')

# Print all source codes
blockchain_lab_package.print_all_sources()

# Print Solidity contracts
blockchain_lab_package.print_solidity_contracts()

# Use individual modules
from blockchain_lab_package import simple_blockchain, rsa_key_generator, solidity_contracts

# Run demonstrations
simple_blockchain.demo()
rsa_key_generator.demo()
solidity_contracts.demo()

Interactive Examples

Simple Blockchain

from blockchain_lab_package.simple_blockchain import Blockchain

# Create a blockchain
chain = Blockchain()
chain.add_block("Alice pays Bob 10 coins")
chain.add_block("Bob pays Charlie 5 coins")

# Validate the chain
print("Valid chain:", chain.is_chain_valid())

RSA Key Generator

from blockchain_lab_package.rsa_key_generator import generate_rsa_keys

# Generate RSA keys
generate_rsa_keys("my_private.pem", "my_public.pem", 2048)

Wallet Shell

from blockchain_lab_package.wallet_shell import start_shell

# Start interactive wallet shell
start_shell()

Merkle Blockchain

from blockchain_lab_package.merkle_blockchain import Blockchain, MerkleTree

# Create advanced blockchain
bc = Blockchain(diff=2)
block = bc.add(["Alice->Bob:5", "Carol->Dave:2"])

# Generate and verify Merkle proof
tree = MerkleTree(block.txs)
proof = tree.proof(0)
is_valid = tree.verify(block.txs[0], proof, tree.root())

Quick Start - Print Source Codes

The primary feature of this package is to easily access and print source codes:

import blockchain_lab_package as blp

# Print specific module source
blp.print_source('rsa_key_generator')
blp.print_source('simple_blockchain')
blp.print_source('wallet_shell')
blp.print_source('merkle_blockchain')
blp.print_source('solidity_contracts')

# Print Solidity contracts only
blp.print_solidity_contracts()

# Or print all at once
blp.print_all_sources()

Requirements

  • Python 3.7+
  • web3 (for wallet shell functionality)
  • OpenSSL (for RSA key generation)

Modules Overview

1. RSA Key Generator (rsa_key_generator)

  • Generate RSA public/private key pairs
  • Uses OpenSSL for secure key generation
  • Configurable key sizes

2. Simple Blockchain (simple_blockchain)

  • Basic blockchain implementation
  • SHA-256 hashing
  • Chain validation
  • Genesis block creation

3. Wallet Shell (wallet_shell)

  • Interactive command-line wallet
  • Web3 integration with Ethereum test provider
  • Send/receive transactions
  • Balance checking
  • Block inspection

4. Merkle Blockchain (merkle_blockchain)

  • Advanced blockchain with Merkle trees
  • Proof-of-work mining
  • Transaction verification
  • Merkle proof generation and verification

5. Solidity Contracts (solidity_contracts)

  • Smart contract source codes
  • BalanceTransfer contract for Ether transfers
  • LabCoin ERC-20 style token contract
  • Contract deployment templates

License

MIT License

Author

Blockchain Lab - Educational Implementation

Metadata

Release files for blockchain-lab-educational 1.1.1

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

Source distribution (sdist)

Source distribution for blockchain-lab-educational 1.1.1
File Size Uploaded Provenance
blockchain_lab_educational-1.1.1.tar.gz 10.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for blockchain-lab-educational 1.1.1
File Interpreter ABI Platform
blockchain_lab_educational-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.3 kB

Release files / blockchain_lab_educational-1.1.1.tar.gz

Download URL blockchain_lab_educational-1.1.1.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9df3eacffc6d0ec694b98a25399499fbfeb07c53e6bc8806658b9cae61c00b94
BLAKE2b-256 checksum
How to use checksums
8147f6f0bb448919b7d967ac5feae01b7dd5826bc6132821da7e132c4e61a507
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / blockchain_lab_educational-1.1.1-py3-none-any.whl

Download URL blockchain_lab_educational-1.1.1-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94f377b6b11016b7cac4567fa89d37796393f60536086aebfd8caac7ccaeb04b
BLAKE2b-256 checksum
How to use checksums
d7de711af131fe29b9565b91dbd222f89f1a81a730014bb4c718b1dfdb52580d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for blockchain-lab-educational 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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