sigmastate-interpreter
sigmastate-interpreter copied to clipboard
Implement modular arithmetic operations
UPD[@aslesarenko]
- [ ] Add test to SigmaDslSpecification
- [ ] make sure serialization is tested (see TODO v6.0 in code)
@kushti @ergomorphic I assume we are going to use the following syntax in ErgoScript (parsed into IR nodes):
a % q
-> ModQ(a, q)
(a + b) % q
-> PlusModQ(a, b, q)
(a - b) % q
-> MinusModQ(a, b, q)
a.plusModQ(b) where q is assumed but not passed as parameter
@ergomorphic I'm not sure I get how "q
is assumed". Where/when do we get q
?
Or ModQ
will be a new type? Like:
val ma = ModQ(a, q)
ma.plusModQ(c)
@greenhat @ergomorphic
- I propose to use "mod q" instead of "% q", as semantics of cryptographic "mod" differs from "%" in popular programming languages for negative numbers.
- "q" is a global constant (order of only one cryptographically strong group we are using). So we may assume it is globally and implicitly imported everywhere.
- Result of all mod operators is of type of the (256-bit) big integer we already have.