# Can we use LEGO bricks to construct a cipher algorithm?

I read a paper titled "On the entropy of LEGO", which explains how to calculate the number of ways to combine $$n$$ $$b\times w$$ LEGO blocks of the same color. For example, six $$2\times4$$ bricks have $$915103765$$ ways to combine. I wonder if could we construct a funny cipher algorithm using LEGO bricks.

Some definitions and symbols:

A $$2\times4$$ brick $$i$$ can be defined as: $$b_i:=\left( \begin{array}{cc} s_0,s_1,s_2,s_3 \\ s_4,s_5,s_6,s_7 \end{array} \right)$$, where $$s_{i,k}:=(0/1,-/b_j)$$ means if a stud $$s_{i,k}$$ is occupied by another brick $$b_j$$, then $$s_{i,k}=(1,b_j)$$; else if no brick is put on this stud $$s_{i,k}$$, then $$s_{i,k}=(0,-)$$.

Then, we have a key space $$\mathcal{K}=\{b_1\cup b_2\cup ...\cup b_n\}$$, where $$n$$ is the number of bricks, $$\cup$$ means the combination of bricks (Sorry, I cannot find an appropriate symbol to present the meaning).

The number $$num$$ of ways to combine $$n$$ $$2\times4$$ bricks is: $$num:=(2^{n-1} + 46^{n-1})/2$$, therefore, the size of $$\mathcal{K}$$ is the number $$num=|\mathcal{K}|$$.

Assuming that there is an one way function $$f(k,m)\to c,k\in\mathcal{K}, m\in\mathcal{M},c\in\mathcal{C}$$, where $$\mathcal{M}$$ is the plaintext space, and $$\mathcal{C}$$ is the ciphertext space.

So far, I still cannot find a method to construct the one-way function and confirm whether the LEGO bricks can be used to construct a cipher algorithm or not.

• I'm sure we can construct one with LEGO bricks. See Solitaire which is constructed from playing cards. If nothing else you could make playing cards from LEGO and then run Solitaire. Or treat green bricks as 1 and red bricks as 0 and then run AES. Nov 2 '21 at 10:05
• You can build any of the standard logic gates with LEGO, which can be combined to make encryption hardware. Nov 2 '21 at 18:41
• Back in 1977, Desmond Bagley's novel The Enemy had a subplot of using trucks on a computerized model railway to encode messages. Compared to that, Lego bricks is pretty straightforward. Nov 2 '21 at 22:25

It seems like what you are actually describing is a way to encode data with Lego bricks, rather than encrypting with them. But, maybe the way that you encode data is hard to invert without knowing a secret key, for example.

I don't think the lego adds security to this encoding, though. Suppose you design a method $$f$$ to encode your message space $$\mathcal{M}$$ into possible arrangements of bricks, $$\mathcal{B}$$. I could design my own correspondence $$g$$ between bitstrings $$\{0,1\}^n$$ and $$\mathcal{B}$$ (for some $$n$$). Then $$g^{-1}\circ f$$ maps from $$\mathcal{M}$$ into $$\{0,1\}^n$$, turning your lego cipher into a regular cipher on bitstrings. This means that if you encrypt a message into bricks and I find the bricks, I can translate their arrangement into bricks and attack the cipher as though it were a traditional computer cipher. Hence, if your map from messages into brick arrangements is supposed to be secure, it should also be secure when viewed as a map from messages into bitstrings.

From this I think the hard work of designing a normal secure cipher still needs to be done, even if lego is the end goal. But I can still see two uses of lego: (1) steganography: to store a small encrypted message in a way that most people wouldn't notice is important; (2) to help compute a cipher by hand (e.g., by making parts of the "computation" easy to store and move around).

• Nov 2 '21 at 17:41
• Thank you very much for your advice. Nov 6 '21 at 11:11

It is possible to build something reminiscent of mechanical cipher machines using Lego Technic gears and less complicated parts: