activeledger 1.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- activeledger/__init__.py +93 -0
- activeledger/bip39-english.txt +2048 -0
- activeledger/canonical.py +151 -0
- activeledger/connection.py +128 -0
- activeledger/ec.py +367 -0
- activeledger/events.py +91 -0
- activeledger/keys.py +99 -0
- activeledger/pq.py +221 -0
- activeledger/recovery.py +172 -0
- activeledger/transaction.py +152 -0
- activeledger-1.3.0.dist-info/METADATA +387 -0
- activeledger-1.3.0.dist-info/RECORD +15 -0
- activeledger-1.3.0.dist-info/WHEEL +5 -0
- activeledger-1.3.0.dist-info/licenses/LICENSE +19 -0
- activeledger-1.3.0.dist-info/top_level.txt +1 -0
activeledger/__init__.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Python SDK for Activeledger, with post-quantum identity support.
|
|
2
|
+
|
|
3
|
+
The core is stdlib-only. Post-quantum keys need the optional extra::
|
|
4
|
+
|
|
5
|
+
pip install 'activeledger-sdk[pq]'
|
|
6
|
+
|
|
7
|
+
Everything else -- canonical JSON, transaction building, submission and event
|
|
8
|
+
subscription -- works with no compiled dependency at all, so an application
|
|
9
|
+
that signs elsewhere (an HSM, a remote service, a user's wallet) never needs a
|
|
10
|
+
C toolchain.
|
|
11
|
+
|
|
12
|
+
from activeledger import Activeledger, KeyPair, KeyType
|
|
13
|
+
|
|
14
|
+
ledger = Activeledger("http://localhost:5260")
|
|
15
|
+
identity = ledger.onboard(KeyPair.generate(KeyType.ML_DSA_65))
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from .canonical import canonical_bytes, canonical_json
|
|
19
|
+
from .connection import Connection, Identity, LedgerResponse
|
|
20
|
+
from .events import EventStream, LedgerEvent
|
|
21
|
+
from . import recovery
|
|
22
|
+
from .keys import KeyType, Signer
|
|
23
|
+
from .transaction import Transaction, TransactionBuilder, onboard_transaction
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"Activeledger",
|
|
27
|
+
"Connection",
|
|
28
|
+
"EventStream",
|
|
29
|
+
"Identity",
|
|
30
|
+
"KeyType",
|
|
31
|
+
"LedgerEvent",
|
|
32
|
+
"LedgerResponse",
|
|
33
|
+
"Signer",
|
|
34
|
+
"Transaction",
|
|
35
|
+
"TransactionBuilder",
|
|
36
|
+
"canonical_bytes",
|
|
37
|
+
"canonical_json",
|
|
38
|
+
"onboard_transaction",
|
|
39
|
+
"KeyPair",
|
|
40
|
+
"PostQuantumUnavailable",
|
|
41
|
+
"Secp256k1KeyPair",
|
|
42
|
+
"recovery",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
__version__ = "1.3.0"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Activeledger:
|
|
49
|
+
"""Entry point.
|
|
50
|
+
|
|
51
|
+
There is deliberately no storage endpoint here. A node's storage service
|
|
52
|
+
listens only on the node's own host, so it is not something a client can
|
|
53
|
+
reach. State is read through a transaction: name streams in ``$r`` with
|
|
54
|
+
:meth:`TransactionBuilder.readonly` and have the contract return values
|
|
55
|
+
with ``returnToRemote``, which arrive in ``LedgerResponse.responses``.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
def __init__(self, base_url: str, timeout: float = 30.0) -> None:
|
|
59
|
+
self.connection = Connection(base_url, timeout=timeout)
|
|
60
|
+
self.events = EventStream(base_url)
|
|
61
|
+
|
|
62
|
+
def onboard(self, signer, label: str = "identity") -> Identity:
|
|
63
|
+
return self.connection.onboard(signer, label)
|
|
64
|
+
|
|
65
|
+
def submit(self, transaction: Transaction) -> LedgerResponse:
|
|
66
|
+
return self.connection.submit(transaction)
|
|
67
|
+
|
|
68
|
+
@staticmethod
|
|
69
|
+
def transaction() -> TransactionBuilder:
|
|
70
|
+
return TransactionBuilder()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def __getattr__(name):
|
|
74
|
+
"""Expose KeyPair lazily so importing this package never needs liboqs.
|
|
75
|
+
|
|
76
|
+
`from activeledger import KeyPair` works whether or not the [pq] extra is
|
|
77
|
+
installed; it is only actually using one that raises, and with a message
|
|
78
|
+
naming the extra rather than a CMake traceback.
|
|
79
|
+
"""
|
|
80
|
+
if name in ("KeyPair", "PostQuantumUnavailable"):
|
|
81
|
+
from . import pq
|
|
82
|
+
|
|
83
|
+
return getattr(pq, name)
|
|
84
|
+
|
|
85
|
+
# Same reasoning for secp256k1: importing this package must not require
|
|
86
|
+
# the [ec] extra either, and a caller who never touches secp256k1 should
|
|
87
|
+
# never be asked to install python-ecdsa.
|
|
88
|
+
if name == "Secp256k1KeyPair":
|
|
89
|
+
from . import ec
|
|
90
|
+
|
|
91
|
+
return ec.Secp256k1KeyPair
|
|
92
|
+
|
|
93
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|