Skip to main content

Algorand Puya RSA Signature Verification: RFC8017 RSASSA-PKCS1-V1.5-VERIFY function implementation

Project description

Puya RSA

Algorand Puya RSA RFC8017 RSASSA-PKCS1-V1.5-VERIFY function implementation. Intended to allow on-chain verification of RSA signatures seen in practice (e.g. JWT signatures), compliant with the Public Key Cryptography Standard v1.5. See RFC Section 8.2.2.

⚠️ Not officially production ready until documentation updated to indicate otherwise. Use at your own risk.

Features

  • Supports up to 1024 bytes (8192 bits) long modulus
  • RSASSA-PKCS1-V1.5-VERIFY function implementation

Install

Puya RSA is available on PyPI:

pip install puya-rsa

Usage

All inputs to math functions are assumed to be big-endian encoded numbers unless explicitly stated otherwise.

from puya_rsa import (
    pkcs1_v15_verify
)
# ... pkcs1_v15_verify(msg_digest_info, signature, public_modulus, exponent, barrett_reduction_factor)

The pkcs1_v15_verify function arguments are as follows:

  • msg_digest_info is a message digest with an identifier of the hashing function prepended
  • signature is the signature used to sign the message
  • public_modulus is the public RSA key (modulus)
  • exponent is the exponent used to generate the RSA key (typically 2**16)
  • barrett_reduction_factor is a precomputed factor according to the Barrett Reduction algorithm, which depends on the public key modulus. This must be calculated on-chain and proven (e.g. in contract state) to be trustless, otherwise it would act as a magic number. See Puya BigNumber.

Develop

This module uses poetry as the package manager and Python environment manager. Please see How to Build and Publish Python Packages With Poetry.

Test

poetry run pytest -v

License & Contribution

Contributions and additions are welcomed. Please respect the terms of the GNU GPL v3 license. Attribution for the author Winton Nathan-Roberts is required. No warranties or liabilities per the license. It is not yet officially production ready, although it is thoroughly tested.

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

puya_rsa-0.2.2.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

puya_rsa-0.2.2-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file puya_rsa-0.2.2.tar.gz.

File metadata

  • Download URL: puya_rsa-0.2.2.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.10.9-350.vanilla.fc40.x86_64

File hashes

Hashes for puya_rsa-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3a730928f13907edab332bcbbe0bb1b6aa592168d0d5104e9f67d3f389726739
MD5 fd310ca5756a2e002dd6c2b0d0ed9dda
BLAKE2b-256 1647ef7d8197dba72bc1cbe392b01c1c3f8d3cb821604329be0d9928dc55db1d

See more details on using hashes here.

File details

Details for the file puya_rsa-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: puya_rsa-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.10.9-350.vanilla.fc40.x86_64

File hashes

Hashes for puya_rsa-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fbdc47440f7c7e04f4d68d9e8281a169615f148848948b23b2312e97ca8c7a24
MD5 3f7e857e769dc6b8df073bd69d829b73
BLAKE2b-256 e4f7bb5a9f53fcb4404f521ae6a7a0f54a241bb303fd068294e6a34ac4d283a8

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