Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PEAFOWL - Privacy-Preserving Entity Alignment for Vertical Federated Learning

English | ไธญๆ–‡

ไธญๆ–‡

PEAFOWL ๆ˜ฏไธ€ไธชไธบๅž‚็›ด่”้‚ฆๅญฆไน ่ฎพ่ฎก็š„้š็งไฟๆŠคๅฎžไฝ“ๅฏน้ฝๅ่ฎฎๆก†ๆžถใ€‚ๅฎƒๅ…่ฎธไธๅŒๆ•ฐๆฎๆ–นๅœจไธๆณ„้œฒๅ„่‡ชๆ•ฐๆฎ็š„ๆƒ…ๅ†ตไธ‹๏ผŒๅฎ‰ๅ…จๅœฐๆ‰พๅ‡บๅ…ฑๅŒๆ ทๆœฌ๏ผˆไบค้›†๏ผ‰๏ผŒๅนถๅŸบไบŽๅฏน้ฝๅŽ็š„ๆ•ฐๆฎ่”ๅˆ่ฎญ็ปƒๆœบๅ™จๅญฆไน ๆจกๅž‹ใ€‚

ๆ ธๅฟƒ็‰นๆ€ง

  • ้š็งไฟๆŠค๏ผšไฝฟ็”จๅŠ ๆณ•็ง˜ๅฏ†ๅ…ฑไบซใ€ไผช้šๆœบๅ‡ฝๆ•ฐใ€ๅฏ†้’ฅๅŒๆ€ไผช้šๆœบ็”Ÿๆˆๅ™จ็ญ‰ๅฏ†็ ๅญฆๆŠ€ๆœฏ๏ผŒ็กฎไฟไบค้›†ไฟกๆฏไธ่ขซๆณ„้œฒ
  • ้ซ˜ๆ•ˆๅ่ฎฎ๏ผš้€šไฟกๅ’Œ่ฎก็ฎ—ๅคๆ‚ๅบฆไธบ็บฟๆ€ง็บงๅˆซ O(n)๏ผŒ้€‚ๅˆๅคง่ง„ๆจกๆ•ฐๆฎ้›†
  • ๅคšๆ–นๆ”ฏๆŒ๏ผšๆ”ฏๆŒๅคšไธชๆ•ฐๆฎๅ‚ไธŽๆ–น็š„ๅฎžไฝ“ๅฏน้ฝ
  • ็ตๆดปๆจกๅž‹๏ผšๆ”ฏๆŒ้€ป่พ‘ๅ›žๅฝ’ใ€CNNใ€SVM็ญ‰ๅคš็งๆœบๅ™จๅญฆไน ๆจกๅž‹

ๆŠ€ๆœฏๅŽŸ็†

PEAFOWL ๅ่ฎฎ็š„ๆ ธๅฟƒๆ€ๆƒณๆ˜ฏ้€š่ฟ‡**็ฝฎๆข๏ผˆPermutation๏ผ‰ๅ’Œ็ง˜ๅฏ†ๅ…ฑไบซ๏ผˆSecret Sharing๏ผ‰**ๆฅๅฎž็Žฐๅฎ‰ๅ…จๅฏน้ฝ๏ผš

  1. ๅฎžไฝ“ๅฏน้ฝ๏ผšๅ„ๆ–นๅŠ ๅฏ†่‡ชๅทฑ็š„ๆ ทๆœฌIDๅนถๅ‘้€็ป™ๆœๅŠกๅ™จ๏ผŒๆœๅŠกๅ™จ่ฎก็ฎ—ไบค้›†ๅคงๅฐ๏ผŒไฝ†ไธ็Ÿฅ้“ๅ…ทไฝ“ไบค้›†ID
  2. ็‰นๅพ็ป„ๅˆ๏ผšๅ„ๆ–นๅŸบไบŽไบค้›†ๆ ทๆœฌ๏ผŒไฝฟ็”จPEAFOWLๅ่ฎฎ็ป„ๅˆๅ„่‡ช็š„็‰นๅพ
  3. ๅฎ‰ๅ…จ่ฎก็ฎ—๏ผš้€š่ฟ‡็ง˜ๅฏ†ๅ…ฑไบซๅ’ŒSHPRG๏ผˆๅฏ†้’ฅๅŒๆ€ไผช้šๆœบ็”Ÿๆˆๅ™จ๏ผ‰ๆททๆท†็‰นๅพๅ€ผ๏ผŒ็กฎไฟๆœๅŠกๅ™จๆ— ๆณ•่Žทๅ–ๅŽŸๅง‹ๆ•ฐๆฎ

้กน็›ฎ็ป“ๆž„

peafowl-python/
โ”œโ”€โ”€ core/                      # ๅŸบ็ก€ๅฏ†็ ๅญฆๅŽŸ่ฏญ
โ”‚   โ”œโ”€โ”€ secret_sharing.py      # ๅŠ ๆณ•็ง˜ๅฏ†ๅ…ฑไบซ
โ”‚   โ”œโ”€โ”€ prf.py                 # ไผช้šๆœบๅ‡ฝๆ•ฐ๏ผˆๅŸบไบŽHMAC-SHA256๏ผ‰
โ”‚   โ”œโ”€โ”€ shprg.py               # ๅฏ†้’ฅๅŒๆ€ไผช้šๆœบ็”Ÿๆˆๅ™จ๏ผˆๅŸบไบŽLWR๏ผ‰
โ”‚   โ”œโ”€โ”€ ot.py                  # ไธ็ปๆ„ไผ ่พ“ๆ‰ฉๅฑ•
โ”‚   โ””โ”€โ”€ polynomial.py          # ๅคš้กนๅผ่ฟ็ฎ—๏ผˆๆ‹‰ๆ ผๆœ—ๆ—ฅๆ’ๅ€ผ๏ผ‰
โ”œโ”€โ”€ protocol/                  # PEAFOWLๅ่ฎฎๅฎž็Žฐ
โ”‚   โ”œโ”€โ”€ przs.py                # ไผช้šๆœบ้›ถๅ…ฑไบซ
โ”‚   โ””โ”€โ”€ peafowl.py             # ไธปๅ่ฎฎ
โ”œโ”€โ”€ party/                     # ่ง’่‰ฒๅฎž็Žฐ
โ”‚   โ”œโ”€โ”€ data_provider.py       # ๆ•ฐๆฎๆไพ›ๆ–น
โ”‚   โ””โ”€โ”€ server.py              # ไบ‘ๆœๅŠกๅ™จ
โ”œโ”€โ”€ network/                   # ็ฝ‘็ปœๆจกๆ‹Ÿ
โ”‚   โ””โ”€โ”€ channel.py             # ้€šไฟก้€š้“
โ”œโ”€โ”€ utils/                     # ๅทฅๅ…ทๅ‡ฝๆ•ฐ
โ”‚   โ””โ”€โ”€ data_loader.py         # ๆ•ฐๆฎๅŠ ่ฝฝ
โ”œโ”€โ”€ webapp/                    # Webๅฏ่ง†ๅŒ–ๅบ”็”จ
โ”‚   โ”œโ”€โ”€ app.py                 # FlaskๅŽ็ซฏๆœๅŠก
โ”‚   โ”œโ”€โ”€ templates/             # HTMLๆจกๆฟ
โ”‚   โ”‚   โ””โ”€โ”€ index.html         # ไธป้กต้ข
โ”‚   โ””โ”€โ”€ static/                # ้™ๆ€่ต„ๆบ
โ”‚       โ”œโ”€โ”€ style.css          # ๆ ทๅผๆ–‡ไปถ
โ”‚       โ””โ”€โ”€ script.js          # ๅ‰็ซฏ่„šๆœฌ
โ”œโ”€โ”€ tests/                     # ๆต‹่ฏ•ๆ–‡ไปถ
โ”‚   โ”œโ”€โ”€ test_core.py           # ๆ ธๅฟƒๆจกๅ—ๆต‹่ฏ•
โ”‚   โ”œโ”€โ”€ test_protocol.py       # ๅ่ฎฎๆต‹่ฏ•
โ”‚   โ”œโ”€โ”€ test_end_to_end.py     # ็ซฏๅˆฐ็ซฏๆต‹่ฏ•
โ”‚   โ”œโ”€โ”€ test_ml_comparison.py  # ๆœบๅ™จๅญฆไน ๅฏนๆฏ”ๆต‹่ฏ•
โ”‚   โ””โ”€โ”€ test_real_vertical_fl.py # ๅž‚็›ด่”้‚ฆๅญฆไน ๅœบๆ™ฏๆต‹่ฏ•
โ”œโ”€โ”€ develop.md                 # ๅผ€ๅ‘ๆ–‡ๆกฃ
โ””โ”€โ”€ README.md                  # ้กน็›ฎ่ฏดๆ˜Ž

