Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于单服务器PIR匿踪查询的疑问 #1266

Open
coderSun20201112 opened this issue Apr 24, 2024 · 2 comments
Open

关于单服务器PIR匿踪查询的疑问 #1266

coderSun20201112 opened this issue Apr 24, 2024 · 2 comments
Assignees

Comments

@coderSun20201112
Copy link

Issue Type

Others

Source

source

Secretflow Version

1.5.0.dev240319

OS Platform and Distribution

centos 7.9

Python version

3.10

Bazel version

6.5.0

GCC/Compiler version

11.2.1

What happend and What you expected to happen.

在匿踪查询中,提及隐语都是基于单服务器的PIR,那我在部署工程的时候,就只能部署到一台服务器上,无法多服务器提供PIR服务吗?

Reproduction code to reproduce the issue.

@Chrisdehe
Copy link
Member

可以的,在sf调用下通过对仿真/生产模式的机器的ip分配可以配置最多两个参与方任务运行

@Chrisdehe
Copy link
Member

例如setup:

import os
import sys
import time
import logging
import multiprocess
from absl import app
import spu
import secretflow as sf
#import random
# init log
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

cluster_config ={
    'parties': {
        'alice': {
            'address': 'ip:9567',
            'listen_addr': '0.0.0.0:9567'
        },
        'bob': {
            'address': 'ip:9568',     
            'listen_addr': '0.0.0.0:9568'
        },
    },
    'self_party': 'bob'
}


# SPU settings
cluster_def = {
    'nodes': [
        {'party': 'alice', 'id': 'local:0', 'address': 'ip:9594'},
        {'party': 'bob', 'id': 'local:1', 'address': 'ip:9595'},
    ],
    'runtime_config': {
        'protocol': spu.spu_pb2.SEMI2K,
        'field': spu.spu_pb2.FM128,
    },
}

link_desc = {
    'recv_timeout_ms': 3600000,
}

def main(_):
    # sf init
    # <<< !!! >>> replace <192.168.0.1:9394> to your ray head

    sf.init(address='ip:9395', log_to_driver=True, cluster_config=cluster_config, omp_num_threads=multiprocess.cpu_count())

    # init log
    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

    alice = sf.PYU('alice')
    bob = sf.PYU('bob')

    # <<< !!! >>> replace path to real parties local file path.
    key_columns =  ['姓名','证件类型','证件号码'] 
    label_columns = ['银行卡号','性别','年龄','住址','职业','薪资','账户余额','授信额度','已用额度','授信限额','生效日期','到期日期','相关还款责任金额','逾期月数']
    spu = sf.SPU(cluster_def, link_desc)

    parent_path = '/root/JDXK/pir'
    pir_input_path = f'{parent_path}/B行.csv'
    pir_oprf_key_path = f'{parent_path}/oprf_key.bin'
    pir_setup_path = f'{parent_path}/setup_path_B'

    start = time.time()

    reports = spu.pir_setup(
        server='bob',
        input_path=pir_input_path,
        key_columns=key_columns,
        label_columns=label_columns,
        oprf_key_path=pir_oprf_key_path,
        setup_path=pir_setup_path,
        num_per_query=100,
        label_max_len=150,
    )

    #print(f"psi reports: {reports}")
    logging.info(f"offline psi reports: {reports}")
    logging.info(f"cost time: {time.time() - start}")

    sf.shutdown()

if __name__ == '__main__':
    app.run(main)

@Chrisdehe Chrisdehe self-assigned this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants