tno.mpc.protocols.kaplan-meier

TNO PET Lab - secure Multi-Party Computation (MPC) - Protocols - Kaplan-Meier

https://github.com/tno-mpc/protocols.kaplan_meier

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.7%) to scientific vocabulary

Keywords

homomorphic-encryption kaplan-meier log-rank-test mpc mpc-lab multi-party-computation paillier paillier-cryptosystem pet-lab secret-sharing survival-analysis tno
Last synced: 6 months ago · JSON representation ·

Repository

TNO PET Lab - secure Multi-Party Computation (MPC) - Protocols - Kaplan-Meier

Basic Info
Statistics
  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
homomorphic-encryption kaplan-meier log-rank-test mpc mpc-lab multi-party-computation paillier paillier-cryptosystem pet-lab secret-sharing survival-analysis tno
Created almost 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme License Citation

README.md

TNO PET Lab - secure Multi-Party Computation (MPC) - Protocols - Kaplan Meier

An implementation of the Kaplan-Meier Estimator. Details about the protocol can be found here: CONVINCED -- Enabling privacy-preserving survival analyses using Multi-Party Computation.

PET Lab

The TNO PET Lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of PET solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed PET functionalities to boost the development of new protocols and solutions.

The package tno.mpc.protocols.kaplan_meier is part of the TNO Python Toolbox.

Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.
This implementation of cryptographic software has not been audited. Use at your own risk.

Documentation

Documentation of the tno.mpc.protocols.kaplan_meier package can be found here.

Install

Easily install the tno.mpc.protocols.kaplan_meier package using pip:

console $ python -m pip install tno.mpc.protocols.kaplan_meier

Note: If you are cloning the repository and wish to edit the source code, be sure to install the package in editable mode:

console $ python -m pip install -e 'tno.mpc.protocols.kaplan_meier'

If you wish to run the tests you can use:

console $ python -m pip install 'tno.mpc.protocols.kaplan_meier[tests]' Note: A significant performance improvement can be achieved by installing the GMPY2 library.

console $ python -m pip install 'tno.mpc.protocols.kaplan_meier[gmpy]'

Protocol description

A more elaborate protocol description can be found in CONVINCED -- Enabling privacy-preserving survival analyses using Multi-Party Computation. In ERCIM News 126 (July 2021), we presented some extra context.

Kaplan-Meier High Level Overview
**Figure 1.** _The protocol to securely compute the log-rank statistic for vertically-partitioned data. One party (Blue) owns data on patient groups, the other party (Orange) owns data on event times (did the patient experience an event ‘1’ or not ‘0’, and when did this occur). Protocol outline: Blue encrypts its data using additive homomorphic encryption and the encrypted data is sent to Orange. Orange is able to securely, without decryption, split its data in the patient groups specified by Blue (1) using the additive homomorphic properties of the encryptions. Orange performs some preparatory, local, computations (2) and with the help of Blue secret-shares the data (3) between Blue, Orange and Purple, where Purple is introduced for efficiency purposes. All parties together securely compute the log-rank statistic associated with the (never revealed) Kaplan-Meier curves (4) and only reveal the final statistical result (5)._

Usage

The protocol is asymmetric. To run the protocol you need to run three separate instances.

scripts/example_usage.py