ๅฟซ้€Ÿๅผ€ๅง‹

็Žฏๅขƒ่ฆๆฑ‚

  • Python 3.8+
  • TensorFlow (ๅฏ้€‰๏ผŒ็”จไบŽCNNๆต‹่ฏ•)
  • scikit-learn
  • numpy

ๅฎ‰่ฃ…ไพ่ต–

cd peafowl-python
pip install -r requirements.txt

ไฝฟ็”จไธ€้”ฎๅฏๅŠจ่„šๆœฌ๏ผˆๆŽจ่๏ผ‰

้กน็›ฎๆไพ›ไบ† start.sh ่„šๆœฌ๏ผŒ่‡ชๅŠจๅฎŒๆˆ็Žฏๅขƒๅˆๅง‹ๅŒ–ใ€ไพ่ต–ๅฎ‰่ฃ…ใ€ๆต‹่ฏ•่ฟ่กŒๅ’Œ WebApp ๅฏๅŠจ๏ผš

chmod +x start.sh
./start.sh

่„šๆœฌๅŠŸ่ƒฝ๏ผš

  1. ๆฃ€ๆต‹ๅนถๅˆ›ๅปบ .venv ่™šๆ‹Ÿ็Žฏๅขƒ
  2. ไฝฟ็”จๆธ…ๅŽๆบๅฎ‰่ฃ… requirements.txt ไธญ็š„ไพ่ต–
  3. ่ฟ่กŒๆ‰€ๆœ‰ๅ•ๅ…ƒๆต‹่ฏ•
  4. ๆต‹่ฏ•้€š่ฟ‡ๅŽ่‡ชๅŠจๅฏๅŠจ WebApp ๆœๅŠก

ๆฟ€ๆดป็Žฏๅขƒ

source .venv/bin/activate

่ฟ่กŒๆต‹่ฏ•

# ่ฟ่กŒๆ‰€ๆœ‰ๅ•ๅ…ƒๆต‹่ฏ•
python -m pytest tests/ -v

# ่ฟ่กŒๅž‚็›ด่”้‚ฆๅญฆไน ๅœบๆ™ฏๆต‹่ฏ•
python tests/test_real_vertical_fl.py

# ่ฟ่กŒๆœบๅ™จๅญฆไน ๅฏนๆฏ”ๆต‹่ฏ•
python tests/test_ml_comparison.py

Webๅฏ่ง†ๅŒ–ๅบ”็”จ

PEAFOWL ๆไพ›ไบ†ไธ€ไธชไบคไบ’ๅผ Web ๅบ”็”จ๏ผŒ็”จไบŽๅฏ่ง†ๅŒ–ๅฑ•็คบๅ่ฎฎๆต็จ‹ๅ’Œ่ฎญ็ปƒ็ป“ๆžœใ€‚

ๅฏๅŠจๆœๅŠก
cd peafowl-python/webapp
python app.py

ๆœๅŠกๅฏๅŠจๅŽ๏ผŒ่ฎฟ้—ฎ http://localhost:5000 ๅณๅฏไฝฟ็”จใ€‚

ๅŠŸ่ƒฝๆจกๅ—
ๆจกๅ— ่ฏดๆ˜Ž
้กน็›ฎๆฆ‚่งˆ PEAFOWL ้กน็›ฎไป‹็ปใ€ๆ ธๅฟƒ็‰นๆ€งใ€ๆŠ€ๆœฏๅŽŸ็†
ๅ่ฎฎๆผ”็คบ ้…็ฝฎๅ‚ไธŽๆ–นๆ•ฐ้‡๏ผŒ่ฟ่กŒ PEAFOWL ๅ่ฎฎๅนถๆŸฅ็œ‹ๅฎžๆ—ถๆต็จ‹ๅฏ่ง†ๅŒ–
ๅฏ†็ ๅญฆๅŽŸ็† ๅฑ•็คบๅŠ ๆณ•็ง˜ๅฏ†ๅ…ฑไบซใ€PRFใ€SHPRGใ€็ฝฎๆขๅ…ฑไบซ็ญ‰ๅฏ†็ ๅญฆๅŽŸ่ฏญ็š„ๅŽŸ็†ๅ’Œ็คบไพ‹
ๅˆ†ๆญฅๆต็จ‹ ่ฏฆ็ป†ๅฑ•็คบ PEAFOWL ๅ่ฎฎ็š„ 7 ไธช้˜ถๆฎต๏ผˆๆ•ฐๆฎๅ‡†ๅค‡ใ€IDๅŠ ๅฏ†ใ€ไบค้›†่ฎก็ฎ—ใ€็‰นๅพๅฏน้ฝใ€็ง˜ๅฏ†ๅ…ฑไบซใ€็‰นๅพๆททๆท†ใ€็ป“ๆžœ่พ“ๅ‡บ๏ผ‰
MNIST่ฎญ็ปƒ ไฝฟ็”จ็œŸๅฎž MNIST ๆ‰‹ๅ†™ๆ•ฐๅญ—ๆ•ฐๆฎ้›†่ฟ›่กŒๅž‚็›ด่”้‚ฆๅญฆไน ่ฎญ็ปƒ๏ผŒๆ”ฏๆŒ CNN ๅ’Œ Logistic Regression ๆจกๅž‹
MNIST่ฎญ็ปƒๅŠŸ่ƒฝ
  • ๆ”ฏๆŒ้€‰ๆ‹ฉๅ‚ไธŽๆ–นๆ•ฐ้‡๏ผˆ2-10ไธช๏ผ‰
  • ๆ”ฏๆŒ้€‰ๆ‹ฉๆจกๅž‹็ฑปๅž‹๏ผšCNN๏ผˆๅท็งฏ็ฅž็ป็ฝ‘็ปœ๏ผ‰ๆˆ– Logistic Regression
  • ๅฑ•็คบๆ•ฐๆฎๅฏน้ฝไฟกๆฏใ€ๆจกๅž‹่ฎญ็ปƒ็ป“ๆžœ
  • ๅฏ่ง†ๅŒ–ๅฑ•็คบ๏ผšๆญฃ็กฎๅˆ†็ฑปๅ’Œ้”™่ฏฏๅˆ†็ฑป็š„ๆ‰‹ๅ†™ๆ•ฐๅญ—ๆ ทๆœฌ๏ผŒๆ˜พ็คบ็œŸๅฎžๆ ‡็ญพใ€้ข„ๆต‹ๆ ‡็ญพๅ’Œ็ฝฎไฟกๅบฆ
APIๆŽฅๅฃ
ๆŽฅๅฃ ๆ–นๆณ• ่ฏดๆ˜Ž
/api/generate_data POST ็”Ÿๆˆ MNIST ๅž‚็›ด่”้‚ฆๅญฆไน ๆ•ฐๆฎๅนถ่ฟ่กŒๅ่ฎฎ
/api/step_by_step POST ๅˆ†ๆญฅๅฑ•็คบๅ่ฎฎๆต็จ‹
/api/cryptography_details POST ่Žทๅ–ๅฏ†็ ๅญฆๅŽŸ่ฏญ่ฏฆๆƒ…
/api/train_mnist POST ่ฟ่กŒ MNIST ่ฎญ็ปƒ๏ผˆๆ”ฏๆŒ CNN๏ผ‰

ไฝฟ็”จ็คบไพ‹

from protocol.peafowl import PEAFOWL
from party.data_provider import DataProvider
from party.server import Server

# ้…็ฝฎ
config = {
    'num_parties': 3,
    'num_samples': 1000,
    'num_features': 100,
    'secret_modulus': 2**64,
    'precision_bits': 16,
}

# ๅˆ›ๅปบๆ•ฐๆฎๆไพ›ๆ–น
data_providers = []
for i in range(num_parties):
    dp = DataProvider(f"P{i}", config, sample_ids[i], features[i])
    dp.prf_key = b'0' * 16
    data_providers.append(dp)

# ๅˆ›ๅปบๆœๅŠกๅ™จ
server = Server("S", config)

# ่ฟ่กŒPEAFOWLๅ่ฎฎ
peafowl = PEAFOWL(config)
aligned_features = peafowl.run_protocol(data_providers, server)

# ไฝฟ็”จๅฏน้ฝๅŽ็š„็‰นๅพ่ฟ›่กŒ่ฎญ็ปƒ
# ...

ๆต‹่ฏ•็ป“ๆžœ

ๅž‚็›ด่”้‚ฆๅญฆไน ๅœบๆ™ฏๆต‹่ฏ•

ๅ‚ไธŽๆ–นๆ•ฐ ๆ ทๆœฌๆ•ฐ ็‰นๅพๆ•ฐ ๅฏน้ฝๅŽๆ ทๆœฌๆ•ฐ ้€ป่พ‘ๅ›žๅฝ’ๅ‡†็กฎ็އ CNNๅ‡†็กฎ็އ
2 [400, 350] [150, 140] 280 80.36% 73.21%
3 [400, 350, 300] [150, 140, 130] 188 65.79% 60.53%
4 [400, 350, 300, 250] [150, 140, 130, 120] 106 63.64% 54.55%

ๆ ธๅฟƒๆจกๅ—่ฏดๆ˜Ž

1. ็ง˜ๅฏ†ๅ…ฑไบซ (Secret Sharing)

ไฝฟ็”จๅŠ ๆณ•็ง˜ๅฏ†ๅ…ฑไบซๅฐ†ๆ•ฐๆฎๆ‹†ๅˆ†ไธบๅคšไธชไปฝ้ข๏ผŒๅชๆœ‰ๆ‰€ๆœ‰ไปฝ้ข็›ธๅŠ ๆ‰่ƒฝๆขๅคๅŽŸๅง‹ๆ•ฐๆฎใ€‚

from core.secret_sharing import share, reconstruct

# ๅˆ†ไบซ
shares = share(secret=42, n=3, modulus=2**64)

# ้‡ๅปบ
reconstructed = reconstruct(shares, modulus=2**64)

2. ไผช้šๆœบๅ‡ฝๆ•ฐ (PRF)

ๅŸบไบŽHMAC-SHA256ๅฎž็Žฐ๏ผŒ็”จไบŽๅฎ‰ๅ…จๅœฐๅŠ ๅฏ†ๆ ทๆœฌIDใ€‚

from core.prf import PRF

prf = PRF(key=b'0' * 16)
encrypted = prf.eval(b'sample_id')

3. ๅฏ†้’ฅๅŒๆ€ไผช้šๆœบ็”Ÿๆˆๅ™จ (SHPRG)

ๅŸบไบŽLWR๏ผˆLearning With Errors๏ผ‰้—ฎ้ข˜ๅฎž็Žฐ๏ผŒๆ”ฏๆŒๅฏ†้’ฅๅŒๆ€่ฟ็ฎ—ใ€‚

from core.shprg import SHPRG

shprg = SHPRG(d=8, m=1024, q=2**128, p=2**64)
output = shprg.generate(seed=[1, 2, 3, 4, 5, 6, 7, 8])

่ฎธๅฏ่ฏ

ๆœฌ้กน็›ฎไป…็”จไบŽๅญฆๆœฏ็ ”็ฉถๅ’Œๆ•™ๅญฆ็›ฎ็š„ใ€‚

