This component complements the Secure Multi-Party Computation and Secure Two-Party Vector Product Proofs of Concept using the Paillier Cryptosystem. Below is a brief overview of the IPC functionalities. Detailed descriptions of the two implementations can be found in their respective folders.
MiniPC is a lightweight Inter-Process Communication (IPC) library for Lua that provides robust TCP socket communication with automatic retry mechanisms. It simplifies client-server communication patterns with an emphasis on reliability and ease of use.
- Simple server-client socket communication
- Automatic retry mechanism for network operations
- Support for broadcast messages
- Custom callback handling
- Built-in logging system
- Lua 5.4+
- LuaSocket library
- Install LuaSocket:
luarocks install luasocket- Include the library in your project:
local minipc = require("minipc.lua")minipc.ip -- Server IP address (default: "127.0.0.1")
minipc.port -- Server port (default: 6969)-- Standard logging
minipc.log(message)
-- Secure logging (only visual)
minipc.sec(message)minipc:serve(message, broadcast, callback)Parameters:
message: Data to send to clientsbroadcast: Number of clients to serve (default: 1)callback: Optional custom handler function(clients, message)
minipc:eat(callback)Parameters:
callback: Optional custom handler function(client) Returns:- Received data from server
minipc.retry(task, retries, delay)Parameters:
task: Function to retryretries: Maximum retry attempts (default: 4)delay: Initial delay in seconds (default: 1)
local minipc = require("minipc.lua")
-- Serve a message to one client
minipc:serve("Hello, client!")local minipc = require("minipc.lua")
-- Receive a message
local message = minipc:eat()
print(message) -- Outputs: Hello, client!-- Server broadcasting to multiple clients
minipc:serve("Broadcast message", 3)-- Server with custom handling
minipc:serve("data", 2, function(clients, message)
for _, client in ipairs(clients) do
client:send(message .. " processed\n")
end
end)
-- Client with custom handling
local result = minipc:eat(function(client)
local data = client:receive()
return data .. " acknowledged"
end)minipc.retry(function()
return minipc:serve("Important message")
end, 5, 2)- All network operations are wrapped in error handling
- Failed operations throw descriptive errors
- Retry mechanism helps handle temporary network issues
- Socket resources are properly cleaned up
- Secure logging option for sensitive data
- Proper socket cleanup
- Error handling for connection failures
- TCP-only communication
- Synchronous operations
- Single server instance per port
- Basic error handling
- Async operation support
- Multiple server instances
- UDP support
- Enhanced error recovery
- Connection pooling