The Legendary Origins Of Tofu
Like bread, people probably did not just encounter tofu. As Green Matters describes, tofu is curd made from soybeans. The process behind this involves first growing and harvesting soybeans. Those soybeans are then ground in water to make a milk, to which calcium and magnesium salt are added. This will cause the milk to coagulate into curds which, after processing, become the tofu blocks you can buy in the supermarket.
In short, it is a very involved process, and no one knows how it came about. Soy Info Center notes the first mention of tofu occurred in 950 AD, at which point it was already a well-established food. One theory is that the coagulation occurred by accident. Someone left out the ground soybeans and made a happy discovery. Another couple of theories suggest that the Chinese used techniques borrowed from either India or Mongolia. These people had their own cheese-making process, so someone simply applied the same idea to soybeans. But since there is no historical agreement concerning the invention of tofu, one individual inevitably has earned a legendary status as the sole inventor.
The legendary version of tofu
Legend has it that the Chinese nobleman and scholar Lui An invented tofu. China Daily recounts how the grandson of Emperor Liu Bang, the founder of the Han dynasty, wanted to develop a food that would grant immortality. Cultural China, however, claims Lui An acted in the hope that he would create a magical substance to heal his grandmother's illness. Instead, he created tofu. When he had some peasants try the tofu, they discovered it was delicious. In the end, as Britannica describes, Lui An was implicated in a plot against the throne. So he died. Or, as some accounts shared by Soy Info Center attest, he grew wings and ascended to the immortals.
Soy Info Center grants that Lui An was probably alive at a time soymilk existed. So, he could theoretically be the inventor of tofu. However, the center also notes that none of Lui An's written work mentions tofu. His claim to credit, then, seems to rest on people's natural propensity for ascribing inventions to noble individuals, the Chinese association between tofu and longevity, and its vegetarian nature make it a favorite of Taoists with whom Lui An associated. Indeed, the association only seems to have begun in the twelfth century, over a thousand years after Lui An died. Soy Info Center gives more space explaining how the Mongolian theory is more likely and that the Chinese developed tofu because they loved Mongolian cheese but lacked dairy animals.