English

PEAFOWL is a privacy-preserving entity alignment protocol framework designed for vertical federated learning. It allows different data parties to securely find common samples (intersection) without exposing their respective data, and jointly train machine learning models based on the aligned data.

Key Features

  • Privacy Preservation: Uses cryptographic techniques including additive secret sharing, pseudo-random functions, and key-homomorphic pseudo-random generators to protect intersection information
  • Efficient Protocol: Linear complexity O(n) for communication and computation, suitable for large-scale datasets
  • Multi-Party Support: Supports entity alignment with multiple data parties
  • Flexible Models: Supports various machine learning models including logistic regression, CNN, SVM, etc.

Technical Principles

The core idea of the PEAFOWL protocol is to achieve secure alignment through permutation and secret sharing:

  1. Entity Alignment: Each party encrypts their sample IDs and sends them to the server, which computes the intersection size without knowing the specific intersection IDs
  2. Feature Combination: Based on the intersection samples, parties combine their features using the PEAFOWL protocol
  3. Secure Computation: Features are obfuscated through secret sharing and SHPRG (Key-Homomorphic Pseudo-Random Generator) to ensure the server cannot access raw data

Project Structure

peafowl-python/
โ”œโ”€โ”€ core/                      # Core cryptographic primitives
โ”‚   โ”œโ”€โ”€ secret_sharing.py      # Additive secret sharing
โ”‚   โ”œโ”€โ”€ prf.py                 # Pseudo-random function (based on HMAC-SHA256)
โ”‚   โ”œโ”€โ”€ shprg.py               # Key-homomorphic PRG (based on LWR)
โ”‚   โ”œโ”€โ”€ ot.py                  # Oblivious transfer extension
โ”‚   โ””โ”€โ”€ polynomial.py          # Polynomial operations (Lagrange interpolation)
โ”œโ”€โ”€ protocol/                  # PEAFOWL protocol implementation
โ”‚   โ”œโ”€โ”€ przs.py                # Pseudo-random zero sharing
โ”‚   โ””โ”€โ”€ peafowl.py             # Main protocol
โ”œโ”€โ”€ party/                     # Party implementations
โ”‚   โ”œโ”€โ”€ data_provider.py       # Data provider party
โ”‚   โ””โ”€โ”€ server.py              # Cloud server
โ”œโ”€โ”€ network/                   # Network simulation
โ”‚   โ””โ”€โ”€ channel.py             # Communication channel
โ”œโ”€โ”€ utils/                     # Utility functions
โ”‚   โ””โ”€โ”€ data_loader.py         # Data loading
โ”œโ”€โ”€ webapp/                    # Web visualization application
โ”‚   โ”œโ”€โ”€ app.py                 # Flask backend service
โ”‚   โ”œโ”€โ”€ templates/             # HTML templates
โ”‚   โ”‚   โ””โ”€โ”€ index.html         # Main page
โ”‚   โ””โ”€โ”€ static/                # Static resources
โ”‚       โ”œโ”€โ”€ style.css          # Stylesheet
โ”‚       โ””โ”€โ”€ script.js          # Frontend script
โ”œโ”€โ”€ tests/                     # Test files
โ”‚   โ”œโ”€โ”€ test_core.py           # Core module tests
โ”‚   โ”œโ”€โ”€ test_protocol.py       # Protocol tests
โ”‚   โ”œโ”€โ”€ test_end_to_end.py     # End-to-end tests
โ”‚   โ”œโ”€โ”€ test_ml_comparison.py  # ML comparison tests
โ”‚   โ””โ”€โ”€ test_real_vertical_fl.py # Real vertical FL scenario tests
โ”œโ”€โ”€ develop.md                 # Development documentation
โ””โ”€โ”€ README.md                  # Project README

Quick Start

Requirements

  • Python 3.8+
  • TensorFlow (optional, for CNN testing)
  • scikit-learn
  • numpy

Installation

cd peafowl-python
pip install -r requirements.txt

Using One-Click Start Script (Recommended)

