Skip to main content

Educational blockchain implementations with source code printing functionality

Project description

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

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()

# Use individual modules
from blockchain_lab_package import simple_blockchain, rsa_key_generator

# Run demonstrations
simple_blockchain.demo()
rsa_key_generator.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')

# 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

License

MIT License

Author

Blockchain Lab - Educational Implementation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blockchain_lab_educational-1.0.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blockchain_lab_educational-1.0.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file blockchain_lab_educational-1.0.1.tar.gz.

File metadata

File hashes

Hashes for blockchain_lab_educational-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fae8a64a70b949dfef3904165c0aed6648781c3504adc8365405790867a537d7
MD5 84a510cbd2a45cade17412e8774a38c1
BLAKE2b-256 4b20ee0e8cd0bde695cf3101e39f92d1cc39404ff22fbd12376b493d903f3f70

See more details on using hashes here.

File details

Details for the file blockchain_lab_educational-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for blockchain_lab_educational-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 845d479dd32c4ed8105695f82f76d2b592d7494259ce3c3091d8967ea5076585
MD5 9d43c96d8b980ba6a12d41757ed131da
BLAKE2b-256 ac63b59468f5b6fe70fdf279ca7a5f668a80470954b090acef86dd22fca0d65c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page