sigmastate-interpreter icon indicating copy to clipboard operation
sigmastate-interpreter copied to clipboard

Implement modular arithmetic operations

Open greenhat opened this issue 6 years ago • 4 comments

UPD[@aslesarenko]

  • [ ] Add test to SigmaDslSpecification
  • [ ] make sure serialization is tested (see TODO v6.0 in code)

greenhat avatar Dec 11 '18 10:12 greenhat

@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)

greenhat avatar Dec 12 '18 11:12 greenhat

a.plusModQ(b) where q is assumed but not passed as parameter

ergomorphic avatar Dec 12 '18 11:12 ergomorphic

@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 avatar Dec 12 '18 11:12 greenhat

@greenhat @ergomorphic

  1. I propose to use "mod q" instead of "% q", as semantics of cryptographic "mod" differs from "%" in popular programming languages for negative numbers.
  2. "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.
  3. Result of all mod operators is of type of the (256-bit) big integer we already have.

kushti avatar Dec 12 '18 15:12 kushti