The project provides start.sh script to automatically complete environment initialization, dependency installation, test running, and WebApp startup:

chmod +x start.sh
./start.sh

Script features:

  1. Detects and creates .venv virtual environment
  2. Installs dependencies from requirements.txt using Tsinghua mirror
  3. Runs all unit tests
  4. Automatically starts WebApp service after tests pass

Running Tests

# Run all unit tests
python -m pytest tests/ -v

# Run vertical federated learning scenario tests
python tests/test_real_vertical_fl.py

# Run ML comparison tests
python tests/test_ml_comparison.py

Web Visualization Application

PEAFOWL provides an interactive web application for visualizing protocol workflows and training results.

Starting the Service
cd peafowl-python/webapp
python app.py

After the service starts, visit http://localhost:5000 to use the application.

Feature Modules
Module Description
Overview PEAFOWL project introduction, core features, technical principles
Protocol Demo Configure number of parties, run PEAFOWL protocol with real-time visualization
Cryptography Demonstrate cryptographic primitives including additive secret sharing, PRF, SHPRG, permutation sharing
Step-by-Step Detailed 7-stage protocol walkthrough (Data Preparation, ID Encryption, Intersection Computation, Feature Alignment, Secret Sharing, Feature Obfuscation, Result Output)
MNIST Training Train vertical federated learning models on real MNIST handwritten digit dataset, supports CNN and Logistic Regression
MNIST Training Features
  • Configurable number of parties (2-10)
  • Model selection: CNN (Convolutional Neural Network) or Logistic Regression
  • Display data alignment info and model training results
  • Visualization: Correctly and incorrectly classified handwritten digit samples with true labels, predicted labels, and confidence scores
API Endpoints
Endpoint Method Description
/api/generate_data POST Generate MNIST vertical FL data and run protocol
/api/step_by_step POST Step-by-step protocol demonstration
/api/cryptography_details POST Get cryptographic primitive details
/api/train_mnist POST Run MNIST training (supports CNN)

Usage Example

from protocol.peafowl import PEAFOWL
from party.data_provider import DataProvider
from party.server import Server

# Configuration
config = {
    'num_parties': 3,
    'num_samples': 1000,
    'num_features': 100,
    'secret_modulus': 2**64,
    'precision_bits': 16,
}

# Create data providers
data_providers = []
for i in range(num_parties):
    dp = DataProvider(f"P{i}", config, sample_ids[i], features[i])
    dp.prf_key = b'0' * 16
    data_providers.append(dp)

# Create server
server = Server("S", config)

# Run PEAFOWL protocol
peafowl = PEAFOWL(config)
aligned_features = peafowl.run_protocol(data_providers, server)

# Train model with aligned features
# ...

Test Results

Vertical Federated Learning Scenario Tests

Parties Samples Features Aligned Samples LR Accuracy CNN Accuracy
2 [400, 350] [150, 140] 280 80.36% 73.21%
3 [400, 350, 300] [150, 140, 130] 188 65.79% 60.53%
4 [400, 350, 300, 250] [150, 140, 130, 120] 106 63.64% 54.55%

Core Modules

1. Secret Sharing

Additive secret sharing splits data into multiple shares, where all shares must be combined to reconstruct the original data.

from core.secret_sharing import share, reconstruct

# Share
shares = share(secret=42, n=3, modulus=2**64)

# Reconstruct
reconstructed = reconstruct(shares, modulus=2**64)

2. Pseudo-Random Function (PRF)

Based on HMAC-SHA256, used for securely encrypting sample IDs.

from core.prf import PRF

prf = PRF(key=b'0' * 16)
encrypted = prf.eval(b'sample_id')

3. Key-Homomorphic Pseudo-Random Generator (SHPRG)

Based on the LWR (Learning With Errors) problem, supporting key-homomorphic operations.

from core.shprg import SHPRG

shprg = SHPRG(d=8, m=1024, q=2**128, p=2**64)
output = shprg.generate(seed=[1, 2, 3, 4, 5, 6, 7, 8])

License

This project is for academic research and educational purposes only.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages