MOF: Mutual Opposite Form

German page Japanese page

MOF is a new canonical representation of signed binary strings, which can be computed not only right-to-left but also left-to-right.


Contents:

Motivation:

The most common method for computing exponentiation of random elements in Abelian groups are sliding window schemes, which enhance the efficiency of the binary method at the expense of some precomputation. In groups where inversion is easy (e.g. elliptic curves), signed representations of the exponent are meaningful because they decrease the amount of required precomputation. The asymptotic best signed method is wNAF, because it minimizes the precomputation effort whilst the non-zero density is nearly optimal. Unfortunately, wNAF can be computed only from the least significant bit, i.e. right-to-left. However, in connection with memory constraint devices left-to-right recoding schemes are by far more valuable.

In representation an integer d is expressed as d=sum(di 2i) where di is in T. For normal binary representations T={0,1} which causes an unique representation. If the set T is larger, i.e. we allow negative digits, one number can be expressed a few times.
decimalbinary T=
181=10110101{0,1}
=1-110-11-11-1{-1,0,1}
=10-10-10101{-1,0,1}

Goals

  1. Minimize #T.
    For ECC applications each digit of T has to be precomputed which takes time and requires memory.
  2. Minimize non-zero digits.
    In multiplication or exponentaion algorithms non-zero digits require an extra operation. So the computation of many zero-digits is faster.

MOF:

MOF Definition
The mutual opposite form (MOF) is an signed binary string that satisfies the following properties:

  1. the signs of adjacent non-zero bits (without considering 0 bits) are opposite, and
  2. the most non-zero bit and the least non-zero bit are 1 and -1, respectively.

Example
Some zero bits are inserted between non-zero bits that have a mutual opposite sign. An example of MOF is 0 1 0 0 -1 0 1 0 0 0 -1 0 0 1 -1 0.

Converting Binary String to MOF
We show a simple and flexible conversion from n-bit binary string to (n+1)-bit MOF.

The crucial point is the following observation. The n-bit binary string d can be converted to a signed binary string by computing md = 2d - d, where - stands for a bitwise subtraction. Indeed, we convert d as follows:

2d =dn-1dn-2...di-1...d1d0
-d =dn-1...di...d2d1d0

md =dn-1dn-2-dn-1...di-1-di...d1-d2d0-d1-d0

Algorithm: Left-to-Right Gerneration fom Binary to MOF
Input:a non-zero n-bit binary string d=dn-1|dn-2|...|d1|d0
Output:MOF mdn|...|md1|md0 of d
  • mdn <- dn-1
  • for i = n - 1 down to 1 do
    • mdi <- di-1 - di
  • md0 <- -d0
  • return (mdn, mdn-1, ..., md1, md0)

Algorithm: Right-to-Left Gerneration fom Binary to MOF
Input:a non-zero n-bit binary string d=dn-1|dn-2|...|d1|d0
Output:MOF mdn|...|md1|md0 of d
  • md0 <- -d0
  • for i = 1 to n - 1 do
    • mdi <- di-1 - di
  • mdn <- dn-1
  • return (mdn, mdn-1, ..., md1, md0)

Theorem
Every non-negative integer d has a representation as wMOF, which is unique except for the number of leading zeros.


wNAF

wNAF Definition
A sequence of signed digits is called wNAF iff the following three properties hold:

  1. The most significant non-zero bit is positive.
  2. Among any w consecutive digits, at most one is non-zero.
  3. Each non-zero digit is odd and less than 2w-1 in absolute value.

Algorithm: Generation of wNAF
Input:width w, an n-bit integer d
Output:wNAF sdn|sdn-1|...|sd0 of d
  • i <- 0
  • while d >= 1 do
    • if d is even then
      • sdi <- 0
    • else
      • sdi <- d mods 2w; d <- d - sdi
    • d <- d/2; i <- i + 1
  • return (sdn, sdn-1, ..., sd0)

The algorithm generates wNAF from the least significant bit, that is right-to-left generation again. The average density of non-zero bits is asymptotically 1/(w+1) for n -> infty, and the digit set equals T={+-1, +-3, ..., +-(2w-1-1)} which seems to be minimal.

It seems impossible to compute wNAF left-to-right. That's the motivation to look for other solutions.


Window Methods on MOF:

In this section we show how to decrease the non-zero density of MOF by applying window methods on it. First we consider the right-to-left width w sliding window method which surprisingly yields the familiar wNAF. In contrast to previously known generation methods, the new one is carry-free, i.e. in each step the knowledge of at most w+1 consecutive input bits is sufficient.

Then we define the dual new class wMOF as the result of the analogue left-to-right width w sliding window method on MOF. This conversion leads to the first left-to-right signed recoding scheme for general width w.

The coherency is shown on the following picture:

schema

Right-to-Left Case: wNAF
In order to describe the proposed scheme, we need the conversion table for width w. First, we define the conversions for MOF windows of length l, such that the first and the last bit is non-zero:

General Conversion table

In addition, we have analogue conversions with all signs changed. To generate the complete table for width w, we have to consider all conversions of length l=2, 3, ..., w
. If l < w holds, the window is filled with leading zeros.

Example: In the case of w=3, we use the following table for the right-to-left sliding window method:

wNAF Conversion table for w=3

Algorithm: Right-to-Left Generation from Binary to wNAF
Input:width w, an n-bit binary string d=dn-1|dn-2|...|d1|d0
Output:wNAF sdn|sdn-1|...|sd0 of d
  • dn+w-2 <- 0; dn+w-3 <- 0; ...; dn <- 0; d-1 <- 0
  • i <- 0
  • while i <= n do
    • if di-1 = di then
      • sdi <- 0; i <- i + 1
    • else {The MOF windows begins with a non-zero digit righthand}
      • (sdi+w-1, ..., sdi) <- TablewSW(di+w-2 - di+w-1, di+w-3 - di+w-2, ..., di-1 - di)
      • i <- i + w
  • return (sdn, sdn-1, ..., sd0)

Left-to-Right Case: wMOF
In order to describe the proposed scheme, we need the conversion table for width w. The conversions for MOF windows of length l, such that the first and the last bit is non-zero, are defined in exactly the same way as in the right-to-left case (see the table above and reflect the assignments). To generate the complete table for width w, we have to consider all conversions of length l=2, 3, ..., w as before. The only difference is that if l < w holds, the window is filled with closing zeros instead of leading ones. As an example, we construct the conversion table Table4SW for width 4:

wMOF Conversion table for w=4

The table is complete due to the properties of MOF. Note that because of the equalities (* 1 -1) = (* 0 1), (* -1 1) = (* 0 -1) usually two different MOF-strings are converted to the same pattern. In an analogue way, TablewSW is defined for general width w. In this case the digit set equals T = { +-1, +-3, ..., +-2w-1-1 }, which is the same as for wNAF. Therefore, the scheme requires only 2w-2 precomputed elements. The algorithm makes use of this table to generate wMOF left-to-right.

Algorithm: Left-to-Right Generation from Binary to wMOF
Input:width w, a non-zero n-bit binary string d=dn-1|dn-2|...|d1|d0
Output:wMOF sdn|sdn-1|...|sd0 of d
  • d-1 <- 0; dn <- 0
  • i <- 0
  • while i >= w - 1 do
    • if di = di-1 then
      • sdi <- 0; i <- i - 1
    • else {The MOF windows begins with a non-zero digit lefthand}
      • (sdi, sdi-1, ..., sdi-w+1) <- TablewSW(di-1 - di, di-2 - di-1, ..., di-w - di-w+1)
      • i <- i - w
  • if i >= 0 then
    • (sdi, sdi-1, ..., sd0) <- Tablei+1SW(di-1 - di, di-2 - di-1, ..., d0 - d1, -d0)
  • return (sdn, sdn-1, ..., sd0)

Theorem
The average non-zero density of wMOF is asymptotically 1/(w+1) for n -> infty.


Compute MOF-representations for the random numbers d (0 < d < 1024 ):

This is a wMOF converter which compute MOF-representations for the random numbers d (0 < d < 1024 ) and output the answer. After that a left-to-right or right-to-left sliding window method can be applied.

(0 < d < 1024)