Skip to main content

TwoF

    TwoF is a Python module that uses stored hashes from the blockchain to verify domains and websites. It provides a secure, decentralized method to store cryptographic hashes of website content or domain certificates on the blockchain and retrieve them for verification, ensuring authenticity and integrity against tampering or phishing attempts. By leveraging blockchain's immutability, TwoF offers a trustless way to confirm that a domain or website matches its registered hash.
    
    ## Features
    
    - **Blockchain Hash Storage**: Store hashes of domain certificates, website content, or metadata on supported blockchain networks.
    - **Verification Mechanism**: Retrieve stored hashes from the blockchain and compare them against computed hashes of current domain/website data.
    - **Supported Blockchains**: Integration with <BLOCKCHAIN_NETWORK1> and <BLOCKCHAIN_NETWORK2> via smart contracts or transaction data.
    - **Hash Algorithms**: Support for multiple hashing methods like SHA-256, SHA-512, with salting options.
    - **Domain/Website Fetching**: Automatically fetch and hash website content or SSL certificates for verification.
    - **Error Handling and Security**: Built-in checks for blockchain connectivity, hash mismatches, and secure key management.
    - **Extensible**: Customize blockchain providers, hash functions, or add support for new networks.
    - **Cross-Platform Compatibility**: Works on Windows, macOS, and Linux.
    
    ## Installation
    
    You can install TwoF via pip:
    
    ```bash
    pip install twof
    ```
    
    Alternatively, clone the repository and install from source:
    
    ```bash
    git clone https://github.com/<USER_OR_ORG>/twof.git
    cd twof
    pip install -e .
    ```
    
    ### Requirements
    
    - Python 3.<MIN_VERSION> or higher
    - Dependencies: web3, requests, hashlib (automatically installed via pip where applicable)
    
    ## Quick Start
    
    Import the module, configure blockchain access, and verify a domain:
    
    ```python
    import twof
    
    # Initialize TwoF with blockchain config
    config = {
        'network': '<BLOCKCHAIN_NETWORK>',
        'api_key': '<API_KEY>',
        'contract_address': '<CONTRACT_ADDR>'
    }
    verifier = twof.Verifier(config)
    
    # Verify a domain
    is_valid = verifier.verify_domain('example.com', stored_hash_key='domain_hash_id')
    print(is_valid)  # True if hashes match
    ```
    
    ## Usage
    
    ### Storing Hashes on Blockchain
    
    Store a hash for a domain or website:
    
    ```python
    # Compute hash of website content
    content_hash = twof.compute_hash('https://example.com', mode='content')
    
    # Store on blockchain
    tx_id = verifier.store_hash('domain_hash_id', content_hash)
    print(tx_id)  # Transaction ID on blockchain
    ```
    
    ### Verifying Domains/Websites
    
    Retrieve and compare hashes:
    
    ```python
    # Fetch stored hash from blockchain
    stored_hash = verifier.get_stored_hash('domain_hash_id')
    
    # Compute current hash
    current_hash = twof.compute_hash('https://example.com', mode='certificate')
    
    # Manual verification
    match = stored_hash == current_hash
    ```
    
    ### Supported Modes
    
    - `content`: Hash the HTML content of the website.
    - `certificate`: Hash the SSL/TLS certificate.
    - `metadata`: Hash custom metadata like headers or DNS records.
    
    ## Examples
    
    ### Example 1: Domain Verification Workflow
    
    ```python
    import twof
    
    config = {'network': '<NETWORK>', 'api_key': '<KEY>'}
    verifier = twof.Verifier(config)
    
    # Store initial hash
    initial_hash = twof.compute_hash('https://secure-site.com', mode='content')
    verifier.store_hash('secure_site_hash', initial_hash)
    
    # Later verification
    is_verified = verifier.verify_domain('secure-site.com', 'secure_site_hash')
    if is_verified:
        print("Domain verified successfully.")
    else:
        print("Verification failed: Potential tampering.")
    ```
    
    ### Example 2: Batch Verification
    
    ```python
    import twof
    
    verifier = twof.Verifier(config)
    domains = ['example.com', 'test.com']
    hash_keys = ['ex_hash', 'test_hash']
    
    results = {}
    for domain, key in zip(domains, hash_keys):
        results[domain] = verifier.verify_domain(domain, key)
    
    print(results)  # e.g., {'example.com': True, 'test.com': False}
    ```
    
    ## Configuration Guide
    
    The config dictionary or YAML file must include:
    
    - `network`: Blockchain network (e.g., 'ethereum', 'binance')
    - `api_key`: Provider API key for node access
    - `contract_address`: Smart contract for hash storage (if applicable)
    - `hash_algorithm`: Default hash method (e.g., 'sha256')
    
    For advanced customization, refer to the [docs/config-reference.md](docs/config-reference.md).
    
    ## Contributing
    
    Contributions are welcome! Please follow these steps:
    
    1. Fork the repository.
    2. Create a feature branch (`git checkout -b feature/<FEATURE_NAME>`).
    3. Commit your changes (`git commit -am 'Add some feature'`).
    4. Push to the branch (`git push origin feature/<FEATURE_NAME>`).
    5. Open a Pull Request.
    
    See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
    
    ## License
    
    This project is licensed under the <LICENSE_TYPE> License - see the [LICENSE](LICENSE.md) file for details.
    
    ## Acknowledgments
    
    - Built with inspiration from blockchain security and verification communities.
    - Thanks to contributors of underlying libraries like web3, requests, hashlib.

Metadata

Release files for twof 0.0.1

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

Built distribution (wheel)

Table of built distributions (wheels) for twof 0.0.1
File Interpreter ABI Platform Actions
twof-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ x86-64 Details for twof-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl

Release files / twof-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl

Download URL twof-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl
Size 22.3 kB
Tags CPython 3.12 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
0f795d9b75e4097d827f3c272b94b5a8ce6322713d814f646b664bcfe07c31bc
BLAKE2b-256 checksum
How to use checksums
aca6e34c42fd84920dc9585714396a850a2bddc9292439071b301cb999f780b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for twof 0.0.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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

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