Secure XPC service call

I would like to develop a macOS application in Swift. This application will consist of 2 programs: a main program to be run by the user (standard account) and another one that will run with root privileges. The second program will only be invoked to perform privileged tasks. Running the main program under root permanently would be too risky.

XPC will be used to trigger calls from the main program to the privileged program.

How can I secure the privileged program to ensure that the calling program is indeed my main program and not another unauthorized program?

Secure XPC service call
 
 
Q