0

I have an application which is using gRPC, client.py and server.py , I want to use gramine in order to execute the service inside SGX. how can I run a specific method not the whole script inside sgx using gramine? client.py:

"""The Python implementation of the GRPC helloworld.Greeter client."""

from __future__ import print_function

import logging

import grpc
import helloworld_pb2
import helloworld_pb2_grpc


def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    print("Will try to greet world ...")
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = helloworld_pb2_grpc.GreeterStub(channel)
        response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
    print("Greeter client received: " + response.message)


if __name__ == '__main__':
    logging.basicConfig()
    run()

and server.py:

from concurrent import futures
import logging

import grpc
import helloworld_pb2
import helloworld_pb2_grpc


class Greeter(helloworld_pb2_grpc.GreeterServicer):

    def SayHello(self, request, context):
        return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)


def serve():
    port = '50051'
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server)
    server.add_insecure_port('[::]:' + port)
    server.start()
    print("Server started, listening on " + port)
    server.wait_for_termination()


if __name__ == '__main__':
    logging.basicConfig()
    serve()

let say I want to execute sayhello inside SGX when I run client.py currently I am running gramine-sgx ./python client.py that is going to execute only client inside SGX or is it going to also run sayhello from server.py inside SGX?

sama
  • 333
  • 2
  • 11

1 Answers1

0

how can I run a specific method not the whole script inside sgx using gramine?

You can't. However you could have two scripts. One script running in SGX implementing the functionality you want to compute securely, the other script communicating with the first script in order to receive the answer.

I am running gramine-sgx ./python client.py that is going to execute only client inside SGX or is it going to also run sayhello from server.py inside SGX?

This only executes the client in an enclave. The code executed on the server-side (i.e. SayHello) is not run in SGX if you start the server with python server.py, but it is run in an enclave if you do gramine-sgx ./python server.py.

gutjuri
  • 57
  • 6