Skip to content

Nice to Have: Fixed Point _Unsigned_ Integers with Modular Overflow #16

Description

@tzaffi

As I pondered creating an Alice/Eve Secret Bounty demo described in #7 , the following Nice to Have occurred to me:

Support the Ring of Unsigned Integers Modulo $64k$ in both PyTeal and Zokrates

For example, in the case $k=16$ this amounts to

Support $\mathbb{Z} / 1024$

  • PyTeal supports uint1024 with the following 3 operations:
    • modular_add: add two numbers and in the case of overflow, reduce modulo $2^{1024}$
    • modular_subtract: subtract two numbers and in the case of under, reduce modulo $2^{1024}$ (obtaining a number in the range $[0, 2^{1024})$
    • modular_multiply: multiply two numbers and in the case of overflow, reduce modulo $2^{1024}$
  • Create a Zokrates library for type u<1024> with underlying base type u64[16] with similar properties to the PyTeal type just described

Links

  1. Integers Modulo $n$
  2. PyTeal ABI Types
  3. Zokrates Type Aliases
  4. PyTeal Arithmetic # 181
  5. PyTeal Fixed Point # 184

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions