Skip to main content

Public Key Name System Framework

Project description

Public Key Name System Framework

Made with Python3 GitHub license PyPI Github status Made with
This is the Public Key Name System Framework designed as a Public Key Exchange for both centralised and peer-to-peer services. It comes pre-built with useful and powerful CLI tools.

Key Features

  • JSON-based Serialization with optional zlib compression for efficient data exchange
  • UDP Transport for low-latency, connectionless communication
  • Thread Pool Executor for efficient multi-client request handling
  • Master Key Vault with network protection for secure key storage
  • db86 JSON Database for persistent, queryable data storage
  • RSA Cryptography for key generation and digital signatures

Installation

From source

To install from source use the following command, make sure you have setuptools>=50.0.0

python3 seutp.py install

To install from PyPI

pip3 install pkns

Using the PKNS_Table API

The PKNS_Table API is the core for the PKNS Local Services found in the pknscore

from pkns.pknscore import PKNS_Table
new_table = PKNS_Table(PATH_TO_A_TABLE_DIR)

PATH_TO_A_TABLE can be a path to an existing table directory or a new table directory, defaults to ~/.pkns. The API provides all basic table operations and secure master key management.

Master Key Vault

Master keys for peergroups are stored in an encrypted vault within the database and are never exposed over the network:

# Get master key (local-only operation)
master_key = table.get_master_key(fingerprint)

# List all master keys
keys = table.list_master_keys()

# Remove a master key
table.remove_master_key(fingerprint)

Using the PKNS_Server API

The PKNS_Server API is the core of PKNS Network Services found in the pknscore. It provides the correct server handling and configuration for a hosted PKNS Services. The PKNS service runs on the default port 6300 over UDP. It efficiently handles multiple concurrent clients using a configurable thread pool and can be safely daemonized.

from pkns.pknscore import PKNS_Server
server = PKNS_Server(IP_ADDR, PORT, PATH_TO_A_TABLE_DIR, max_workers=10)

IP_ADDR is the IP Address to bind to, defaults to 0.0.0.0, PORT is the port to be used for the server, defaults to 6300, PATH_TO_A_TABLE can be a path to an existing table directory or a new table directory, defaults to ~/.pkns, and max_workers is the number of worker threads in the pool, defaults to 10.

UDP Transport

The server uses UDP for fast, stateless communication:

  • Single-packet request/response model for low latency
  • Automatic payload signing with SHA256
  • JSON serialization with optional zlib compression

Query Syntax

PKNS Query is used for better integration of centralised servers. The query follows a fixed Syntax

pkns://HOST_SERVER[:PORT][/PEERGROUP][/USER]

CLI Tools

CLI Tools help manage the PKNS Tables and Servers easily, they also include useful functions.

Local Table Manager tabman

Managing Local Tables

$ pkns tabman
Usage: pkns tabman [OPTIONS] COMMAND [ARGS]...

  PKNS Table Manager

Options:
  --help  Show this message and exit.

Commands:
  add-peergroup     Add/Create a Peergroup
  add-user          Add Users to a Peergroup
  del-peergroup     Delete/Leave a Peergroup
  del-user          Remove Users from a Peergroup
  get-peergroup     Get Info of a Peergroup
  get-user          Get Users Info from a Peergroup
  rename-peergroup  Rename a Peergroup
  rename-user       Rename a User from a Peergroup

Server Manager server

Server Utilities

$ pkns server
Usage: pkns server [OPTIONS] COMMAND [ARGS]...

  PKNS Server Manager

Options:
  -i, --host TEXT     IP Address to bind  [default: 0.0.0.0]
  -p, --port INTEGER  Port to bind  [default: 6300]
  --help              Show this message and exit.

Commands:
  restart  Restart PKNS Server
  start    Start the PKNS Server
  status   PKNS Server Status
  stop     Stop the PKNS Server

Other utilities

Ping

Ping a Local or Remote Server

$ pkns ping --help
Usage: pkns ping [OPTIONS] [ADDRESS]

  PKNS Ping

Options:
  -n, --nop INTEGER  Number of Pings to send
  --help             Show this message and exit.

Query

Query Local or Remote Server

$ pkns query --help
Usage: pkns query [OPTIONS] QUERY

  PKNS Query

Options:
  --help  Show this message and exit.

Sync

Sync to Local or Remote Server

$ pkns sync --help
Usage: pkns sync [OPTIONS] [ADDRESS]

  PKNS Sync

Options:
  --help  Show this message and exit.

Technical Architecture

Serialization Layer

  • JSON-based serialization for structured, human-readable data exchange
  • Zlib compression (optional) reduces payload size with PKNSZ prefix for detection
  • Type preservation for bytes (base64-encoded) and tuples (preserved through round-trip)
  • Replaces legacy pickle5 for better compatibility with db86 JSON storage

Network Layer

  • UDP transport (BaseUDPBus) for fast, connectionless communication
  • Single-packet request/response model with SHA256 signing
  • Thread pool executor on server side for efficient concurrent request handling
  • Automatic sender address tracking for reply routing

Storage Layer

  • db86 JSON Database for persistent key-value storage
  • Automatic schema creation for peergroups and users
  • Master Key Vault protected from network access for secure cryptographic key storage
  • Per-peergroup user tables for flexible data organization

Security

  • Master keys stored only in local vault, never transmitted over network
  • Protected tables (vault, peergroups) block unauthorized queries
  • SHA256-signed messages prevent tampering
  • RSA key generation with configurable sizes (default 3072-bit)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pkns-0.6.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pkns-0.6.0-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file pkns-0.6.0.tar.gz.

File metadata

  • Download URL: pkns-0.6.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pkns-0.6.0.tar.gz
Algorithm Hash digest
SHA256 4740d509dd42e82f05ca2c1d01a708ed759cb2df61e8e660ccf6da639003982c
MD5 3dbda5e93d9734837e3f69708e5e8a1e
BLAKE2b-256 c69525c5382dd2ebfa113a4379004fce6d6cd45ebf5a3a406e1cc7e012319f4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pkns-0.6.0.tar.gz:

Publisher: python-publish.yml on anubhav-narayan/PKNS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pkns-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pkns-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pkns-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2586ca0423850809ed001da4db5ea25891af9834a11b9686c13dced95d1cf9e
MD5 5c7fed85da797294107ace42a79d4426
BLAKE2b-256 412e765455a98b1dd660862b4688f5498c5b37ac9f936a811984a5f3d29c3110

See more details on using hashes here.

Provenance

The following attestation bundles were made for pkns-0.6.0-py3-none-any.whl:

Publisher: python-publish.yml on anubhav-narayan/PKNS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page