Skip to content

Commit

Permalink
chore(frontend): clarify XOR-distance example.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcm-at-zama committed Apr 18, 2024
1 parent 676a787 commit 623e466
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
# Hamming weight computation
def hw(x):
# Hamming Weight table for 8b entries
hw_table_ref = [np.binary_repr(x).count("1") for x in range(2**8)]

# fmt: off
hw_table_ref = [
assert np.array_equal(hw_table_ref, [
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3,
4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4,
4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2,
Expand All @@ -20,7 +22,7 @@ def hw(x):
3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5,
6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5,
6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8]
6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8])
# fmt: on

hw_table = fhe.LookupTable(hw_table_ref)
Expand Down

0 comments on commit 623e466

Please sign in to comment.