Securely computing functions over source code I have been studying multi-party computation and want to start implementing it. I think it would be interesting to do this where one of the inputs (say party 1) is some source code, say a .py file. 

If for example I wanted to securely compute the number of lines of code this file had, how would I go about it? The functionality would look something like $$f(code.py, \_) = (\_, \text{number of lines in code.py})$$ where $\_$ represents the empty string. 

I think MPC is up to this task but are there any better ways this functionality could be realised? 

Also, any pointers to packages that would be good to implement this in would be nice also.
I'd like to divide the problem into semi-honest and malicious adversaries with corrupt the party inputting the source code.

In the semi-honest setting, you assume an adversary which follows the protocol correctly, but tries to learn information from the messages the party corrupted by the adversary. As a result, if you assume the adversary is semi-honest, the problem will be trivial to compute since that party can simply compute the lines of code himself and send the other party the result.

It will be very hard to securely construct a secure multiparty computation protocol in the malicious setting where an adversary may also vary the protocol specification, if there are not additional properties about the code known to both parties, like the length of the code. That is for two reasons:


Some data like the length of the code has to get leaked. As to my knowledge, there is no MPC protocol known which permits inputs of variable length.
Adversaries in the malicious setting may input another input like anothercode.py. You can assume that the input is not changed by the adversary, but then you can just use the semi-honest setting.


My best idea of designing the MPC procotol you desire would be to define and reveal properties about the code and then prove them using zero knowledge protocols such that these properties are fulfilled. The best candidates which come to my mind are Zero-Knowledge Using Garbled Circuits or ZKBoo: Faster Zero-Knowledge for Boolean Circuits (the authors even provided an impmenentation of ZKBoo on Github). These protocols are zero-knowledge protocols which prove generic statements (generic as described using AND/XOR gates) using MPC techniques.