Deanonymizer
A library aiding to create attacks against anonymizers (privacy preserving machine learning models) for the AnoMed competition platform. Currently, only membership inference attacks are supported.
Usage Example
The following example will create a Falcon-based web app that encapsulates a deanonymizer, targeting the example anonymizer defined in the anomed-anonyimzer README.md (which is a privacy preserving classifier for the famous iris dataset classification problem). The encapsulated deanonymizer is a membership inference black box attack, implemented using the Adversarial Robustness Toolbox (ART library).
The web app offers these routes (some may have query parameters not mentioned here):
- [GET] / (This displays an "alive message".)
- [POST] /fit (This invokes fitting the Gaussian naive based classifier; the web app will pull the training data from training_data_url.)
- [POST] /evaluate (This invokes an intermediate, or final evaluation of the classifier.)
import anomed_deanonymizer
import numpy as np
from art.attacks.inference.membership_inference import MembershipInferenceBlackBox
def validate_input_array(feature_array: np.ndarray) -> None:
if feature_array.shape[1] != 4 or len(feature_array.shape) != 2:
raise ValueError("Feature array needs to have shape (n_samples, 4).")
if feature_array.dtype != np.float_:
raise ValueError("Feature array must be an array of floats.")
attack_target_hostname = "example-anonymizer"
attack_target = anomed_deanonymizer.WebClassifier(
url=f"http://{attack_target_hostname}/predict", input_shape=(4,), nb_classes=3
)
example_attack_art = MembershipInferenceBlackBox(
estimator=attack_target, # type: ignore
attack_model_type="rf",
)
example_attack = anomed_deanonymizer.ARTWrapper(
art_mia=example_attack_art, input_validator=validate_input_array
)
challenge_hostname = "example.com"
application = anomed_deanonymizer.supervised_learning_MIA_server_factory(
anonymizer_identifier="example_anonymizer",
deanonymizer_identifier="example_deanonymizer",
deanonymizer_obj=example_attack,
model_filepath="deanonymizer.pkl",
default_batch_size=64,
member_url=f"http://{challenge_hostname}/data/deanonymizer/members",
nonmember_url=f"http://{challenge_hostname}/data/deanonymizer/non-members",
evaluation_data_url=f"http://{challenge_hostname}/data/attack-success-evaluation",
model_loader=anomed_deanonymizer.unpickle_deanonymizer,
utility_evaluation_url=f"http://{challenge_hostname}/utility/deanonymizer",
)
Metadata
Release files for anomed-deanonymizer 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| anomed_deanonymizer-0.0.11.tar.gz | 13.1 kB | With provenance | Details for anomed_deanonymizer-0.0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anomed_deanonymizer-0.0.11-py3-none-any.whl | Python 3 | none | any | Details for anomed_deanonymizer-0.0.11-py3-none-any.whl |
Total release size: 24.2 kB
Release files / anomed_deanonymizer-0.0.11.tar.gz
| Download URL | anomed_deanonymizer-0.0.11.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95b71564a6336eb73957b4ba220102b06abc8ba8c2c3cae5953b0bb3eb13084d
|
|
BLAKE2b-256 checksum How to use checksums |
2579b500aa955e4816dbc0688592896fcd80991ff299767a04627adfb26805cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 6, 2025.
Transparency logRelease files / anomed_deanonymizer-0.0.11-py3-none-any.whl
| Download URL | anomed_deanonymizer-0.0.11-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
732649b1b899e4fcdd8e097793b8db3aeed4654fef684af7ea0f743b539dbdc1
|
|
BLAKE2b-256 checksum How to use checksums |
3217c86761e99a70f831697bbc0cafa7d0158fa41d70aa2616cb3d6619623371
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 6, 2025.
Transparency logSecurity for anomed-deanonymizer 0.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for anomed_deanonymizer-0.0.11.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 6, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.