I'm trying to do modular exponentiation with numbers larger than the size of uint16_t. Therefore, 65536 is the maximum value that can be represented in the data type. To express larger numbers, I'm using a pointer array and using 65536 as the base. Addition, subtraction, and multiplication are all implemented, so I'm able to use these in the function for modular exponentiation, I just have no clue how to approach this specific function.
I'm aware x * y (mod z) = x mod z * y mod z, and I know the function would have to be incremental, but I don't know how to handle the large base 65536 numbers and I don't know how to do anything that wouldn't take too long to run.
None of the other solutions on this site, or the internet, are for input values larger than the size of the data type, and as such are comletely pointless to me. I need to be able to do the calculations on an array of values that represent one large int of base 65536.
I am looking for code-based answers, not theory as I understand the theory behind modular exponentiation, I just don't see how to implement it at all.