Physio-Key-Gen is a Proof-of-Concept (PoC) implementation of a secure key agreement protocol for Wireless Body Area Networks (WBAN). It utilizes the Inter-Pulse Interval (IPI) derived from Electrocardiogram (ECG) signals as a shared source of randomness to generate cryptographic keys between two sensors.
The system employs Bloom Filters to efficiently reconcile the set of biometric features (IPIs) between a sender (Sensor S) and a receiver (Sensor R) without exposing the raw biometric data, ensuring both security and privacy.
The following diagram illustrates the key agreement flow between Sensor S and Sensor R:
sequenceDiagram
participant S as Sensor S (Sender)
participant R as Sensor R (Receiver)
Note over S,R: Both sensors capture ECG from the same host
S->>S: Generate IPI Features (Fs)
R->>R: Generate IPI Features (Fr)
S->>S: Create Bloom Filter (BF) from Fs
S->>R: Send (ID_S, BF, Random_Nonce)
R->>R: Check Fr against BF
R->>R: Identify Common Features
R->>R: Generate Key (Kr) = SHA1(Common Features)
R->>R: Generate HMAC1 = HMAC(Kr, Common Features + Nonce)
R->>S: Send (ID_R, HMAC1, Indices_Common)
S->>S: Reconstruct Common Features from Indices
S->>S: Generate Key (Ks) = SHA1(Common Features)
S->>S: Verify HMAC1 using Ks
alt HMAC Verified
S->>S: Key Agreement Successful (Ks == Kr)
S->>R: Send Confirmation HMAC
else HMAC Failed
S->>S: Abort Protocol
end
- Biometric Feature Extraction: Extracts Inter-Pulse Intervals (IPI) from raw ECG data using
wfdb. - Bloom Filter Implementation: Custom Python implementation of a Bloom Filter for efficient set membership testing.
- Secure Key Generation: Uses SHA-1 hashing and HMAC for secure key derivation and verification.
- Simulation: Simulates the interaction between two sensors using the MIT-BIH Arrhythmia Database.
-
Clone the repository:
git clone https://github.com/yourusername/physio-key-gen.git cd physio-key-gen -
Install the required dependencies:
pip install numpy matplotlib wfdb bitarray
Note: You may need to download the MIT-BIH Arrhythmia Database files if they are not included or use the
wfdblibrary to fetch them.
To run the key agreement simulation:
python KeyAgreement.pyThis script will:
- Load an ECG record.
- Generate features for Sensor S and Sensor R (with a simulated offset/noise).
- Execute the key agreement protocol.
- Print the status of the key generation and verification steps to the console.
KeyAgreement.py: Main entry point. Orchestrates the protocol between S and R.BloomFilter.py: Class implementation of the Bloom Filter data structure.InterPulseInterval.py: Helper functions for ECG signal processing and IPI calculation.LICENSE: MIT License file.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.