What kind of encryption is required for LineageOS on Xiaomi Redmi Note 5 (whyred) to boot? Having my Redmi Note 5 stuck at the LineageOS logo, I tried different ROMs like Resurrection Remix OS. They work well. After some reserach, I found a hint to some kind of encryption in the LineageOS release thread on xda-developers. So I re-flashed the stock MIUI ROM (without firmware cause of Xiaomi's devious anti roll-back mechanism) and LineageOS could be installed without problems. 

I want to understand this topic:


What are those keys?
Why LineageOS needs them?
Has this anything to do with device encryption?
Is this a Xiaomi specific topic or does it apply to other manufactures as well?


Currently, I know very little about those encryption keys:


It seems that they're generated by the stock MIUI on first boot
They got deleted by formatting in TWRP, not on simply wiping
We don't get any usefull error message, only a endless booting LineageOS animation
Encryption can be bypassed using a zip from here. But without OTA updates and the zip for bypassing must be flashed on each LineageOS update
Other ROMs like MoKee or Resurrection Remix OS don't care
Format data using TWRP, unmount the data partition, then resize the partition with adb shell :
resize2fs /dev/block/mmcblk0p50 51G

(my original size of filesystem /dev/block/mmcblk0p50 was 52.1G (you can find it with the command "df -h /dev/block/mmcblk0p50")
The encryption process need to take some place at the end of the partition or it will fail - this thread has helped me : github.com/CyanogenMod/android_device_motorola_xt907/issues/3
You can debug also the problem with the adb logcat command.