plutus icon indicating copy to clipboard operation
plutus copied to clipboard

Modular exponentiation primitive

Open kwxm opened this issue 1 year ago • 1 comments

CIP-0109 proposes a new modular exponentiation builtin for Plutus Core. This will calculate a^k mod n for integers a and k and a positive integer n (not necessarily prime) and it should fail if k<0 and a is not invertible modulo n (ie, when gcd(a,n) > 1).

We need to do the following.

  • [ ] Identify a library function that provides the required functionality.
  • [ ] Add a new builtin called modExpInteger or similar to Plutus Core. This may require some wrapping of the library function to enforce the expected behaviour for non-invertible elements.
  • [ ] Cost the new function. This may need some new costing types.
  • [ ] Add a corresponding function to PlutusTx
  • [ ] Add some tests, perhaps including one or more realistic use cases to check that the costs are acceptable.
  • [ ] Add conformance tests
  • [ ] Add e2e tests
  • [ ] Add the new function to plutus-metatheory
  • [ ] Add the new function to the Plutus Core specification.

kwxm avatar May 30 '24 12:05 kwxm