Understanding the hamming weight metric

1k Views Asked by At

Definition: Hamming weight

Consider any $z\in\mathbb Z$. The hamming weight of $binary(z)$ is then defined as the hamming distance [1] to the zero string of same length. That means (using the language of coding-theory) every set bit increases the weight. Otherwise defined by linear algebra as: Let $z=\sum_{i=0}^n z_i 2^i$ then the hamming weight $h(z)=\sum_{i=0}^n z_i$.

This is the definition of Hamming weight, that I know.

Question

How could it be, that then $u=-2^{77} +2^{50} + 2^{33}$ has $h(u)=3$ or $v=2^{35}-2^{32}-2^{18}+2^8+1$ has $h(v)=5$? The negative sign in the beginning is confusing me. That tells me, that I have to consider 3 conditions, instead of 2?

Binary representation of u and v

$u=-0b11111111111111111111111111011111111111111111000000000000000000000000000000000$

and

$v=0b11011111111111111000000000100000001$

That shows, that the given definition does not hold in case, the given hamming weight by [2] is right.

References

[1] https://en.wikipedia.org/wiki/Hamming_distance

[2] https://eprint.iacr.org/2017/334

1

There are 1 best solutions below

7
On

The Hamming weight does not take the value of the coefficient into account, it simply adds $1$ if the coefficient is $\ne 0$ :

$$u=-2^{77} +2^{50} + 2^{33} \Rightarrow h(u) = 1+1+1 = 3$$

$$v=2^{35}-2^{32}-2^{18}+2^8+1 \Rightarrow h(v) = 1+1+1+1+1 = 5 $$

The general formula is :

$$z = \sum_{i=0}^n z_i2^i \Rightarrow h(z) = \sum_{i=0\\z_i\ne 0}^n 1$$