Skip to main content

Reference verifier and signer for the POL/1.0 (Proof-of-Logic) verifiable work-receipt standard.

Project description

logicnodes-pol

Reference verifier and signer for POL/1.0 (Proof-of-Logic) — an open standard for verifiable work receipts in a machine-to-machine economy.

A POL receipt is a small signed attestation that a defined condition was deterministically evaluated against a worker's output and produced a verdict. Verification is a pure function of the receipt and the issuer's public signer address — no secret, no account, and no network call required.

Install

pip install logicnodes-pol

Verify a receipt (Python)

from logicnodes_pol import verify_receipt

receipt = {
    "payload": {
        "receipt": "0x77102c0e...",
        "escrow_id": "0xa8bff8e8...",
        "agent": "example-worker",
        "output_hash": "0x839ee4b2...",
        "verified": True,
        "amount_usdc": 0.01,
        "settlement_tx": None,
        "chain": "base",
    },
    "signature": {
        "standard": "EIP-191",
        "signer": "0x0D12B2B82e4aE84A15a032C31C6A8a23520Ecde7",
        "payload_hash": "0xe2dc732e...",
        "signature": "6738841a...",
    },
}

result = verify_receipt(receipt)
print(result.verified)            # True
print(result.recovered_signer)    # 0x0D12B2B82e4aE84A15a032C31C6A8a23520Ecde7
print(result.payload_hash_matches)  # True

If any field in the signed body is altered after signing, payload_hash_matches becomes False and verified becomes False — the receipt is rejected even though the signature itself is still mathematically valid over the original hash.

Verify from the command line

# verify a receipt file against the default logicnodes.io issuer
pol verify receipt.json

# verify against a different issuer signer
pol verify receipt.json --signer 0xYourIssuerSigner

# machine-readable output
pol verify receipt.json --json

# read from stdin
cat receipt.json | pol verify -

# print the canonical payload_hash of a receipt body
pol hash receipt.json

pol verify exits 0 on PASS and 1 on FAIL, so it composes in CI and shell pipelines.

Sign a receipt (POL/1.0-Producer)

from logicnodes_pol import sign_receipt

signed = sign_receipt(
    {"receipt": "0x...", "verified": True, "agent": "my-worker", "amount_usdc": 0.01, "chain": "base"},
    private_key="0x...",
)

How verification works (POL/1.0 §05)

  1. Canonicalize the signed body: JSON with sort_keys=True, compact separators, _verification key dropped.
  2. Hash: payload_hash = "0x" + sha256(canonical).
  3. Recover: EIP-191 encode_defunct(hexstr=payload_hash) → ecrecover the signer.
  4. Decide: a receipt is verified when the derived hash equals the claimed payload_hash and the recovered signer equals the expected issuer.

This library implements both the POL/1.0-Verifier and POL/1.0-Producer conformance profiles.

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

logicnodes_pol-1.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

logicnodes_pol-1.0.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file logicnodes_pol-1.0.0.tar.gz.

File metadata

  • Download URL: logicnodes_pol-1.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for logicnodes_pol-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a6fd43400957980c1921df1cac7edce4c428be81e962f4258cf75509a2bac4c6
MD5 88249106bcafd231c39e112388306c0a
BLAKE2b-256 c4483c1d9546bffb0482269481763a0846e8cdfbe90fb8b6a9f7e2722a15136a

See more details on using hashes here.

File details

Details for the file logicnodes_pol-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for logicnodes_pol-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a0ca40beb3a70f60ba463313d00739dd3a501eefcf6ed7315be92454d59943f
MD5 cea84645b25dbcb01c1f06ba39151df2
BLAKE2b-256 12a87ebfe127186bc23ed1d108677bba4266bcdf6bbcbb0f15be5e92fab8aed0

See more details on using hashes here.

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