Skip to main content

Amora is a secure token inspired by JWT and Branca, but enhanced a bit in some areas.

Project description

Amora

Amora is a secure token inspired by JWT and Branca, but enhanced a bit in some areas.

Key features:

  • Can contain any type of payload: JSON, msgpack, cbor and so on...
  • Always encrypted and authenticated using XChaCha20-Poly1305 algorithm.
  • There are two versions of Amora:
    • Amora zero: encrypted with a 32-byte symmetric key.
    • Amora one: encrypted with a 32-byte asymmetric key.
  • Encoded using url-safe base64.
  • Always contain token generation time and TTL.

Amora structure

  • header (4 bytes for Amora zero; 36 bytes for Amora one):
    • version marker: 0xa0 or 0xa1 (1 byte)
    • TTL (3 bytes; little-endian)
    • randomly generated public key (32 bytes; Amora one only)
  • nonce (24 bytes)
    • token generation time (first 4 bytes; little-endian)
    • randomly generated 20 bytes
  • payload (any length)
  • message authentication code (4 bytes)

Token generation time (TGT) + TTL

TGT is an unsigned 32-bit int. It's a number of seconds starting from the Unix epoch on January 1, 1970 UTC. This means that Amora tokens will work correctly until the year 2106.

TTL is an unsigned 24-bits int. It means that each token can be valid for a maximum of 194 days.

Asymmetric encryption

The shared key is computed using the X25519 function. It requires two pairs of priv/pub keys. The first pair must be known. The second pair is randomly generated for each token.

Code examples

Symmetric key from bytes

from amora_py import Amora

key = bytes([
	0x4f, 0x99, 0x70, 0x66, 0x2f, 0xac, 0xd3, 0x7d,
	0xc3, 0x6c, 0x0f, 0xd1, 0xda, 0xd0, 0x7e, 0xaa,
	0x04, 0x7c, 0x28, 0x54, 0x58, 0x3c, 0x92, 0x0f,
	0x52, 0x4b, 0x2b, 0x01, 0xd8, 0x40, 0x83, 0x1a,
])
amora = Amora.amora_zero(key)
payload = "sample_payload_just_for_testing"
token = amora.encode(payload.encode(), 1)
decoded = amora.decode(token, True)
decoded = bytes(decoded).decode()

Symmetric key from string

from amora_py import Amora

key = "4f9970662facd37dc36c0fd1dad07eaa047c2854583c920f524b2b01d840831a"
amora = Amora.amora_zero_from_str(key)
payload = "sample_payload_just_for_testing"
token = amora.encode(payload.encode(), 1)
decoded = amora.decode(token, True)
decoded = bytes(decoded).decode()

Asymmetric key from bytes

from amora_py import Amora
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey

x25519 = X25519PrivateKey.generate()
secret_key = x25519.private_bytes_raw()
public_key = x25519.public_key().public_bytes_raw()
amora = Amora.amora_one(secret_key, public_key)
payload = "sample_payload_just_for_testing"
token = amora.encode(payload.encode(), 1)
decoded = amora.decode(token, True)
decoded = bytes(decoded).decode()

Asymmetric key from string

from amora_py import Amora

secret_key = "778d0b92672b9a25ec4fbe65e3ad2212efa011e8f7035754c1342fe46191dbb3"
public_key = "5cdd89c1bb6859c927c50b6976712f256cdbf14d7273f723dc121c191f9d6d6d"
amora = Amora.amora_one_from_str(secret_key, public_key)
payload = "sample_payload_just_for_testing"
token = amora.encode(payload.encode(), 1)
decoded = amora.decode(token, True)
decoded = bytes(decoded).decode()

Fetch metadata from the token

from amora_py import Amora

token = "oAEAAE_X6GVaC7xve5xaaAaLiW1YPqHX9I1BNGbKnC7ArMke4G" \
	"EU9MXCgU2U5jYAkJhDXQBqsO5tadCKyXZmI3mV-bpDFr1aQc1U";
meta = Amora.meta(token)
print(meta)

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

amora_py-0.2.2.tar.gz (15.5 kB view details)

Uploaded Source

Built Distributions

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

