Maybe you can make your script separate from the spreadsheet. Then import it as a library. I believe that keeps your code private.
Just as a note, it seems that anyone with edit access to a spreadsheet also has edit access to the script associated with the spreadsheet.