# Data Layer

The data layer manages the application's data storage and access, including local storage and remote storage. By combining blockchain technology, Alien ensures that user data can only be accessed and decrypted by the user, and no third party, including Alien's developers and operators, can access the user's private data.

Local Storage

Alien uses local storage on the user's device to store temporary data and cache to improve the application's performance and user experience.

* SQLite Database: Used to store user chat records, application settings, and cache files. All locally stored data is encrypted to ensure data cannot be accessed even if the device is lost or stolen.
* Encryption Technology: Uses AES for local data encryption, with keys stored in the device's secure storage area (e.g., iOS's Keychain and Android's Keystore).

Remote Storage

Alien uses distributed storage technology and blockchain technology to ensure data consistency and security across multiple devices.

* Distributed Storage: Uses a distributed storage network to store user chat records and files. These data blocks are encrypted, and only users with the correct decryption key can access them.
* On-Chain Encryption Technology: Uses blockchain to record verification information of data storage and transmission, ensuring the immutability and transparency of the data. Every storage operation generates an on-chain record to prevent data tampering.

On-chain Encryption

Alien's on-chain encryption technology ensures absolute security of data during transmission and storage. All data is encrypted before being uploaded to the distributed storage network and blockchain.

* Asymmetric Encryption: Uses RSA (public key encryption algorithm) for data encryption. Each user has a pair of public and private keys, where the public key is used for encryption and the private key is used for decryption. Only the user with the private key can decrypt the data.
* Symmetric Encryption: In some cases, to improve encryption and decryption efficiency, Alien also uses AES for data encryption. The symmetric encryption key is transmitted using asymmetric encryption to ensure the security of the key itself.
* On-Chain Storage: The hash value of the encrypted data is stored on the blockchain as a basis for data verification and traceability. The immutability of the blockchain ensures the integrity and security of the data.
