Skip to main content

pamoja-security

ed25519 device identity: sign a reading and verify it, so a gateway can prove it is authentic. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.

read the guide documentation API reference

Install

pip install pamoja-security
from pamoja import security

This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.

Example

The script the test suite runs, spliced here as it ran.

From bindings/python/guides/security.py:

from pamoja.security import DeviceIdentity, fingerprint, verify

# The seed is provisioned into the device once and never leaves it. A real one comes from
# the factory or a secure element; any 32 bytes stand in here.
device = DeviceIdentity.from_seed(bytes([7]) * 32)

# Only the 32-byte public key travels to the gateway. Its fingerprint is the short form an
# operator reads off a screen to tell one device from another.
gateway_key = device.public_key
print(f"device     {fingerprint(gateway_key)}")

# Signing is deterministic, so the same reading always produces the same 64 bytes and there
# is no randomness to get wrong on a microcontroller.
reading = "meter-4 1182.750 kWh"
signature = device.sign(reading)
if verify(gateway_key, reading, signature):
    print(f"accepted   {reading}")
else:
    print("rejected   a reading the device really did sign, which should never happen")

# A digit changed in transit no longer matches what was signed.
edited = "meter-4 1082.750 kWh"
if verify(gateway_key, edited, signature):
    print("accepted   an edited reading, which should never happen")
else:
    print(f"rejected   {edited}")

# Nor does the same reading offered under another device's key.
impostor = DeviceIdentity.from_seed(bytes([90]) * 32)
if verify(impostor.public_key, reading, signature):
    print("accepted   an impostor, which should never happen")
else:
    print("rejected   a signature offered under another device's key")

The same capability in every language

Language Package Reference
Rust pamoja-security reference, docs.rs, install
TypeScript @pamoja/security reference, install
Python pamoja-security reference, install
C# Pamoja.Security reference, install

Documentation

License

MIT

Release files for pamoja-security 0.1.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pamoja-security 0.1.18
File Size Uploaded
pamoja_security-0.1.18.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pamoja-security 0.1.18
File Interpreter ABI Platform
pamoja_security-0.1.18-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / pamoja_security-0.1.18.tar.gz

Download URL pamoja_security-0.1.18.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
13423466dfd6669b2216804c7cb7c5cedb84d89669036148b4253b5e75784dee
BLAKE2b-256 checksum
How to use checksums
27fb7250e90a387143e930a1aee1fab5158e9fe5d4522b16d7bf51175f15cb7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / pamoja_security-0.1.18-py3-none-any.whl

Download URL pamoja_security-0.1.18-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b88c8fbcda35fbbeae2a396f6a3256932274008d4c086eddd1919ab7661867b6
BLAKE2b-256 checksum
How to use checksums
507f77b3ea02a5e3976d769789937d48e394882bf9d0927b2e91d8e3561a67bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.18 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page