Never, ever try to restore either or partitions back to stock! You can easily brick your device by doing so, and the only way out is to do a full Odin restore with data wipe...
Here is the Full Guide to Install Magisk App on your Android Device. All New Method Offers Complete Offline Installation and Even from Custom Recovery.