```py """ Example usage for performing Kaplan-Meier analysis Run three separate instances e.g., $ python ./scripts/exampleusage.py -M3 -I0 -p alice $ python ./scripts/exampleusage.py -M3 -I1 -p bob $ python ./scripts/example_usage.py -M3 -I2 -p helper All but the last argument are passed to MPyC. """

from future import annotations

import argparse import asyncio from enum import Enum

import lifelines import pandas as pd

from tno.mpc.communication import Pool from tno.mpc.protocols.kaplan_meier import Alice, Bob, Helper

class KnownPlayers(Enum): ALICE = "alice" BOB = "bob" HELPER = "helper"

def parseargs() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.addargument( "-p", "--player", help="Name of the sending player", type=str, required=True, choices=list(p.value.lower() for p in KnownPlayers), ) args = parser.parse_args() return args

async def main(playerinstance: Alice | Bob | Helper) -> None: await playerinstance.run_protocol()

if name == "main": # Parse arguments and acquire configuration parameters args = parseargs() player = KnownPlayers(args.player) playerconfig: dict[KnownPlayers, dict[str, str]] = { KnownPlayers.ALICE: {"address": "127.0.0.1", "port": "8080"}, KnownPlayers.BOB: {"address": "127.0.0.1", "port": "8081"}, }

test_data = pd.DataFrame(  # type: ignore[attr-defined]
    {
        "time": [3, 5, 6, 8, 10, 14, 14, 18, 20, 22, 30, 30],
        "event": [1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1],
        "Group A": [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
        "Group B": [0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1],
        "Group C": [0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0],
    }
)

player_instance: Alice | Bob | Helper
if player in player_config.keys():
    pool = Pool()
    pool.add_http_server(port=int(player_config[player]["port"]))

    for player_, config in player_config.items():
        if player_ is player:
            continue
        pool.add_http_client(
            player_.value,
            config["address"],
            port=int(config["port"]) if "port" in config else 80,
        )  # default port=80
    if player is KnownPlayers.ALICE:
        event_times = test_data[["time", "event"]]
        player_instance = Alice(
            identifier=player.value,
            data=event_times,
            pool=pool,
        )
    elif player is KnownPlayers.BOB:
        groups = test_data[["Group A", "Group B", "Group C"]]
        player_instance = Bob(
            identifier=player.value,
            data=groups,
            pool=pool,
        )
elif player is KnownPlayers.HELPER:
    player_instance = Helper(player.value)

loop = asyncio.get_event_loop()
loop.run_until_complete(main(player_instance))

print("-" * 32)
print(player_instance.statistic)
print("-" * 32)

# Validate results
event_times = test_data[["time", "event"]]
groups = (
    test_data["Group B"].to_numpy() + 2 * test_data["Group C"].to_numpy()
)  # convert from binary to categorical
print(
    lifelines.statistics.multivariate_logrank_test(
        event_times["time"],
        groups,
        event_times["event"],
    )
)
print("-" * 32)

```

Owner

  • Name: TNO - MPC Lab
  • Login: TNO-MPC
  • Kind: organization
  • Email: mpclab@tno.nl
  • Location: Anna van Buerenplein 1, 2595 DA Den Haag, The Netherlands

TNO - MPC Lab

Citation (CITATION.cff)

cff-version: 1.2.0
license: Apache-2.0
message: If you use this software, please cite it using these metadata.
authors:
  - name: TNO PET Lab
    city: The Hague
    country: NL
    email: petlab@tno.nl
    website: https://pet.tno.nl
type: software
url: https://pet.tno.nl
contact:
  - name: TNO PET Lab
    city: The Hague
    country: NL
    email: petlab@tno.nl
    website: https://pet.tno.nl
repository-code: https://github.com/TNO-MPC/protocols.kaplan_meier
repository-artifact: https://pypi.org/project/tno.mpc.protocols.kaplan_meier
title: TNO PET Lab - secure Multi-Party Computation (MPC) - Protocols - Kaplan Meier
version: 1.0.4
date-released: 2024-11-29

GitHub Events

Total
Last Year

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 5
  • Total Committers: 1
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Thomas Rooijakkers t****s@t****l 5
Committer Domains (Top 20 + Academic)
tno.nl: 1

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 2
  • Total pull requests: 0
  • Average time to close issues: 4 days
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 3.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • frankcorneliusmartin (2)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 56 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
pypi.org: tno.mpc.protocols.kaplan-meier

Kaplan Meier using Paillier homomorphic encryption and a helper party

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 56 Last month
Rankings
Dependent packages count: 6.6%
Forks count: 30.5%
Dependent repos count: 30.6%
Stargazers count: 32.3%
Average: 33.6%
Downloads: 67.8%
Maintainers (1)
Last synced: 7 months ago

Dependencies

pyproject.toml pypi
  • lifelines ~=0.27
  • mpyc ~=0.7
  • numpy >=1.24,<2
  • pandas *
  • scipy *
  • tno.mpc.communication ~=4.0,!=4.4.2
  • tno.mpc.encryption_schemes.paillier ~=3.0
  • tno.mpc.encryption_schemes.utils ~=0.6
  • tno.mpc.mpyc.matrix_inverse ~=0.4