# What's the number of unique possible Cayley tables in a 16*16 grid for XOR'ing single hex characters?

A few days ago, I designed and s-box then derived the following Cayley table of all possible XOR outputs of hex digits in the range of $${2^4}$$ and was curious how many such "valid" possible configurations exist within a 16*16 grid and where the table remains Abelian and has symmetric diagonals, such as this one? (And aside from rotating this one).(See update below: what does the XOR Cayley table tell us about the Ciphertext space for a given range?).

In other words, how many ways can a 16*16 table be designed that shows the XOR result for any single Hexadecimal character, when using the top/left edges as the coordinate lookup values, or bottom/right edges, and where no value repeats more than once for any given row or column (i.e. making it a Cayley table).

$$\begin{array}{c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \oplus \ & \text{0} & \text{5} & \text{10} & \text{15} & \text{1} & \text{4} & \text{11} & \text{14}& \text{2} & \text{7} & \text{8} & \text{13}& \text{3} & \text{6} & \text{9} & \text{12}\\ \hline \text{0} &0 &5 &A &F &1 &4 &B &E &2 &7 &8 &D &3 &6 &9 &C\\ \hline \text{5} &5 &0 &F &A &4 &1 &E &B &7 &2 &D &8 &6 &3 &C &9\\ \hline \text{10} &A &F &0 &5 &B &E &1 &4 &8 &D &2 &7 &9 &C &3 &6\\ \hline \text{15} &F &A &5 &0 &E &B &4 &1 &D &8 &7 &2 &C &9 &6 &3\\ \hline \text{1} &1 &4 &B &E &0 &5 &A &F &3 &6 &9 &C &2 &7 &8 &D\\ \hline \text{4} &4 &1 &E &B &5 &0 &F &A &6 &3 &C &9 &7 &2 &D &8\\ \hline \text{11} &B &E &1 &4 &A &F &0 &5 &9 &C &3 &6 &8 &D &2 &7\\ \hline \text{14} &E &B &4 &1 &F &A &5 &0 &C &9 &6 &3 &D &8 &7 &2\\ \hline \text{2} &2 &7 &8 &D &3 &6 &9 &C &0 &5 &A &F &1 &4 &B &E\\ \hline \text{7} &7 &2 &D &8 &6 &3 &C &9 &5 &0 &F &A &4 &1 &E &B\\ \hline \text{8} &8 &D &2 &7 &9 &C &3 &6 &A &F &0 &5 &B &E &1 &4\\ \hline \text{13} &D &8 &7 &2 &C &9 &6 &3 &F &A &5 &0 &E &B &4 &1\\ \hline \text{3} &3 &6 &9 &C &2 &7 &8 &D &1 &4 &B &E &0 &5 &A &F\\ \hline \text{6} &6 &3 &C &9 &7 &2 &D &8 &4 &1 &E &B &5 &0 &F &A\\ \hline \text{9} &9 &C &3 &6 &8 &D &2 &7 &B &E &1 &4 &A &F &0 &5\\ \hline \text{12}& C &9 &6 &3 &D &8 &7 &2 &E &B &4 &1 &F &A &5 &0\\ \hline \end{array}$$ $$\text{ designed by Steven Hatzakis 2019}$$

Note: I've seen one other such table where the lookup values are linear (https://i.stack.imgur.com/eIe24.png and mentioned here https://math.stackexchange.com/questions/116736/cayley-table-with-the-identity-along-a-diagonal/3260978#3260978). Also, the below table doesn't need the extra lookup top row and left column as the first and top columns of the 16*16 table itself can be used instead (but I added them for convenience/readability).

In addition, lookups can be performed using the right and bottom edges (i.e. if top/left side is used to lookup $${5 \oplus 4 = 1}$$, that coordinate answer is shared for $${8 \oplus 9 = 1 }$$ when using the bottom/right side).

How many such Caley XOR tables are theoretically possible that hold such qualities for a 16*16 table?

P.S. for cryptography purposes such a table configuration could be a potential 256-character hex string and/or have relationships to an s-box design, so I thought this question is worth exploring here.

Update: If we treat the left-most column in the 17*17 table herein as the possible keyspace $${2^4}$$ and the top-most row as the message-space $${2^4}$$, does the resulting $${2^8}$$ ciphertext within the 16*16 table represent all possible XOR combinations for single hex characters? And if so, why are there only a total of 51 unique ones (if we defining the uniqueness of one as the six possible ways to write a given XOR equation for three variables that XOR to each other such as this one: ${ • $${8 \oplus c = 4}$$, $${(Message \oplus Private Key = Ciphertext)}$$ • $${c \oplus 8 = 4}$$, $${( Private Key \oplus Message = Ciphertext)}$$ • $${c \oplus 4 = 8}$$, $${(Private Key \oplus Ciphertext = Message)}$$ • $${4 \oplus c = 8}$$, $${(Ciphertext \oplus Private Key = Message)}$$ • $${4 \oplus 8 = c}$$, $${(Ciphertext \oplus Message = Private Key)}$$ • $${8 \oplus 4 = c}$$, $${(Message \oplus Ciphertext = Private Key)}$$ Here the map/truth table for 4-bit XOR functions showing the 51 equations and relationships color-coded: Note: I counted 51 but 0 XOR 0 = 0 doesn't show on the inner table the way all other values do when excluding the additional 17th column/row used for lookup as seen below. $$\begin{array}{c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \oplus \ \\ \hline \text{} &0 &5 &A &F &1 &4 &B &E &2 &7 &8 &D &3 &6 &9 &C\\ \hline \text{} &5 &0 &F &A &4 &1 &E &B &7 &2 &D &8 &6 &3 &C &9\\ \hline \text{} &A &F &0 &5 &B &E &1 &4 &8 &D &2 &7 &9 &C &3 &6\\ \hline \text{} &F &A &5 &0 &E &B &4 &1 &D &8 &7 &2 &C &9 &6 &3\\ \hline \text{} &1 &4 &B &E &0 &5 &A &F &3 &6 &9 &C &2 &7 &8 &D\\ \hline \text{} &4 &1 &E &B &5 &0 &F &A &6 &3 &C &9 &7 &2 &D &8\\ \hline \text{} &B &E &1 &4 &A &F &0 &5 &9 &C &3 &6 &8 &D &2 &7\\ \hline \text{} &E &B &4 &1 &F &A &5 &0 &C &9 &6 &3 &D &8 &7 &2\\ \hline \text{} &2 &7 &8 &D &3 &6 &9 &C &0 &5 &A &F &1 &4 &B &E\\ \hline \text{} &7 &2 &D &8 &6 &3 &C &9 &5 &0 &F &A &4 &1 &E &B\\ \hline \text{} &8 &D &2 &7 &9 &C &3 &6 &A &F &0 &5 &B &E &1 &4\\ \hline \text{} &D &8 &7 &2 &C &9 &6 &3 &F &A &5 &0 &E &B &4 &1\\ \hline \text{} &3 &6 &9 &C &2 &7 &8 &D &1 &4 &B &E &0 &5 &A &F\\ \hline \text{} &6 &3 &C &9 &7 &2 &D &8 &4 &1 &E &B &5 &0 &F &A\\ \hline \text{} &9 &C &3 &6 &8 &D &2 &7 &B &E &1 &4 &A &F &0 &5\\ \hline \text{}& C &9 &6 &3 &D &8 &7 &2 &E &B &4 &1 &F &A &5 &0\\ \hline \end{array}$$ • I'm not sure I understand what you're asking. The bitwise XOR operation is uniquely defined on the set of$n$-bit vectors for any$n$, so its Cayley table is unique up to permutation of the elements of the set. If you count tables listing the elements in a different order as distinct, then there are$2^n!$such tables. But you seem to be asking for the number of "valid" tables, for some specific meaning of "valid" that you haven't explicitly defined. – Ilmari Karonen Jun 13 '19 at 22:21 • Also, I find the connection to cryptography rather tenuous. If you really want an answer to this question, Mathematics is probably a better place for it. But I'd suggest clarifying it before asking it there. – Ilmari Karonen Jun 13 '19 at 22:23 • I'm voting to close this question as off-topic because it's a mathematics question with no direct application to cryptography. – Gilles 'SO- stop being evil' Jun 14 '19 at 6:30 • What are you asking? Are you asking how many groups of order 16 there are? Or how many abelian groups of order 16 there are? Or how many symmetric matrices in$\mathbb F_{16}$or$\mathbb Z/16\mathbb Z\$ there are? What is the connection of xor to the table you drew? What is it, exactly, that you invented? – Squeamish Ossifrage Jun 14 '19 at 13:20
• You can also always hit the ‘edit’ or ‘improve this answer’ button on anyone's post to see what markup and TeX it used. – Squeamish Ossifrage Jun 16 '19 at 16:40

How many such Caley XOR tables are theoretically possible that hold such qualities for a 16*16 table?

It is essential to define what we want to count. I read the constraints as

1. A table of $$r$$ line and columns for an internal law $$\boxplus$$ on $$\Bbb Z_r$$ (the non-negative integers less than $$r$$), with line and columns in the same arbitrary order. More precisely:
1. The table has $$r$$ lines and $$r$$ columns for $$r^2$$ entries $$T_{x,y}$$, plus $$r$$ labels $$L_i$$. Table entries, lines and columns numbers are in $$\Bbb Z_r$$. $$\begin{array}{c|ccccc} \boxplus&L_0&L_1&L_2&\ldots&L_{(r-1)}\\ \hline L_0&T_{0,0}&T_{1,0}&T_{2,0}&\ldots&T_{(r-1),0}\\ L_1&T_{0,1}&T_{1,1}&T_{2,1}&\ldots&T_{(r-1),1}\\ L_2&T_{0,2}&T_{1,2}&T_{2,2}&\ldots&T_{(r-1),2}\\ \vdots&\vdots&\vdots&\vdots&\ddots&\vdots\\ L_{(r-1)}&T_{0,(r-1)}&T_{1,(r-1)}&T_{2,(r-1)}&\ldots&T_{(r-1),(r-1)} \end{array}$$
2. Labels $$L_i$$ are a permutation of $$\Bbb Z_r$$.
3. Whenever $$L_x=u$$ and $$L_y=v$$, the table and internal law $$\boxplus$$ are such that it holds: $$u\boxplus v\ =\ T_{x,y}$$.
2. That internal law $$\boxplus$$ is $$\oplus$$ (eXclusive-OR, or XOR). Equivalently,
1. $$\boxplus$$ has neutral $$0$$: $$\forall u\in\Bbb Z_r, u\boxplus 0\ =\ 0\boxplus u\ =\ u$$.
2. $$\boxplus$$ is associative: $$\forall u,v,w\in\Bbb Z_r,\ (u\boxplus v)\boxplus w\ =\ u\boxplus (v\boxplus w)$$.
3. $$\boxplus$$ is invertible: $$\forall u\in\Bbb Z_r,\exists v\in\Bbb Z_r,\ u\boxplus v =\ v\boxplus u =\ 0$$.
4. $$\boxplus$$ is commutative: $$\forall u,v\in\Bbb Z_r,\ u\boxplus v=v\boxplus u$$.
5. $$\boxplus$$ is involutory: $$\forall u\in\Bbb Z_r,\ u\boxplus u=0$$.
3. The table is symmetric across the secondary diagonal: $$\forall x,y\in\Bbb Z_r$$, $$T_{x,y}=T_{(r-1-y),(r-1-x)}$$.
4. $$L_0=0$$.

Constraints 1 and 2.4 imply that $$T$$ is symmetric across the primary diagonal. Constraint 2.5 further implies that this diagonal is all $$0$$.
Assuming 1, constraints 2.1 thru 2.3 are that of $$\boxplus$$ being a group law for $$\Bbb Z_r$$. 2.4 specializes to a symmetric group. 2.5 further specializes to law $$\oplus$$ and implies that $$r$$ is a power of two.
Assuming 1 and 2.1, constraint 4 means that $$L$$ is also the top line and left columns of $$T$$. Constraint 3 further implies it is the bottom and right lines, read backward.

We restrict to $$r=2^n$$, $$n>0$$. Given constraints 1 and 2, constraint 3 is strictly equivalent to: $$\forall s\in\Bbb Z_r,\ L_s\oplus L_{(r-s-1)}\ =\ L_0\oplus L_{r-1}$$

Therefore, to construct any possible table:

• set $$L_0\gets0$$;
• freely select $$L_{r-1}$$ among the $$r-1$$ labels values other than $$0$$;
• for $$s$$ from $$1$$ to $$r/2$$, select $$L_{r-1-s}$$ and $$L_s$$ as follows:
• freely select $$L_{r-1-s}$$ among the $$r-2m$$ labels values not previously selected;
• set $$L_s\gets L_0\oplus L_{r-1}\oplus L_{r-1-s}$$;
• compute the $$r^2$$ values $$T_{x,y}\gets L_x\oplus L_y$$.

The number of possible assignments is the product of the number of choices (that we had for the right half of $$L$$; assignments for the left half have all been forced). That number is $$(r-1)$$ times the product of even integers from $$r-2$$ down to $$2$$. That is $$(r/2-1)!\,2^{r/2-1}\,(r-1)$$.

For the question $$r=16$$, giving $$7!\times2^7\times15\, = \,9676800$$ possible assignments.

I wrote a short C program to generate these tables, try it online. A table to generate is designated by an index from 0 to 9676799. Here are 8 examples (intentionally including the question's one when the index is 1971611; it's the but-last scrolling to the right).

\| 0 6 5 B 1 4 7 3 A E D 8 2 C F 9    \| 0 1 D 7 B E A 4 6 8 C 9 5 F 3 2    \| 0 9 B F C 7 E 2 8 4 D 6 5 1 3 A    \| 0 5 1 B 4 D A C F 9 E 7 8 2 6 3    \| 0 D 8 F A 7 5 9 2 E C 1 4 3 6 B    \| 0 D 1 2 B E C 7 3 8 A F 6 5 9 4    \| 0 5 A F 1 4 B E 2 7 8 D 3 6 9 C    \| 0 9 2 1 8 E 6 F A 3 B D 4 7 C 5
-+--------------------------------    -+--------------------------------    -+--------------------------------    -+--------------------------------    -+--------------------------------    -+--------------------------------    -+--------------------------------    -+--------------------------------
0| 0 6 5 B 1 4 7 3 A E D 8 2 C F 9    0| 0 1 D 7 B E A 4 6 8 C 9 5 F 3 2    0| 0 9 B F C 7 E 2 8 4 D 6 5 1 3 A    0| 0 5 1 B 4 D A C F 9 E 7 8 2 6 3    0| 0 D 8 F A 7 5 9 2 E C 1 4 3 6 B    0| 0 D 1 2 B E C 7 3 8 A F 6 5 9 4    0| 0 5 A F 1 4 B E 2 7 8 D 3 6 9 C    0| 0 9 2 1 8 E 6 F A 3 B D 4 7 C 5
6| 6 0 3 D 7 2 1 5 C 8 B E 4 A 9 F    1| 1 0 C 6 A F B 5 7 9 D 8 4 E 2 3    9| 9 0 2 6 5 E 7 B 1 D 4 F C 8 A 3    5| 5 0 4 E 1 8 F 9 A C B 2 D 7 3 6    D| D 0 5 2 7 A 8 4 F 3 1 C 9 E B 6    D| D 0 C F 6 3 1 A E 5 7 2 B 8 4 9    5| 5 0 F A 4 1 E B 7 2 D 8 6 3 C 9    9| 9 0 B 8 1 7 F 6 3 A 2 4 D E 5 C
5| 5 3 0 E 4 1 2 6 F B 8 D 7 9 A C    D| D C 0 A 6 3 7 9 B 5 1 4 8 2 E F    B| B 2 0 4 7 C 5 9 3 F 6 D E A 8 1    1| 1 4 0 A 5 C B D E 8 F 6 9 3 7 2    8| 8 5 0 7 2 F D 1 A 6 4 9 C B E 3    1| 1 C 0 3 A F D 6 2 9 B E 7 4 8 5    A| A F 0 5 B E 1 4 8 D 2 7 9 C 3 6    2| 2 B 0 3 A C 4 D 8 1 9 F 6 5 E 7
B| B D E 0 A F C 8 1 5 6 3 9 7 4 2    7| 7 6 A 0 C 9 D 3 1 F B E 2 8 4 5    F| F 6 4 0 3 8 1 D 7 B 2 9 A E C 5    B| B E A 0 F 6 1 7 4 2 5 C 3 9 D 8    F| F 2 7 0 5 8 A 6 D 1 3 E B C 9 4    2| 2 F 3 0 9 C E 5 1 A 8 D 4 7 B 6    F| F A 5 0 E B 4 1 D 8 7 2 C 9 6 3    1| 1 8 3 0 9 F 7 E B 2 A C 5 6 D 4
1| 1 7 4 A 0 5 6 2 B F C 9 3 D E 8    B| B A 6 C 0 5 1 F D 3 7 2 E 4 8 9    C| C 5 7 3 0 B 2 E 4 8 1 A 9 D F 6    4| 4 1 5 F 0 9 E 8 B D A 3 C 6 2 7    A| A 7 2 5 0 D F 3 8 4 6 B E 9 C 1    B| B 6 A 9 0 5 7 C 8 3 1 4 D E 2 F    1| 1 4 B E 0 5 A F 3 6 9 C 2 7 8 D    8| 8 1 A 9 0 6 E 7 2 B 3 5 C F 4 D
4| 4 2 1 F 5 0 3 7 E A 9 C 6 8 B D    E| E F 3 9 5 0 4 A 8 6 2 7 B 1 D C    7| 7 E C 8 B 0 9 5 F 3 A 1 2 6 4 D    D| D 8 C 6 9 0 7 1 2 4 3 A 5 F B E    7| 7 A F 8 D 0 2 E 5 9 B 6 3 4 1 C    E| E 3 F C 5 0 2 9 D 6 4 1 8 B 7 A    4| 4 1 E B 5 0 F A 6 3 C 9 7 2 D 8    E| E 7 C F 6 0 8 1 4 D 5 3 A 9 2 B
7| 7 1 2 C 6 3 0 4 D 9 A F 5 B 8 E    A| A B 7 D 1 4 0 E C 2 6 3 F 5 9 8    E| E 7 5 1 2 9 0 C 6 A 3 8 B F D 4    A| A F B 1 E 7 0 6 5 3 4 D 2 8 C 9    5| 5 8 D A F 2 0 C 7 B 9 4 1 6 3 E    C| C 1 D E 7 2 0 B F 4 6 3 A 9 5 8    B| B E 1 4 A F 0 5 9 C 3 6 8 D 2 7    6| 6 F 4 7 E 8 0 9 C 5 D B 2 1 A 3
3| 3 5 6 8 2 7 4 0 9 D E B 1 F C A    4| 4 5 9 3 F A E 0 2 C 8 D 1 B 7 6    2| 2 B 9 D E 5 C 0 A 6 F 4 7 3 1 8    C| C 9 D 7 8 1 6 0 3 5 2 B 4 E A F    9| 9 4 1 6 3 E C 0 B 7 5 8 D A F 2    7| 7 A 6 5 C 9 B 0 4 F D 8 1 2 E 3    E| E B 4 1 F A 5 0 C 9 6 3 D 8 7 2    F| F 6 D E 7 1 9 0 5 C 4 2 B 8 3 A
A| A C F 1 B E D 9 0 4 7 2 8 6 5 3    6| 6 7 B 1 D 8 C 2 0 E A F 3 9 5 4    8| 8 1 3 7 4 F 6 A 0 C 5 E D 9 B 2    F| F A E 4 B 2 5 3 0 6 1 8 7 D 9 C    2| 2 F A D 8 5 7 B 0 C E 3 6 1 4 9    3| 3 E 2 1 8 D F 4 0 B 9 C 5 6 A 7    2| 2 7 8 D 3 6 9 C 0 5 A F 1 4 B E    A| A 3 8 B 2 4 C 5 0 9 1 7 E D 6 F
E| E 8 B 5 F A 9 D 4 0 3 6 C 2 1 7    8| 8 9 5 F 3 6 2 C E 0 4 1 D 7 B A    4| 4 D F B 8 3 A 6 C 0 9 2 1 5 7 E    9| 9 C 8 2 D 4 3 5 6 0 7 E 1 B F A    E| E 3 6 1 4 9 B 7 C 0 2 F A D 8 5    8| 8 5 9 A 3 6 4 F B 0 2 7 E D 1 C    7| 7 2 D 8 6 3 C 9 5 0 F A 4 1 E B    3| 3 A 1 2 B D 5 C 9 0 8 E 7 4 F 6
D| D B 8 6 C 9 A E 7 3 0 5 F 1 2 4    C| C D 1 B 7 2 6 8 A 4 0 5 9 3 F E    D| D 4 6 2 1 A 3 F 5 9 0 B 8 C E 7    E| E B F 5 A 3 4 2 1 7 0 9 6 C 8 D    C| C 1 4 3 6 B 9 5 E 2 0 D 8 F A 7    A| A 7 B 8 1 4 6 D 9 2 0 5 C F 3 E    8| 8 D 2 7 9 C 3 6 A F 0 5 B E 1 4    B| B 2 9 A 3 5 D 4 1 8 0 6 F C 7 E
8| 8 E D 3 9 C F B 2 6 5 0 A 4 7 1    9| 9 8 4 E 2 7 3 D F 1 5 0 C 6 A B    6| 6 F D 9 A 1 8 4 E 2 B 0 3 7 5 C    7| 7 2 6 C 3 A D B 8 E 9 0 F 5 1 4    1| 1 C 9 E B 6 4 8 3 F D 0 5 2 7 A    F| F 2 E D 4 1 3 8 C 7 5 0 9 A 6 B    D| D 8 7 2 C 9 6 3 F A 5 0 E B 4 1    D| D 4 F C 5 3 B 2 7 E 6 0 9 A 1 8
2| 2 4 7 9 3 6 5 1 8 C F A 0 E D B    5| 5 4 8 2 E B F 1 3 D 9 C 0 A 6 7    5| 5 C E A 9 2 B 7 D 1 8 3 0 4 6 F    8| 8 D 9 3 C 5 2 4 7 1 6 F 0 A E B    4| 4 9 C B E 3 1 D 6 A 8 5 0 7 2 F    6| 6 B 7 4 D 8 A 1 5 E C 9 0 3 F 2    3| 3 6 9 C 2 7 8 D 1 4 B E 0 5 A F    4| 4 D 6 5 C A 2 B E 7 F 9 0 3 8 1
C| C A 9 7 D 8 B F 6 2 1 4 E 0 3 5    F| F E 2 8 4 1 5 B 9 7 3 6 A 0 C D    1| 1 8 A E D 6 F 3 9 5 C 7 4 0 2 B    2| 2 7 3 9 6 F 8 E D B C 5 A 0 4 1    3| 3 E B C 9 4 6 A 1 D F 2 7 0 5 8    5| 5 8 4 7 E B 9 2 6 D F A 3 0 C 1    6| 6 3 C 9 7 2 D 8 4 1 E B 5 0 F A    7| 7 E 5 6 F 9 1 8 D 4 C A 3 0 B 2
F| F 9 A 4 E B 8 C 5 1 2 7 D 3 0 6    3| 3 2 E 4 8 D 9 7 5 B F A 6 C 0 1    3| 3 A 8 C F 4 D 1 B 7 E 5 6 2 0 9    6| 6 3 7 D 2 B C A 9 F 8 1 E 4 0 5    6| 6 B E 9 C 1 3 F 4 8 A 7 2 5 0 D    9| 9 4 8 B 2 7 5 E A 1 3 6 F C 0 D    9| 9 C 3 6 8 D 2 7 B E 1 4 A F 0 5    C| C 5 E D 4 2 A 3 6 F 7 1 8 B 0 9
9| 9 F C 2 8 D E A 3 7 4 1 B 5 6 0    2| 2 3 F 5 9 C 8 6 4 A E B 7 D 1 0    A| A 3 1 5 6 D 4 8 2 E 7 C F B 9 0    3| 3 6 2 8 7 E 9 F C A D 4 B 1 5 0    B| B 6 3 4 1 C E 2 9 5 7 A F 8 D 0    4| 4 9 5 6 F A 8 3 7 C E B 2 1 D 0    C| C 9 6 3 D 8 7 2 E B 4 1 F A 5 0    5| 5 C 7 4 D B 3 A F 6 E 8 1 2 9 0


(Does the..) table (..$$T$$..) represent all possible XOR combinations for single hex characters?

Yes. Constraint 1 tells that $$T$$ is the full table for $$u\boxplus v$$, and constraint 2 that $$\boxplus$$ is XOR.

(..) why are there only a total of 51 unique (..combinations of $$M,K,C$$ with $$M\oplus K=C$$, within order)?

Because $$a_n=(2^n+1)(2^n+2)/6$$ has value $$51$$ for $$n=4$$. That sequence is OEIS A007581, stating (without proof):
a(n) is also the number of distinct solutions (avoiding permutations) to the equation: XOR(A,B,C)=0 where A,B,C are n-bit binary numbers. - Ramasamy Chandramouli, Jan 11 2009