1. A computer-implemented method for securely encrypting or decrypting a message or for generating or verifying a digital signature of a message, comprising: inputting a key represented as a binary number with a sequence of bits; initializing a first auxiliary variable and a second auxiliary variable; determining first and second memory addresses respectively for the first and second auxiliary variables and assigning the first memory address to an address variable; calculating a differential value from a difference between the memory addresses; sequentially performing the following steps for each bit of the binary number starting from a most significant bit: (a) updating the first auxiliary variable by applying a first computation operation to the first auxiliary variable; (b) updating the second auxiliary variable by applying a second computation operation to the first auxiliary variable; (c) adding the differential value to the address variable as a function of the value of the current bit, so that either the memory address of the first auxiliary variable or the memory address of the second auxiliary variable is assigned as a value to the address variable; and (d) updating the first auxiliary variable by using the auxiliary variable, whose memory address is assigned to the address variable; and after completing steps (a) through (d) for each bit, outputting the first auxiliary variable.