This example demonstrates how to use RSA encryption with INTERSECT services.
RSA encryption provides end-to-end encryption for messages between clients and services:
- Clients encrypt requests using the service's public key
- Services encrypt responses using the client's public key
- Each party decrypts messages using their own private key
hello_service.py- Service implementation with RSA encryption enabledhello_client.py- Client implementation that sends RSA encrypted messageshello_service_schema.json- Service schema defining available operations
-
Automatic RSA Key Generation:
- Both service and client automatically generate RSA key pairs internally
- No manual key management required
- Service automatically handles public key requests from clients
-
Transparent Encryption:
- Simply set
encryption_scheme='RSA'when sending messages - INTERSECT SDK handles all encryption/decryption automatically
- Public key exchange happens automatically in the background
- Simply set
-
Start the service:
python -m examples.5_hello_world_rsa.hello_service
-
In another terminal, run the client:
python -m examples.5_hello_world_rsa.hello_client
Client output:
Hello, hello_client!
- Client starts and generates its RSA key pair
- Client sends encrypted message to service (encryption_scheme='RSA')
- Client first fetches service's public key via
intersect_sdk.get_public_key - Client encrypts the request using service's public key
- Service receives encrypted request and decrypts it using its private key
- Service processes the request and generates a response
- Service fetches client's public key (if not cached)
- Service encrypts response using client's public key
- Client receives encrypted response and decrypts it using its private key
- Client prints the decrypted response
- Each service and client automatically generates its own unique RSA key pair on startup
- Private keys are managed internally by the SDK and never transmitted
- Public keys are exchanged automatically via the INTERSECT messaging system
- RSA encryption uses 2048-bit keys for strong security
- No manual key management is required - the SDK handles everything automatically