algorand / algorand/go-algorand
New opcode: modexp
- Dominant language
- Go
- Stars
- 1.4k
- Forks
- 537
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 18
Description
## Problem
I believe `modexp` (modular exponentiation) should be available as an opcode, as it seems like an important crypto primitive. It is also present in many other chains like EVM. While I have implemented its functionality in [Puya BigNumber](https://github.com/Helium-Labs/Puya-BigNumber), I'm afraid its cost is prohibitively expensive for most real-world applications like RSA signature verification. This is why I propose it be made an opcode.
This opcode would pave the way for several novel use cases, such as supporting RSA, which is still a popular cryptographic function seen in many places like JWT verification and DKIM in email.
## Solution
I offer to make a PR adding support for the opcode, updating several source files in `data/transactions/logic` to integrate it. Before creating the PR, I thought it best to raise an issue to provide context and see whether it's something others would like to see added. The API design would be something typical, likely `modexp(base: Bytes, exponent: Bytes, modulus: Bytes)`. The opcode cost would be a function of the input size, similar to `base64_decode`.
## Dependencies
There are no known dependencies.
## Urgency
I am aware of several developers, including myself, who wish to support RSA in some form, such as for DKIM in email or privacy-preserving JWT verification. In that sense, it seems like an important opcode.
Contributor guide
Assessment
This issue has not been assessed yet.