If you want to know the complexity of this algorithm, you just have to add the complexitys of the operations you use and sum it up.
sha1(message)
has a complexity depending on the length m
of the message, so lets say poly(m), since I dont know the complexity of sha1.
ab mod p
can be done in O(log b)
multiplications.
h * r mod p
is exactly one multiplication
Str1 || Str2
Is this bitwise or? If yes it will take O(s)
where s
is the length of Str1
l == r
will take as much comparisons as the length of the byte array is. This will also be s
.
When numbers are realy big. The can not multiplicated in one processor step, so complexity of one multiplications will be in O(log p)
, since log p
is the length of the numbers.
All together you get O(poly(m) + log(b) ⋅ log(p) + s)
.
Notice: If the length of the numbers (log(b)
and log(p)
) will never change, this part will be constant. This also holds for s
.
You said the numbers are 256 Bit long, so the complexity is only O(poly(m))
, which is the complexity of the Sha1-algorithm.
Notice: If you have an algorithm with any complexity, an you only use input of a fixed length, the complexity will always be constany. Complexity is a tool to see how the runtime will expand if the input is growing. If it is not growing, the runtime will also not.
If your input has always a fixed length, than you are more interested in the performance of the implementation of an algorithm.