├── main ├── __init__.py ├── network_communication.py ├── raspberry_pi_interface.py ├── ai_model.py ├── data_analysis.py └── main.py ├── utils ├── utils.py ├── constants.py ├── config_parser.py ├── logger.py ├── encryption.py ├── cloud_storage.py ├── natural_language_processing.py ├── homomorphic_encryption.py └── blockchain_interface.py ├── ai_model ├── __init__.py ├── model_architecture.py ├── model_training.py ├── ai_model.py ├── explainability.py ├── graph_neural_network.py ├── attention_module.py └── transformer_model.py ├── data_analysis ├── __init__.py ├── data_storage.py ├── data_visualization.py ├── anomaly_detection.py ├── real_time_anomaly_detection.py ├── time_series_analysis.py ├── data_analysis.py └── anomaly_detection_with_explainability.py ├── network_communication ├── __init__.py ├── socket_handler.py ├── network_communication.py ├── mqtt_client.py ├── coap_client.py └── quantum_key_distribution.py ├── raspberry_pi_interface ├── __init__.py ├── camera_interface.py ├── gpio_controller.py ├── lidar_interface.py ├── raspberry_pi_interface.py └── gesture_recognition.py ├── config ├── secrets.json └── config.json ├── .github ├── ISSUE_TEMPLATE │ ├── custom.md │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── codeql.yml ├── README.md ├── .gitignore └── LICENSE /main/__init__.py: -------------------------------------------------------------------------------- 1 | # Empty file to make main a package 2 | -------------------------------------------------------------------------------- /utils/utils.py: -------------------------------------------------------------------------------- 1 | # Empty file to make utils a package 2 | -------------------------------------------------------------------------------- /ai_model/__init__.py: -------------------------------------------------------------------------------- 1 | # Empty file to make ai_model a package 2 | -------------------------------------------------------------------------------- /data_analysis/__init__.py: -------------------------------------------------------------------------------- 1 | # Empty file to make data_analysis a package 2 | -------------------------------------------------------------------------------- /utils/constants.py: -------------------------------------------------------------------------------- 1 | API_KEY = "YOUR_API_KEY" 2 | API_SECRET = "YOUR_API_SECRET" 3 | -------------------------------------------------------------------------------- /network_communication/__init__.py: -------------------------------------------------------------------------------- 1 | # Empty file to make network_communication a package 2 | -------------------------------------------------------------------------------- /raspberry_pi_interface/__init__.py: -------------------------------------------------------------------------------- 1 | # Empty file to make raspberry_pi_interface a package 2 | -------------------------------------------------------------------------------- /config/secrets.json: -------------------------------------------------------------------------------- 1 | { 2 | "api_key": "YOUR_API_KEY", 3 | "api_secret": "YOUR_API_SECRET" 4 | } 5 | -------------------------------------------------------------------------------- /data_analysis/data_storage.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | def store_data(data, path): 4 | data.to_csv(path, index=False) 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /data_analysis/data_visualization.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | def visualize_data(data): 4 | plt.plot(data["timestamp"], data["traffic_data"]) 5 | plt.xlabel("Timestamp") 6 | plt.ylabel("Traffic Data") 7 | plt.show() 8 | -------------------------------------------------------------------------------- /raspberry_pi_interface/camera_interface.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | class CameraInterface: 4 | def __init__(self): 5 | self.camera = cv2.VideoCapture(0) 6 | 7 | def capture_image(self): 8 | ret, frame = self.camera.read() 9 | return frame 10 | 11 | def release_camera(self): 12 | self.camera.release() 13 | -------------------------------------------------------------------------------- /raspberry_pi_interface/gpio_controller.py: -------------------------------------------------------------------------------- 1 | import RPi.GPIO as GPIO 2 | 3 | class GPIOController: 4 | def __init__(self): 5 | self.GPIO = GPIO 6 | 7 | def set_gpio_mode(self, mode): 8 | self.GPIO.setmode(mode) 9 | 10 | def setup_gpio_pin(self, pin, direction, pull_up_down): 11 | self.GPIO.setup(pin, direction, pull_up_down) 12 | -------------------------------------------------------------------------------- /ai_model/model_architecture.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow import keras 3 | 4 | def create_model(): 5 | model = keras.Sequential([ 6 | keras.layers.LSTM(50, input_shape=(10, 1)), 7 | keras.layers.Dense(1, activation="sigmoid") 8 | ]) 9 | model.compile(loss="binary_crossentropy", optimizer="adam", metrics=["accuracy"]) 10 | return model 11 | -------------------------------------------------------------------------------- /config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "raspberry_pi_interface": { 3 | "gpio_pin": 17 4 | }, 5 | "network_communication": { 6 | "server_ip": "192.168.1.100", 7 | "server_port": 8080 8 | }, 9 | "ai_model": { 10 | "model_path": "anomaly_detection_model.h5" 11 | }, 12 | "data_analysis": { 13 | "data_storage_path": "traffic_data.csv" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /utils/config_parser.py: -------------------------------------------------------------------------------- 1 | import configparser 2 | 3 | class ConfigParser: 4 | def __init__(self, config_file): 5 | self.config = configparser.ConfigParser() 6 | self.config.read(config_file) 7 | 8 | def get_section(self, section): 9 | return self.config[section] 10 | 11 | def get_option(self, section, option): 12 | return self.config.get(section, option) 13 | -------------------------------------------------------------------------------- /network_communication/socket_handler.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | class SocketHandler: 4 | def __init__(self): 5 | self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | 7 | def connect_to_server(self, server_ip, server_port): 8 | self.socket.connect((server_ip, server_port)) 9 | 10 | def send_data(self, data): 11 | self.socket.sendall(data.encode("utf-8")) 12 | -------------------------------------------------------------------------------- /utils/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | class Logger: 4 | def __init__(self): 5 | self.logger = logging.getLogger("PiNetGuardian") 6 | self.logger.setLevel(logging.INFO) 7 | 8 | def info(self, message): 9 | self.logger.info(message) 10 | 11 | def warning(self, message): 12 | self.logger.warning(message) 13 | 14 | def error(self, message): 15 | self.logger.error(message) 16 | -------------------------------------------------------------------------------- /raspberry_pi_interface/lidar_interface.py: -------------------------------------------------------------------------------- 1 | import serial 2 | 3 | class LidarInterface: 4 | def __init__(self, serial_port): 5 | self.serial_port = serial_port 6 | self.lidar = serial.Serial(self.serial_port, 115200) 7 | 8 | def read_lidar_data(self): 9 | data = self.lidar.readline() 10 | return data.decode("utf-8") 11 | 12 | def send_lidar_command(self, command): 13 | self.lidar.write(command.encode("utf-8")) 14 | -------------------------------------------------------------------------------- /main/network_communication.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | class NetworkCommunication: 4 | def __init__(self): 5 | self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | 7 | def connect_to_network(self): 8 | print("Connecting to decentralized network...") 9 | self.socket.connect(("192.168.1.100", 8080)) 10 | 11 | def send_data(self, data): 12 | print("Sending data to network...") 13 | self.socket.sendall(data.encode("utf-8")) 14 | -------------------------------------------------------------------------------- /network_communication/network_communication.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | class NetworkCommunication: 4 | def __init__(self): 5 | self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | 7 | def connect_to_network(self): 8 | print("Connecting to decentralized network...") 9 | self.socket.connect(("192.168.1.100", 8080)) 10 | 11 | def send_data(self, data): 12 | print("Sending data to network...") 13 | self.socket.sendall(data.encode("utf-8")) 14 | -------------------------------------------------------------------------------- /utils/encryption.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import base64 3 | 4 | class Encryption: 5 | def __init__(self): 6 | self.hash_algorithm = hashlib.sha256 7 | 8 | def encrypt_data(self, data): 9 | encrypted_data = self.hash_algorithm.update(data.encode("utf-8")).digest() 10 | return base64.b64encode(encrypted_data) 11 | 12 | def decrypt_data(self, encrypted_data): 13 | decrypted_data = base64.b64decode(encrypted_data) 14 | return decrypted_data.decode("utf-8") 15 | -------------------------------------------------------------------------------- /utils/cloud_storage.py: -------------------------------------------------------------------------------- 1 | import boto3 2 | 3 | class CloudStorage: 4 | def __init__(self, bucket_name): 5 | self.s3 = boto3.client("s3") 6 | self.bucket_name = bucket_name 7 | 8 | def upload_file(self, file_name, file_data): 9 | self.s3.put_object(Body=file_data, Bucket=self.bucket_name, Key=file_name) 10 | 11 | def download_file(self, file_name): 12 | response = self.s3.get_object(Bucket=self.bucket_name, Key=file_name) 13 | return response["Body"].read() 14 | -------------------------------------------------------------------------------- /utils/natural_language_processing.py: -------------------------------------------------------------------------------- 1 | import nltk 2 | from nltk.tokenize import word_tokenize 3 | from nltk.sentiment import SentimentIntensityAnalyzer 4 | 5 | class NaturalLanguageProcessing: 6 | def __init__(self): 7 | self.sia = SentimentIntensityAnalyzer() 8 | 9 | def tokenize_text(self, text): 10 | tokens = word_tokenize(text) 11 | return tokens 12 | 13 | def analyze_sentiment(self, text): 14 | sentiment = self.sia.polarity_scores(text) 15 | return sentiment 16 | -------------------------------------------------------------------------------- /ai_model/model_training.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.model_selection import train_test_split 3 | from ai_model.model_architecture import create_model 4 | 5 | def train_model(): 6 | data = pd.read_csv("data/traffic_data.csv") 7 | X = data.drop("label", axis=1) 8 | y = data["label"] 9 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 10 | model = create_model() 11 | model.fit(X_train, y_train, epochs=10, batch_size=32, validation_data=(X_test, y_test)) 12 | model.save("models/anomaly_detection_model.h5") 13 | -------------------------------------------------------------------------------- /network_communication/mqtt_client.py: -------------------------------------------------------------------------------- 1 | import paho.mqtt.client as mqtt 2 | 3 | class MQTTClient: 4 | def __init__(self, broker_ip, broker_port): 5 | self.client = mqtt.Client() 6 | self.client.connect(broker_ip, broker_port) 7 | 8 | def publish_message(self, topic, message): 9 | self.client.publish(topic, message) 10 | 11 | def subscribe_topic(self, topic): 12 | self.client.subscribe(topic) 13 | 14 | def on_message(self, client, userdata, message): 15 | print("Received message:", message.payload) 16 | 17 | def start_listening(self): 18 | self.client.loop_start() 19 | -------------------------------------------------------------------------------- /main/raspberry_pi_interface.py: -------------------------------------------------------------------------------- 1 | import RPi.GPIO as GPIO 2 | import socket 3 | 4 | class RaspberryPiInterface: 5 | def __init__(self): 6 | self.GPIO = GPIO 7 | self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 8 | 9 | def initialize_hardware(self): 10 | print("Initializing Raspberry Pi hardware...") 11 | self.GPIO.setmode(GPIO.BCM) 12 | self.GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP) 13 | 14 | def get_network_traffic_data(self): 15 | print("Getting network traffic data...") 16 | data = self.socket.recv(1024) 17 | return data.decode("utf-8") 18 | -------------------------------------------------------------------------------- /data_analysis/anomaly_detection.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.ensemble import IsolationForest 3 | 4 | class AnomalyDetection: 5 | def __init__(self): 6 | self.model = IsolationForest() 7 | 8 | def fit(self, data): 9 | self.model.fit(data) 10 | 11 | def predict(self, data): 12 | return self.model.predict(data) 13 | 14 | def visualize_anomalies(self, data): 15 | print("Visualizing anomalies...") 16 | anomalies = self.predict(data) 17 | plt.scatter(data[:, 0], data[:, 1], c=anomalies) 18 | plt.xlabel("Feature 1") 19 | plt.ylabel("Feature 2") 20 | plt.show() 21 | -------------------------------------------------------------------------------- /raspberry_pi_interface/raspberry_pi_interface.py: -------------------------------------------------------------------------------- 1 | import RPi.GPIO as GPIO 2 | import socket 3 | 4 | class RaspberryPiInterface: 5 | def __init__(self): 6 | self.GPIO = GPIO 7 | self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 8 | 9 | def initialize_hardware(self): 10 | print("Initializing Raspberry Pi hardware...") 11 | self.GPIO.setmode(GPIO.BCM) 12 | self.GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP) 13 | 14 | def get_network_traffic_data(self): 15 | print("Getting network traffic data...") 16 | data = self.socket.recv(1024) 17 | return data.decode("utf-8") 18 | -------------------------------------------------------------------------------- /data_analysis/real_time_anomaly_detection.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.ensemble import IsolationForest 3 | 4 | class RealTimeAnomalyDetection: 5 | def __init__(self): 6 | self.model = IsolationForest() 7 | 8 | def fit(self, data): 9 | self.model.fit(data) 10 | 11 | def predict(self, data): 12 | predictions = self.model.predict(data) 13 | return predictions 14 | 15 | def detect_anomalies(self, data): 16 | predictions = self.predict(data) 17 | anomalies = [] 18 | for i, prediction in enumerate(predictions): 19 | if prediction == -1: 20 | anomalies.append(data.iloc[i]) 21 | return anomalies 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /data_analysis/time_series_analysis.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from statsmodels.tsa.arima_model import ARIMA 3 | 4 | class TimeSeriesAnalysis: 5 | def __init__(self): 6 | self.model = None 7 | 8 | def fit(self, data): 9 | self.model = ARIMA(data, order=(5,1,0)) 10 | self.model_fit = self.model.fit() 11 | 12 | def forecast(self, steps): 13 | forecast = self.model_fit.forecast(steps=steps) 14 | return forecast 15 | 16 | def visualize_forecast(self, data, forecast): 17 | print("Visualizing forecast...") 18 | plt.plot(data) 19 | plt.plot(forecast) 20 | plt.xlabel("Time") 21 | plt.ylabel("Value") 22 | plt.show() 23 | -------------------------------------------------------------------------------- /main/ai_model.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow import keras 3 | from sklearn.preprocessing import MinMaxScaler 4 | 5 | class AnomalyDetectionModel: 6 | def __init__(self): 7 | self.model = None 8 | self.scaler = MinMaxScaler() 9 | 10 | def load_model(self): 11 | print("Loading AI model...") 12 | self.model = keras.models.load_model("anomaly_detection_model.h5") 13 | 14 | def predict(self, traffic_data): 15 | print("Predicting anomalies...") 16 | scaled_data = self.scaler.transform(traffic_data) 17 | predictions = self.model.predict(scaled_data) 18 | anomalies = [i for i, x in enumerate(predictions) if x > 0.5] 19 | return anomalies 20 | -------------------------------------------------------------------------------- /ai_model/ai_model.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow import keras 3 | from sklearn.preprocessing import MinMaxScaler 4 | 5 | class AnomalyDetectionModel: 6 | def __init__(self): 7 | self.model = None 8 | self.scaler = MinMaxScaler() 9 | 10 | def load_model(self): 11 | print("Loading AI model...") 12 | self.model = keras.models.load_model("models/anomaly_detection_model.h5") 13 | 14 | def predict(self, traffic_data): 15 | print("Predicting anomalies...") 16 | scaled_data = self.scaler.transform(traffic_data) 17 | predictions = self.model.predict(scaled_data) 18 | anomalies = [i for i, x in enumerate(predictions) if x > 0.5] 19 | return anomalies 20 | -------------------------------------------------------------------------------- /network_communication/coap_client.py: -------------------------------------------------------------------------------- 1 | import coapthon.client.helperclient 2 | 3 | class CoAPClient: 4 | def __init__(self, server_ip, server_port): 5 | self.client = coapthon.client.helperclient.CoAPClient(server=(server_ip, server_port)) 6 | 7 | def get_resource(self, resource_path): 8 | response = self.client.get(resource_path) 9 | return response.payload 10 | 11 | def post_resource(self, resource_path, payload): 12 | response = self.client.post(resource_path, payload) 13 | return response.payload 14 | 15 | def put_resource(self, resource_path, payload): 16 | response = self.client.put(resource_path, payload) 17 | return response.payload 18 | 19 | def delete_resource(self, resource_path): 20 | response = self.client.delete(resource_path) 21 | return response.payload 22 | -------------------------------------------------------------------------------- /utils/homomorphic_encryption.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from phe import paillier 3 | 4 | class HomomorphicEncryption: 5 | def __init__(self): 6 | self.public_key, self.private_key = paillier.generate_paillier_keypair() 7 | 8 | def encrypt(self, data): 9 | encrypted_data =[self.public_key.encrypt(x) for x in data] 10 | return encrypted_data 11 | 12 | def decrypt(self, encrypted_data): 13 | decrypted_data = [self.private_key.decrypt(x) for x in encrypted_data] 14 | return decrypted_data 15 | 16 | def add_homomorphically(self, encrypted_data1, encrypted_data2): 17 | result = [x + y for x, y in zip(encrypted_data1, encrypted_data2)] 18 | return result 19 | 20 | def multiply_homomorphically(self, encrypted_data, scalar): 21 | result = [x * scalar for x in encrypted_data] 22 | return result 23 | -------------------------------------------------------------------------------- /main/data_analysis.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import matplotlib.pyplot as plt 3 | 4 | class DataAnalysis: 5 | def __init__(self): 6 | self.data = pd.DataFrame(columns=["timestamp", "traffic_data"]) 7 | 8 | def initialize_data_storage(self): 9 | print("Initializing data storage...") 10 | self.data.to_csv("traffic_data.csv", index=False) 11 | 12 | def store_data(self, traffic_data): 13 | print("Storing traffic data...") 14 | self.data = self.data.append({"timestamp": time.time(), "traffic_data": traffic_data}, ignore_index=True) 15 | self.data.to_csv("traffic_data.csv", index=False) 16 | 17 | def visualize_data(self): 18 | print("Visualizing traffic data...") 19 | plt.plot(self.data["timestamp"], self.data["traffic_data"]) 20 | plt.xlabel("Timestamp") 21 | plt.ylabel("Traffic Data") 22 | plt.show() 23 | -------------------------------------------------------------------------------- /data_analysis/data_analysis.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import matplotlib.pyplot as plt 3 | 4 | class DataAnalysis: 5 | def __init__(self): 6 | self.data = pd.DataFrame(columns=["timestamp", "traffic_data"]) 7 | 8 | def initialize_data_storage(self): 9 | print("Initializing data storage...") 10 | self.data.to_csv("data/traffic_data.csv", index=False) 11 | 12 | def store_data(self, traffic_data): 13 | print("Storing traffic data...") 14 | self.data = self.data.append({"timestamp": time.time(), "traffic_data": traffic_data}, ignore_index=True) 15 | self.data.to_csv("data/traffic_data.csv", index=False) 16 | 17 | def visualize_data(self): 18 | print("Visualizing traffic data...") 19 | plt.plot(self.data["timestamp"], self.data["traffic_data"]) 20 | plt.xlabel("Timestamp") 21 | plt.ylabel("Traffic Data") 22 | plt.show() 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PiNet-Guardian 2 | 3 | Decentralized AI-Powered IoT Security System for the Pi Network 4 | 5 | # About 6 | 7 | The PiNet Guardian project aims to create a cutting-edge, decentralized IoT security system using Raspberry Pi and advanced machine learning algorithms. 8 | 9 | ## Project Goals 10 | 11 | * Develop an AI-powered anomaly detection system for IoT devices 12 | * Create a decentralized network of Raspberry Pi devices for real-time security monitoring 13 | * Implement advanced machine learning algorithms for threat detection and prevention 14 | 15 | ## Getting Started 16 | 17 | * Clone the repository: `git clone https://github.com/KOSASIH/PiNet-Guardian.git` 18 | * Explore the project structure and files 19 | * Contribute to the project by creating issues, pull requests, or submitting code changes 20 | 21 | ## License 22 | 23 | This project is licensed under the Apache 2.0 License. See `LICENSE` for details. 24 | -------------------------------------------------------------------------------- /data_analysis/anomaly_detection_with_explainability.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.ensemble import IsolationForest 3 | from sklearn.metrics import accuracy_score 4 | 5 | class AnomalyDetectionWithExplainability: 6 | def __init__(self): 7 | self.model = IsolationForest() 8 | 9 | def fit(self, data): 10 | self.model.fit(data) 11 | 12 | def predict(self, data): 13 | predictions = self.model.predict(data) 14 | return predictions 15 | 16 | def explain_anomalies(self, data, predictions): 17 | explanations = [] 18 | for i, prediction in enumerate(predictions): 19 | if prediction == -1: 20 | explanation = self.explain_anomaly(data.iloc[i]) 21 | explanations.append(explanation) 22 | return explanations 23 | 24 | def explain_anomaly(self, data_point): 25 | # Use techniques like SHAP or LIME to explain the anomaly 26 | pass 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # http://www.gnu.org/software/automake 2 | 3 | Makefile.in 4 | /ar-lib 5 | /mdate-sh 6 | /py-compile 7 | /test-driver 8 | /ylwrap 9 | .deps/ 10 | .dirstamp 11 | 12 | # http://www.gnu.org/software/autoconf 13 | 14 | autom4te.cache 15 | /autoscan.log 16 | /autoscan-*.log 17 | /aclocal.m4 18 | /compile 19 | /config.cache 20 | /config.guess 21 | /config.h.in 22 | /config.log 23 | /config.status 24 | /config.sub 25 | /configure 26 | /configure.scan 27 | /depcomp 28 | /install-sh 29 | /missing 30 | /stamp-h1 31 | 32 | # https://www.gnu.org/software/libtool/ 33 | 34 | /ltmain.sh 35 | 36 | # http://www.gnu.org/software/texinfo 37 | 38 | /texinfo.tex 39 | 40 | # http://www.gnu.org/software/m4/ 41 | 42 | m4/libtool.m4 43 | m4/ltoptions.m4 44 | m4/ltsugar.m4 45 | m4/ltversion.m4 46 | m4/lt~obsolete.m4 47 | 48 | # Generated Makefile 49 | # (meta build system like autotools, 50 | # can automatically generate from config.status script 51 | # (which is called by configure script)) 52 | Makefile 53 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /ai_model/explainability.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow import keras 3 | 4 | class Explainability: 5 | def __init__(self, model): 6 | self.model = model 7 | 8 | def saliency_map(self, input_data): 9 | print("Generating saliency map...") 10 | gradients = tf.gradients(self.model.output, input_data) 11 | saliency_map = tf.abs(gradients) 12 | return saliency_map 13 | 14 | def feature_importance(self): 15 | print("Calculating feature importance...") 16 | feature_importance = tf.keras.backend.sum(self.model.layers[-1].weights[0], axis=0) 17 | return feature_importance 18 | 19 | def visualize_explainability(self, input_data): 20 | print("Visualizing explainability...") 21 | saliency_map = self.saliency_map(input_data) 22 | feature_importance = self.feature_importance() 23 | plt.imshow(saliency_map, cmap="hot") 24 | plt.xlabel("Feature Importance") 25 | plt.ylabel("Saliency Map") 26 | plt.show() 27 | -------------------------------------------------------------------------------- /utils/blockchain_interface.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | from ecdsa import SigningKey, SECP256k1 3 | 4 | class BlockchainInterface: 5 | def __init__(self): 6 | self.private_key = SigningKey.from_secret_exponent(123456789, curve=SECP256k1) 7 | self.public_key = self.private_key.get_verifying_key() 8 | 9 | def generate_transaction(self, data): 10 | transaction = { 11 | "data": data, 12 | "timestamp": int(time.time()), 13 | "hash": self.generate_hash(data) 14 | } 15 | return transaction 16 | 17 | def generate_hash(self, data): 18 | hash_object = hashlib.sha256() 19 | hash_object.update(data.encode("utf-8")) 20 | return hash_object.hexdigest() 21 | 22 | def sign_transaction(self, transaction): 23 | signature = self.private_key.sign(transaction["hash"].encode("utf-8")) 24 | return signature 25 | 26 | def verify_transaction(self, transaction, signature): 27 | return self.public_key.verify(signature, transaction["hash"].encode("utf-8")) 28 | -------------------------------------------------------------------------------- /network_communication/quantum_key_distribution.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from qiskit import QuantumCircuit, execute 3 | 4 | class QuantumKeyDistribution: 5 | def __init__(self): 6 | self.qc = QuantumCircuit(2) 7 | 8 | def generate_key(self): 9 | self.qc.h(0) 10 | self.qc.cx(0, 1) 11 | self.qc.measure_all() 12 | job = execute(self.qc, backend="qasm_simulator") 13 | result = job.result() 14 | key = result.get_counts() 15 | return key 16 | 17 | def encode_message(self, message, key): 18 | encoded_message = "" 19 | for i, bit in enumerate(message): 20 | if key[i] == "0": 21 | encoded_message += str(bit) 22 | else: 23 | encoded_message += str(1 - bit) 24 | return encoded_message 25 | 26 | def decode_message(self, encoded_message, key): 27 | decoded_message = "" 28 | for i, bit in enumerate(encoded_message): 29 | if key[i] == "0": 30 | decoded_message += str(bit) 31 | else: 32 | decoded_message += str(1 - bit) 33 | return decoded_message 34 | -------------------------------------------------------------------------------- /ai_model/graph_neural_network.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow import keras 3 | 4 | class GraphNeuralNetwork: 5 | def __init__(self, num_layers, hidden_size): 6 | self.num_layers = num_layers 7 | self.hidden_size = hidden_size 8 | 9 | def graph_convolution(self, inputs, adjacency_matrix): 10 | outputs = [] 11 | for i in range(self.num_layers): 12 | outputs.append(self.graph_convolution_layer(inputs, adjacency_matrix)) 13 | inputs = outputs[-1] 14 | return outputs[-1] 15 | 16 | def graph_convolution_layer(self, inputs, adjacency_matrix): 17 | weights = keras.layers.Dense(self.hidden_size)(inputs) 18 | outputs = tf.matmul(adjacency_matrix, weights) 19 | return outputs 20 | 21 | def graph_pooling(self, inputs, pooling_matrix): 22 | outputs = tf.matmul(pooling_matrix, inputs) 23 | return outputs 24 | 25 | def graph_neural_network_model(self, inputs, adjacency_matrix, pooling_matrix): 26 | outputs = self.graph_convolution(inputs, adjacency_matrix) 27 | outputs = self.graph_pooling(outputs, pooling_matrix) 28 | return outputs 29 | -------------------------------------------------------------------------------- /raspberry_pi_interface/gesture_recognition.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | class GestureRecognition: 5 | def __init__(self): 6 | self.cap = cv2.VideoCapture(0) 7 | 8 | def capture_frame(self): 9 | ret, frame = self.cap.read() 10 | return frame 11 | 12 | def detect_hand(self, frame): 13 | hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 14 | lower_skin = np.array([0, 20, 70]) 15 | upper_skin = np.array([20, 255, 255]) 16 | mask = cv2.inRange(hsv, lower_skin, upper_skin) 17 | return mask 18 | 19 | def recognize_gesture(self, mask): 20 | contours, _ = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) 21 | for contour in contours: 22 | area = cv2.contourArea(contour) 23 | if area > 1000: 24 | x, y, w, h = cv2.boundingRect(contour) 25 | aspect_ratio = float(w)/h 26 | if aspect_ratio > 2: 27 | return "V Gesture" 28 | elif aspect_ratio < 0.5: 29 | return "Fist Gesture" 30 | else: 31 | return "Unknown Gesture" 32 | return "No Gesture" 33 | -------------------------------------------------------------------------------- /ai_model/attention_module.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow import keras 3 | 4 | class AttentionModule: 5 | def __init__(self, num_heads, hidden_size): 6 | self.num_heads = num_heads 7 | self.hidden_size = hidden_size 8 | 9 | def attention(self, query, key, value): 10 | attention_scores = tf.matmul(query, key, transpose_b=True) 11 | attention_scores = attention_scores / tf.sqrt(self.hidden_size) 12 | attention_weights = tf.nn.softmax(attention_scores, axis=-1) 13 | output = tf.matmul(attention_weights, value) 14 | return output 15 | 16 | def multi_head_attention(self, query, key, value): 17 | outputs = [] 18 | for i in range(self.num_heads): 19 | output = self.attention(query, key, value) 20 | outputs.append(output) 21 | output = tf.concat(outputs, axis=-1) 22 | return output 23 | 24 | def attention_layer(self, inputs): 25 | query = keras.layers.Dense(self.hidden_size)(inputs) 26 | key = keras.layers.Dense(self.hidden_size)(inputs) 27 | value = keras.layers.Dense(self.hidden_size)(inputs) 28 | output = self.multi_head_attention(query, key, value) 29 | return output 30 | -------------------------------------------------------------------------------- /main/main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import time 4 | from ai_model import AnomalyDetectionModel 5 | from raspberry_pi_interface import RaspberryPiInterface 6 | from network_communication import NetworkCommunication 7 | from data_analysis import DataAnalysis 8 | 9 | class PiNetGuardian: 10 | def __init__(self): 11 | self.ai_model = AnomalyDetectionModel() 12 | self.rpi_interface = RaspberryPiInterface() 13 | self.network_communication = NetworkCommunication() 14 | self.data_analysis = DataAnalysis() 15 | 16 | def start_system(self): 17 | print("Starting PiNet Guardian system...") 18 | self.rpi_interface.initialize_hardware() 19 | self.network_communication.connect_to_network() 20 | self.ai_model.load_model() 21 | self.data_analysis.initialize_data_storage() 22 | 23 | def monitor_network_traffic(self): 24 | print("Monitoring network traffic...") 25 | while True: 26 | traffic_data = self.rpi_interface.get_network_traffic_data() 27 | self.ai_model.predict(traffic_data) 28 | self.data_analysis.store_data(traffic_data) 29 | time.sleep(1) 30 | 31 | def run(self): 32 | self.start_system() 33 | self.monitor_network_traffic() 34 | 35 | if __name__ == "__main__": 36 | pignet_guardian = PiNetGuardian() 37 | pignet_guardian.run() 38 | -------------------------------------------------------------------------------- /ai_model/transformer_model.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | from tensorflow import keras 3 | 4 | class TransformerModel: 5 | def __init__(self, num_layers, hidden_size, num_heads): 6 | self.num_layers = num_layers 7 | self.hidden_size = hidden_size 8 | self.num_heads = num_heads 9 | 10 | def encoder_layer(self, inputs): 11 | attention_output = self.multi_head_attention(inputs, inputs) 12 | attention_output = self.feed_forward_network(attention_output) 13 | return attention_output 14 | 15 | def decoder_layer(self, inputs, encoder_output): 16 | attention_output = self.multi_head_attention(inputs, encoder_output) 17 | attention_output = self.feed_forward_network(attention_output) 18 | return attention_output 19 | 20 | def multi_head_attention(self, query, key, value): 21 | attention_scores = tf.matmul(query, key, transpose_b=True) 22 | attention_scores = attention_scores / tf.sqrt(self.hidden_size) 23 | attention_weights = tf.nn.softmax(attention_scores, axis=-1) 24 | output = tf.matmul(attention_weights, value) 25 | return output 26 | 27 | def feed_forward_network(self, inputs): 28 | outputs = keras.layers.Dense(self.hidden_size, activation="relu")(inputs) 29 | outputs = keras.layers.Dense(self.hidden_size)(outputs) 30 | return outputs 31 | 32 | def transformer_model(self, inputs): 33 | encoder_output = self.encoder_layer(inputs) 34 | decoder_output = self.decoder_layer(inputs, encoder_output) 35 | return decoder_output 36 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "main" ] 17 | pull_request: 18 | branches: [ "main" ] 19 | schedule: 20 | - cron: '24 19 * * 6' 21 | 22 | jobs: 23 | analyze: 24 | name: Analyze (${{ matrix.language }}) 25 | # Runner size impacts CodeQL analysis time. To learn more, please see: 26 | # - https://gh.io/recommended-hardware-resources-for-running-codeql 27 | # - https://gh.io/supported-runners-and-hardware-resources 28 | # - https://gh.io/using-larger-runners (GitHub.com only) 29 | # Consider using larger runners or machines with greater resources for possible analysis time improvements. 30 | runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} 31 | timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} 32 | permissions: 33 | # required for all workflows 34 | security-events: write 35 | 36 | # required to fetch internal or private CodeQL packs 37 | packages: read 38 | 39 | # only required for workflows in private repositories 40 | actions: read 41 | contents: read 42 | 43 | strategy: 44 | fail-fast: false 45 | matrix: 46 | include: 47 | # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' 48 | # Use `c-cpp` to analyze code written in C, C++ or both 49 | # Use 'java-kotlin' to analyze code written in Java, Kotlin or both 50 | # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both 51 | # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, 52 | # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. 53 | # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how 54 | # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages 55 | steps: 56 | - name: Checkout repository 57 | uses: actions/checkout@v4 58 | 59 | # Initializes the CodeQL tools for scanning. 60 | - name: Initialize CodeQL 61 | uses: github/codeql-action/init@v3 62 | with: 63 | languages: ${{ matrix.language }} 64 | build-mode: ${{ matrix.build-mode }} 65 | # If you wish to specify custom queries, you can do so here or in a config file. 66 | # By default, queries listed here will override any specified in a config file. 67 | # Prefix the list here with "+" to use these queries and those in the config file. 68 | 69 | # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 70 | # queries: security-extended,security-and-quality 71 | 72 | # If the analyze step fails for one of the languages you are analyzing with 73 | # "We were unable to automatically build your code", modify the matrix above 74 | # to set the build mode to "manual" for that language. Then modify this step 75 | # to build your code. 76 | # ℹ️ Command-line programs to run using the OS shell. 77 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 78 | - if: matrix.build-mode == 'manual' 79 | shell: bash 80 | run: | 81 | echo 'If you are using a "manual" build mode for one or more of the' \ 82 | 'languages you are analyzing, replace this with the commands to build' \ 83 | 'your code, for example:' 84 | echo ' make bootstrap' 85 | echo ' make release' 86 | exit 1 87 | 88 | - name: Perform CodeQL Analysis 89 | uses: github/codeql-action/analyze@v3 90 | with: 91 | category: "/language:${{matrix.language}}" 92 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------