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.3.tar.gz (11.9 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.3-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chagu-0.1.3.tar.gz
  • Upload date:
  • Size: 11.9 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.3.tar.gz
Algorithm Hash digest
SHA256 8929db60e550777e41807b6257a2a55b2dd4fdf29b94ff1e313b6688a93c3a9c
MD5 c8be6f628cb935edfdb2363dc0718a06
BLAKE2b-256 7208a31d3389c9b7294c6a2bbc7691c76e15b555a731de4b334491761eba1b1d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chagu-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6ecbedf1ddc4c2212886d17937faa00aa8b623162a1a8e29f6d0ec07b8dd4e62
MD5 7e37c0579f21694b2f44743497ad7c1e
BLAKE2b-256 48d126734fd4e8152bfb5e935e128b83c09bfbd04637ce3b86b1879146c3e599

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