amora_py-0.2.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (318.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

amora_py-0.2.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (303.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

amora_py-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (318.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

amora_py-0.2.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (303.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

amora_py-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (319.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

amora_py-0.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (303.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

amora_py-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (321.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

amora_py-0.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (305.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

amora_py-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (320.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

amora_py-0.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (305.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: amora_py-0.2.2.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b9831173199b83200101d9d0e465ec3321d871a02904b0a0fd92a6db2f6ae44c
MD5 b8bac1803ea19e55eb2ef9978dce6003
BLAKE2b-256 5264ec4616aace4bc5179d561f33dfd709017fd5612dc3de3a4553936c684885

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 318.1 kB
  • Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84a1c9fff389b5c7f4bd58b89874eeb2e8df6260f48eae56662d157fcaf5c42c
MD5 91ef38bf6c02b61166e8ea696eff2e16
BLAKE2b-256 3db45fc217f46859a4e95aa3d54e6270c8191b7cf6359c4e205fe09eb9020c82

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 303.1 kB
  • Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b6bcadedf66ba6dcd2b6c1f3b6200088603212a1315f24ba4bc010dea613dca8
MD5 55b6f54ea08d62cc6eca3ca891eb36fe
BLAKE2b-256 199f1c8598ffef6282ea27cf189175145e54bcba7719f7afb2f90b5acdd1c108

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 318.2 kB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa66e05e1e184e2eec7dc4099c68da764f3e089e19acc0641d91860750d39be5
MD5 4a9c4ecfeb2c50e375ac9404ed236e9d
BLAKE2b-256 6ee733631ef3ed591e3121817e0e635422a4dd6057c6247a9a383f661d07bcb0

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 303.6 kB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 056636fd7dce9b792813c9db377cc41f98021dfc30fc9b882457504a6812ab04
MD5 e16da1a46c467b49db61dea9cfc11164
BLAKE2b-256 70079a29e41ea13b28f4903ab2e1067e9d60b34beddb6f0bb9e8dd71336e95eb

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 319.2 kB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 967d12abf9dfac3a9d261a243a74bbf4edaf01d45ccb056af3849e03f72965bf
MD5 56cabc6a62be21d60aa7ee744b67ee37
BLAKE2b-256 b0941f3c2ccad71204fc524ab9b98a5dfa84e8ec34f9af0b1b9e7f1833566554

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 303.7 kB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 636cac51151858676720c8de0aa8f1b0f9fdfea172e2dca1ee667c9844672ee3
MD5 e9179e9b157ae64dcf31273f07b60716
BLAKE2b-256 ffc82e66287fab965082c9f20a4bc4dddda2bd2bddfe5294978a46292ffb979e

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 321.0 kB
  • Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5897d67abec7e0628eab1473929b04a5c74b5888b7e773ffc240524b6d930ca1
MD5 2cb2630ed05563dfa392aa0953abf488
BLAKE2b-256 3a8b5e9567780672f7d6c74f1709168a353417ade1de552402cf3243d45d9c77

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 305.7 kB
  • Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8c445d4c919b36a5e3f201bb1b3bb0883b0b220e177a453821820262bcfbed42
MD5 5c7006bf0bce381c3ae40dbb5eb6c464
BLAKE2b-256 e62a61b05eb2373641576308869bb78d3c562acf369ada33f5a1534e373a576b

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 320.5 kB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9fdb78d6d4b830dd8bc7f3430afd2d86149cf9614b9744f23ab3b469d17dd864
MD5 42ffe9d7145967c24c8bdb5a434c1c19
BLAKE2b-256 2e3d7abb8f97dc10643da5a47151e7a5b7623d3c6feb28965d92db3d803694b5

See more details on using hashes here.

File details

Details for the file amora_py-0.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: amora_py-0.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 305.5 kB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for amora_py-0.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2599d185b6cf3e7e7f8ce7ff76ca173910ace12a5e81f686df5ef0b3fec4c8cd
MD5 904048e9653db797543a7070eff28350
BLAKE2b-256 a1e5d66843ba4ce73d90554883eef5d36f184d02a6797dbd1da0dc20f992bedb

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