Page cover

📩Data Encryption

Alien encrypts all user data and files to ensure that data cannot be accessed without authorization during storage and transmission.

  • Local Encryption: Data is encrypted locally on the user's device using AES to encrypt chat records and settings. The keys are stored in the device's secure storage area.

  • On-Chain Encryption: The hash values of encrypted data are stored on the blockchain, leveraging the immutability and transparency of blockchain to ensure the integrity and security of the data.

// Example: Data Encryption Storage

import { encrypt, decrypt, generateKey } from 'crypto';

import { storeFileOnIPFS, storeHashOnBlockchain } from './storage';

// Generate AES Key

const aesKey = generateKey('aes', { length: 256 });

// Encrypt File

function encryptFile(file) {

const encryptedFile = encrypt(aesKey, file);

return encryptedFile;

}

// Store Encrypted File and Hash

async function storeFile(file) {

const encryptedFile = encryptFile(file);

const fileHash = await storeFileOnIPFS(encryptedFile);

await storeHashOnBlockchain(fileHash);

}