ENCRYPTION.md 1.8 KB
Newer Older
T
111  
Thomas Young 已提交
1
# MOEDL ENCRYPTION INFERENCE
H
HexToString 已提交
2

T
111  
Thomas Young 已提交
3
([简体中文](ENCRYPTION_CN.md)|English)
H
HexToString 已提交
4

T
111  
Thomas Young 已提交
5
Paddle Serving provides model encryption inference, This document shows the details.
H
HexToString 已提交
6

T
111  
Thomas Young 已提交
7
## Principle
H
HexToString 已提交
8

T
111  
Thomas Young 已提交
9
We use symmetric encryption algorithm to encrypt the model. Symmetric encryption algorithm uses the same key for encryption and decryption, it has small amount of calculation, fast speed, is the most commonly used encryption method.
H
HexToString 已提交
10

T
Thomas Young 已提交
11
### Got an Encrypted Model
T
111  
Thomas Young 已提交
12 13 14

Normal model and parameters can be understood as a string, by using the encryption algorithm (parameter is your key) on them, the normal model and parameters become an encrypted one.

T
fff  
Thomas Young 已提交
15
We provide a simple demo to encrypt the model. See the [python/examples/encryption/encrypt.py](../python/examples/encryption/encrypt.py)
T
Thomas Young 已提交
16 17 18 19 20 21 22 23 24


### Start Encryption Service

Suppose you already have an encrypted model(in the `encrypt_server/`),you can start the encryption model service by adding an additional command line parameter `--use_encryption_model`

CPU Service
```
python -m paddle_serving_server.serve --model encrypt_server/ --port 9300 --use_encryption_model
H
HexToString 已提交
25
```
T
Thomas Young 已提交
26 27
GPU Service
```
28
python -m paddle_serving_server.serve --model encrypt_server/ --port 9300 --use_encryption_model --gpu_ids 0
H
HexToString 已提交
29 30
```

T
Thomas Young 已提交
31
At this point, the server does not really start, but waits for the key。
H
HexToString 已提交
32

T
Thomas Young 已提交
33
### Client Encryption Inference
H
HexToString 已提交
34

T
Thomas Young 已提交
35
First of all, you got have the key which is used in the process of model encryption.
H
HexToString 已提交
36

T
Thomas Young 已提交
37
Then you can configure your client with the key, when you connect the server, this key will send to the server and the server will keep it.
H
HexToString 已提交
38

T
Thomas Young 已提交
39
Once the server gets the key, it uses the key to parse the model and starts the model prediction service.
H
HexToString 已提交
40 41


T
Thomas Young 已提交
42 43 44
### Example of Model Encryption Inference
Example of model encryption inference, See the [`/python/examples/encryption/`](../python/examples/encryption/)