Sanhedrin 59a does not say "Murdering goyim is like killing a wild animal .... To communicate anything to a goy about our religious relations would be equal to the killing of all Jews, for if the goyim knew what we teach about them they would kill us openly .... If a Jew be called upon to explain any part of the rabbinic books, he ought to give only a false explanation. Whoever will violate this order shall be put to death." This is several layers away from what the passage was originally about, namely, what natural law applies to all men and what Mosaic law applies to the Jews. In some versions of this meme, Sanhedrin is accurately paraphrased as "A goy who pries into the law is guilty of death"; more literally at Sefaria, in one rabbi's name: "Rabbi Yohanan says: A Gentile who engages in Torah, liable death; as it is stated: 'Moses commanded us a law, an inheritance'; it is an inheritance for us, and not for them." This view is then rejected in favor of another baraita by Rabbi Meir, with the conclusion, "You have therefore learned that even a Gentile who engages in Torah is like a High Priest. There, in their seven mitzvot." That is, since Gentiles must study Torah to find out the (seven) Laws of Noah, they are free to study Torah; and Yohanan represents a rejected view. The extended form of the statement above comes not from the Talmud but is often attributed to a fictitious book name, "Libbre David 37". The nonexistence of "Libbre David" as a book or even a Hebrew phrase, and the nonexistence of quotes in several of the books correctly titled "Dibre David" beginning in 1671, was noted as early as 1920 by Hermann Strack, cited in 1939 by Ben Zion Bokser. This typo and quote arose from an anti-Talmud pamphlet, apparently by August Rohling (c. 1871), quoted by Joseph S. Bloch, Israel and the Nations, 1927, p. 4. However, the quote may still exist in some unsearched Dibre David.
Sanhedrin 58b comes close to saying "If a goy hits a Jew he must be killed." It says: "Rabbi Hanina says: A Gentile who struck a Jew is liable death, as it is stated, And he turned this way and that way, and when he saw that there was no man, he struck the Egyptian." Since the context is Ex. 2:12, this refers to Moses's vengeance for the Egyptian "smiting" a Hebrew, meaning to injure willfully and often unto death. This reflects the capital punishment laws of Ex. 21:12 and applies to all, as the same Talmud passage says, "Rava says: Is there any for which a Jew is not deemed liable, but a Gentile is deemed liable?" That is, all are alike.
That Dibre David link gives up to 6 candidates for the possible text, but they are probably all offline and untranslated. But one of them might have the long quote misattributed in the 19th century to "Libbre" David.
Boilerplate:
Sanhedrin 59a does not say "Murdering goyim is like killing a wild animal .... To communicate anything to a goy about our religious relations would be equal to the killing of all Jews, for if the goyim knew what we teach about them they would kill us openly .... If a Jew be called upon to explain any part of the rabbinic books, he ought to give only a false explanation. Whoever will violate this order shall be put to death." This is several layers away from what the passage was originally about, namely, what natural law applies to all men and what Mosaic law applies to the Jews. In some versions of this meme, Sanhedrin is accurately paraphrased as "A goy who pries into the law is guilty of death"; more literally at Sefaria, in one rabbi's name: "Rabbi Yohanan says: A Gentile who engages in Torah, liable death; as it is stated: 'Moses commanded us a law, an inheritance'; it is an inheritance for us, and not for them." This view is then rejected in favor of another baraita by Rabbi Meir, with the conclusion, "You have therefore learned that even a Gentile who engages in Torah is like a High Priest. There, in their seven mitzvot." That is, since Gentiles must study Torah to find out the (seven) Laws of Noah, they are free to study Torah; and Yohanan represents a rejected view. The extended form of the statement above comes not from the Talmud but is often attributed to a fictitious book name, "Libbre David 37". The nonexistence of "Libbre David" as a book or even a Hebrew phrase, and the nonexistence of quotes in several of the books correctly titled "Dibre David" beginning in 1671, was noted as early as 1920 by Hermann Strack, cited in 1939 by Ben Zion Bokser. This typo and quote arose from an anti-Talmud pamphlet, apparently by August Rohling (c. 1871), quoted by Joseph S. Bloch, Israel and the Nations, 1927, p. 4. However, the quote may still exist in some unsearched Dibre David.
Sanhedrin 58b comes close to saying "If a goy hits a Jew he must be killed." It says: "Rabbi Hanina says: A Gentile who struck a Jew is liable death, as it is stated, And he turned this way and that way, and when he saw that there was no man, he struck the Egyptian." Since the context is Ex. 2:12, this refers to Moses's vengeance for the Egyptian "smiting" a Hebrew, meaning to injure willfully and often unto death. This reflects the capital punishment laws of Ex. 21:12 and applies to all, as the same Talmud passage says, "Rava says: Is there any for which a Jew is not deemed liable, but a Gentile is deemed liable?" That is, all are alike.
That Dibre David link gives up to 6 candidates for the possible text, but they are probably all offline and untranslated. But one of them might have the long quote misattributed in the 19th century to "Libbre" David.