Skip to main content

ChainGuard: A Secure Data Transformation and Transfer Protocol using Blockchain Technology

Project description

Chagu

ChainGuard

graph TD
    subgraph Users and Entities
        A[User]:::userColor
        B[Entity]:::userColor
    end

    subgraph Data Request and Transfer
        C[Data Requested]:::dataColor
        D[Data Sent]:::dataColor
        E[Data Received]:::dataColor
    end

    subgraph Secure Transmission
        F[AES Encryption]:::encryptionColor
        G[Secure Data Transfer]:::encryptionColor
    end

    subgraph Anomaly Detection
        H[Anomaly Detection Model]:::anomalyColor
    end

    subgraph Blockchain and Traceability
        I[Blockchain Transaction]:::blockchainColor
        J[Blockchain Ledger]:::blockchainColor
        K[Neo4j Trace]:::traceColor
    end

    %% Flow of Data
    A -->|Requests Data| C
    C -->|Encrypted with AES| F
    F -->|Transfers Data Securely| G
    G -->|Data Sent| D
    D -->|Logs Transaction| I
    I -->|Recorded in Ledger| J
    I -->|Creates Trace| K
    D -->|Receives Data| E
    E -->|Analyzes Data| H
    H -->|Flags Anomalies| K
    B -->|Receives Data| E

    %% Highlight Flow Arrows
    classDef flowColor stroke:#FF5733,stroke-width:4px;
    class C,F,G,D,I,J,K flowColor;

    %% Define Colors
    classDef userColor fill:#FFDDC1,stroke:#333,stroke-width:2px,color:#333;
    classDef dataColor fill:#C1E1C5,stroke:#333,stroke-width:2px,color:#333;
    classDef encryptionColor fill:#FADBD8,stroke:#333,stroke-width:2px,color:#333;
    classDef anomalyColor fill:#F9EBEA,stroke:#333,stroke-width:2px,color:#333;
    classDef blockchainColor fill:#D4E6F1,stroke:#333,stroke-width:2px,color:#333;
    classDef traceColor fill:#FCF3CF,stroke:#333,stroke-width:2px,color:#333;

Nodes:

Network Traffic Data: Represents the source of data that is analyzed by the anomaly detection model. Anomaly Detection Model: Scans network traffic data to flag anomalies. Anomaly Node in Neo4j: Represents flagged anomalies stored as nodes in the Neo4j database. Blockchain Transaction: Represents a transaction recorded in the blockchain. Blockchain Node in Neo4j: Represents a blockchain transaction stored as a node in Neo4j. Secure Data Transfer: Represents the secure transfer of data between nodes. AES Encryption: The method used to encrypt and decrypt the data during transfer. Blockchain Network: The network where transactions are recorded. Anomaly Detection Results: Results of anomaly detection stored in Neo4j.

Relationships:

Scanned by: Indicates the process of scanning network traffic data by the anomaly detection model. Flags anomalies: Shows that the model flags anomalies and creates corresponding nodes in Neo4j. DETECTED_IN: Relationship between an anomaly and a blockchain transaction where the anomaly was detected. Sends encrypted data: Indicates the data transfer process using AES encryption. Receives encrypted data: Represents the reception of encrypted data. Records Transactions: Indicates that the blockchain network records transactions in the blockchain. Stored in: Represents the storage of anomaly detection results in the Neo4j graph database. Interaction: Shows the interaction between secure data transfer and the anomaly detection model. ChainGuard is a custom protocol designed for secure data transformation using blockchain technology. It leverages AES encryption for confidentiality and plans to integrate blockchain for data integrity and traceability.

https://pypi.org/project/chagu/

    pip install chainguard

Features

  • AES Encryption and Decryption
  • (Planned) Blockchain Integration
  • Unit and Integration Tests

Installation

pip install -r requirements.txt

usage

    from chainguard.encryption import AESCipher
    
    password = "yourpassword"
    cipher = AESCipher(password)
    
    # Encrypt and Decrypt
    plaintext = "Hello, World!"
    encrypted = cipher.encrypt(plaintext)
    decrypted = cipher.decrypt(encrypted)
    
    print(f"Encrypted: {encrypted}")
    print(f"Decrypted: {decrypted}")

Data Transfer Protocol

ChainGuard now includes a secure data transfer protocol to securely send and receive data between nodes.

Example Usage

from chainguard.data_transfer import SecureDataTransfer

# Initialize SecureDataTransfer with a shared password
transfer = SecureDataTransfer(password="securepassword")

# On the sending side
transfer.send_data("This is a secure message")

# On the receiving side
transfer.receive_data()

Blockchain Integration

ChainGuard includes a custom blockchain to securely log and verify each data transfer. This ensures transparency, immutability, and traceability of all transactions.

Example Usage

from chainguard.data_transfer import SecureDataTransfer

# Initialize SecureDataTransfer with a shared password
transfer = SecureDataTransfer(password="securepassword")

# On the sending side
transfer.send_data("This is a secure message")

# On the receiving side
transfer.receive_data()

# Validate blockchain
is_valid = transfer.validate_blockchain()
print(f"Blockchain valid: {is_valid}")

Anomaly Detection Model , based on shodan scanner

Overview

This repository contains a Python class AnomalyDetectionModel built using TensorFlow and Keras for detecting anomalies in network traffic data. The class encapsulates the creation, training, and evaluation of a neural network model designed to classify network data as either normal or anomalous.

Why Use a Sequential Model?

The Sequential model in Keras is a simple, linear stack of layers. It is ideal for building feedforward neural networks where the model progresses through each layer sequentially, without any branching or complex topologies.

Key Reasons for Using Sequential:

Simplicity: The Sequential API is straightforward and easy to use. It is perfect for beginners and for models that involve a single input and output with layers stacked one after the other.

Linear Stack: For the task of anomaly detection, the architecture typically involves a simple forward pass through several dense layers, making the Sequential model a natural fit.

Flexibility: While simple, the Sequential model is flexible enough to allow for customization through the addition of various types of layers, activation functions, and regularization techniques.

Example Usage

# Initialize the model with the input shape
anomaly_model = AnomalyDetectionModel(X_train.shape[1])
# Train the model
history = anomaly_model.train(X_train, y_train)
# Evaluate the model on the test data
loss, accuracy = anomaly_model.evaluate(X_test, y_test)
print(f'Test Accuracy: {accuracy:.4f}')

Dependencies Python 3.x TensorFlow Keras (included with TensorFlow) Scikit-learn Pandas Installation Install the required packages using pip:

Conclusion The Sequential model is a great choice for this anomaly detection task due to its simplicity, ease of use, and the linear nature of the problem. This approach ensures that the model is easy to build, understand, and maintain while still providing robust performance for binary classification tasks such as anomaly detection.

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

chagu-0.1.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

chagu-0.1.2-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file chagu-0.1.2.tar.gz.

File metadata

  • Download URL: chagu-0.1.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.0

File hashes

Hashes for chagu-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1f931848a5db9e41a9ce15f109789a4e5c8efc301aea374536e6be3cb1ce4534
MD5 45f1af7603434a4991f18f4a7ee1a012
BLAKE2b-256 a6cada445aaa65246383ac499ebe123af63d70d6a226cb82e6027eb6a459822e

See more details on using hashes here.

File details

Details for the file chagu-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: chagu-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.0

File hashes

Hashes for chagu-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b6ef709b8d504472c98a40c47e8cd38320a7ed64764e400160187d612f3dd917
MD5 6dc1c6ed28c10dd2bbd5d633a5a43ffd
BLAKE2b-256 96193a9c4f49e1f08130c4a8b5f4ba79b1c0585c736e579932b6d889d391845e

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