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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twof-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: twof-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 22.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f795d9b75e4097d827f3c272b94b5a8ce6322713d814f646b664bcfe07c31bc
|
|
| MD5 |
f1d41ef81dc5aa880dc53d50279bdacb
|
|
| BLAKE2b-256 |
aca6e34c42fd84920dc9585714396a850a2bddc9292439071b301cb999f780b6
|