You actually could publish “illegal code” because code is protected under 1st amendment, as free speech. Legal precedent has been set by Bernstein v US DoJ.
There is an open question about whether publishing non custodial contract code on Ethereum counts as providing a service. If you post 10 lines of immutable code onto Ethereum, and some years later a user chooses to run this code on their machines for criminal behavior, should you be prosecuted?
There is an open question about whether publishing non custodial contract code on Ethereum counts as providing a service. If you post 10 lines of immutable code onto Ethereum, and some years later a user chooses to run this code on their machines for criminal behavior, should you be prosecuted?