abdm-ecdh
Python library implementing the ABDM (Ayushman Bharat Digital Mission) ECDH encryption protocol for secure health data exchange.
Installation
pip install abdm-ecdh==1.0.0
Usage
from abdm_ecdh import generate_key_material, encrypt, decrypt
# Each party generates their own key material
sender = generate_key_material()
requester = generate_key_material()
# Sender encrypts
enc = encrypt(
string_to_encrypt="sensitive health data",
sender_nonce=sender.nonce,
requester_nonce=requester.nonce,
sender_private_key=sender.private_key,
requester_public_key=requester.x509_public_key,
)
# Requester decrypts
dec = decrypt(
encrypted_data=enc.encrypted_data,
sender_nonce=sender.nonce,
requester_nonce=requester.nonce,
requester_private_key=requester.private_key,
sender_public_key=sender.x509_public_key,
)
print(dec.decrypted_data) # "sensitive health data"
API
generate_key_material() -> KeyMaterial
Generates an ECDH key pair on Curve25519 (Weierstrass form) and a random 32-byte nonce.
Returns a KeyMaterial dataclass with fields:
private_key— base64-encoded private scalarpublic_key— base64-encoded uncompressed EC point (65 bytes)x509_public_key— base64-encoded X.509 SubjectPublicKeyInfo DERnonce— base64-encoded 32-byte random nonce
encrypt(...) -> EncryptionResponse
Encrypts a plaintext string using ECDH shared secret derivation + HKDF-SHA256 + AES-256-GCM.
Parameters: string_to_encrypt, sender_nonce, requester_nonce, sender_private_key, requester_public_key
Returns EncryptionResponse with encrypted_data (base64 string).
decrypt(...) -> DecryptionResponse
Decrypts ciphertext using ECDH shared secret derivation + HKDF-SHA256 + AES-256-GCM.
Parameters: encrypted_data, sender_nonce, requester_nonce, requester_private_key, sender_public_key
Returns DecryptionResponse with decrypted_data (string).
Cryptographic Details
- Key Agreement: ECDH on Curve25519 (Weierstrass form), compatible with Java/BouncyCastle
- Key Derivation: HKDF-SHA256
- Encryption: AES-256-GCM
- Nonce Handling: IV and salt derived from XOR of sender and requester nonces
License
MIT
Metadata
Release files for abdm-ecdh 1.1.0
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 |
|---|---|---|---|---|
| abdm_ecdh-1.1.0.tar.gz | 6.5 kB | Without provenance | Details for abdm_ecdh-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| abdm_ecdh-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for abdm_ecdh-1.1.0-py3-none-any.whl |
Total release size: 13.7 kB
Release files / abdm_ecdh-1.1.0.tar.gz
| Download URL | abdm_ecdh-1.1.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f47152dc35bfa6472618899094a1c0171ec12e5e2024c0e2f9a58e6b724c2bdf
|
|
BLAKE2b-256 checksum How to use checksums |
51268d0ae966f8e61879e8f202820343089f6e87c484670a005d278731e1f83a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.5 cpython/3.11.15 HTTPX/0.28.1
|
Release files / abdm_ecdh-1.1.0-py3-none-any.whl
| Download URL | abdm_ecdh-1.1.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fb003ffd168d33f23bc801d67b21b41d5d59473f48168641783a9389518a8a9
|
|
BLAKE2b-256 checksum How to use checksums |
0f5140dc9bd2c17939e0fe4979b894f069e4dbf90092eb749b1844fc0d04a1ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.5 cpython/3.11.15 HTTPX/0.28.1
|
Security for abdm-ecdh 1.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.