astreum 0.2.12__tar.gz → 0.2.13__tar.gz
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.
Potentially problematic release.
This version of astreum might be problematic. Click here for more details.
- {astreum-0.2.12/src/astreum.egg-info → astreum-0.2.13}/PKG-INFO +2 -2
- {astreum-0.2.12 → astreum-0.2.13}/README.md +1 -1
- {astreum-0.2.12 → astreum-0.2.13}/pyproject.toml +1 -1
- astreum-0.2.13/src/astreum/models/transaction.py +83 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/node.py +2 -81
- {astreum-0.2.12 → astreum-0.2.13/src/astreum.egg-info}/PKG-INFO +2 -2
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum.egg-info/SOURCES.txt +3 -2
- {astreum-0.2.12 → astreum-0.2.13}/LICENSE +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/setup.cfg +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/__init__.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/_node/__init__.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/_node/storage/__init__.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/_node/storage/merkle.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/_node/storage/patricia.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/crypto/__init__.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/crypto/ed25519.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/crypto/quadratic_form.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/crypto/wesolowski.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/crypto/x25519.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/format.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/lispeum/__init__.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/lispeum/parser.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum/lispeum/tokenizer.py +0 -0
- {astreum-0.2.12/src/astreum/utils → astreum-0.2.13/src/astreum/models}/__init__.py +0 -0
- {astreum-0.2.12/src/astreum/utils → astreum-0.2.13/src/astreum/models}/patricia.py +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum.egg-info/dependency_links.txt +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum.egg-info/requires.txt +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/src/astreum.egg-info/top_level.txt +0 -0
- {astreum-0.2.12 → astreum-0.2.13}/tests/test_node_machine.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.13
|
|
4
4
|
Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
|
|
5
5
|
Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
|
|
6
6
|
Project-URL: Homepage, https://github.com/astreum/lib
|
|
@@ -118,6 +118,6 @@ except ParseError as e:
|
|
|
118
118
|
## Testing
|
|
119
119
|
|
|
120
120
|
```bash
|
|
121
|
-
|
|
121
|
+
source venv/bin/activate
|
|
122
122
|
python3 -m unittest discover -s tests
|
|
123
123
|
```
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from ..format import encode, decode
|
|
2
|
+
from ..crypto import ed25519
|
|
3
|
+
import blake3
|
|
4
|
+
|
|
5
|
+
class Transaction:
|
|
6
|
+
def __init__(
|
|
7
|
+
self,
|
|
8
|
+
sender_pk: bytes,
|
|
9
|
+
recipient_pk: bytes,
|
|
10
|
+
amount: int,
|
|
11
|
+
fee: int,
|
|
12
|
+
nonce: int,
|
|
13
|
+
signature: bytes | None = None,
|
|
14
|
+
) -> None:
|
|
15
|
+
self.sender_pk = sender_pk
|
|
16
|
+
self.recipient_pk = recipient_pk
|
|
17
|
+
self.amount = amount
|
|
18
|
+
self.fee = fee
|
|
19
|
+
self.nonce = nonce
|
|
20
|
+
self.signature = signature
|
|
21
|
+
|
|
22
|
+
if self.amount < 0 or self.fee < 0:
|
|
23
|
+
raise ValueError("amount and fee must be non-negative")
|
|
24
|
+
|
|
25
|
+
if self.fee % 2 != 0:
|
|
26
|
+
raise ValueError("fee must be divisible by two")
|
|
27
|
+
|
|
28
|
+
self.tx_body_hash: bytes = blake3.blake3(self._body_bytes()).digest()
|
|
29
|
+
|
|
30
|
+
if self.signature is not None:
|
|
31
|
+
self.tx_hash = blake3.blake3(self.tx_body_hash + self.signature).digest()
|
|
32
|
+
else:
|
|
33
|
+
self.tx_hash = None
|
|
34
|
+
|
|
35
|
+
def sign(self, priv_key: ed25519.Ed25519PrivateKey) -> None:
|
|
36
|
+
if self.signature is not None:
|
|
37
|
+
raise ValueError("transaction already signed")
|
|
38
|
+
sig = priv_key.sign(self.tx_body_hash)
|
|
39
|
+
self.signature = sig
|
|
40
|
+
self.tx_hash = blake3.blake3(self.tx_body_hash + sig).digest()
|
|
41
|
+
|
|
42
|
+
def verify_signature(self) -> bool:
|
|
43
|
+
if self.signature is None:
|
|
44
|
+
return False
|
|
45
|
+
try:
|
|
46
|
+
pub = ed25519.Ed25519PublicKey.from_public_bytes(self.sender_pk)
|
|
47
|
+
pub.verify(self.signature, self.tx_body_hash)
|
|
48
|
+
return True
|
|
49
|
+
except Exception:
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
def to_bytes(self) -> bytes:
|
|
53
|
+
sig = self.signature or b""
|
|
54
|
+
return encode([
|
|
55
|
+
self.sender_pk,
|
|
56
|
+
self.recipient_pk,
|
|
57
|
+
self.amount,
|
|
58
|
+
self.fee,
|
|
59
|
+
self.nonce,
|
|
60
|
+
sig,
|
|
61
|
+
])
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def from_bytes(cls, blob: bytes) -> 'Transaction':
|
|
65
|
+
sender, recipient, amount, fee, nonce, sig = decode(blob)
|
|
66
|
+
return cls(sender, recipient, int(amount), int(fee), int(nonce), sig)
|
|
67
|
+
|
|
68
|
+
def _body_bytes(self) -> bytes:
|
|
69
|
+
return encode([
|
|
70
|
+
self.sender_pk,
|
|
71
|
+
self.recipient_pk,
|
|
72
|
+
self.amount,
|
|
73
|
+
self.fee,
|
|
74
|
+
self.nonce,
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
def __eq__(self, other: "Transaction") -> bool:
|
|
78
|
+
if not isinstance(other, Transaction):
|
|
79
|
+
return NotImplemented
|
|
80
|
+
return self.tx_hash == other.tx_hash
|
|
81
|
+
|
|
82
|
+
def __hash__(self) -> int:
|
|
83
|
+
return int.from_bytes(self.tx_hash, 'big')
|
|
@@ -6,6 +6,8 @@ from pathlib import Path
|
|
|
6
6
|
from typing import Tuple, Dict, Union, Optional, List
|
|
7
7
|
from datetime import datetime, timedelta, timezone
|
|
8
8
|
import uuid
|
|
9
|
+
|
|
10
|
+
from .models.transaction import Transaction
|
|
9
11
|
from .format import encode, decode
|
|
10
12
|
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
|
|
11
13
|
from cryptography.hazmat.primitives import serialization
|
|
@@ -323,87 +325,6 @@ class Env:
|
|
|
323
325
|
f"parent_id={self.parent_id})"
|
|
324
326
|
)
|
|
325
327
|
|
|
326
|
-
|
|
327
|
-
class Transaction:
|
|
328
|
-
def __init__(
|
|
329
|
-
self,
|
|
330
|
-
sender_pk: bytes,
|
|
331
|
-
recipient_pk: bytes,
|
|
332
|
-
amount: int,
|
|
333
|
-
fee: int,
|
|
334
|
-
nonce: int,
|
|
335
|
-
signature: bytes | None = None,
|
|
336
|
-
) -> None:
|
|
337
|
-
self.sender_pk = sender_pk
|
|
338
|
-
self.recipient_pk = recipient_pk
|
|
339
|
-
self.amount = amount
|
|
340
|
-
self.fee = fee
|
|
341
|
-
self.nonce = nonce
|
|
342
|
-
self.signature = signature
|
|
343
|
-
|
|
344
|
-
if self.amount < 0 or self.fee < 0:
|
|
345
|
-
raise ValueError("amount and fee must be non-negative")
|
|
346
|
-
|
|
347
|
-
if self.fee % 2 != 0:
|
|
348
|
-
raise ValueError("fee must be divisible by two")
|
|
349
|
-
|
|
350
|
-
self.tx_body_hash: bytes = blake3.blake3(self._body_bytes()).digest()
|
|
351
|
-
|
|
352
|
-
if self.signature is not None:
|
|
353
|
-
self.tx_hash = blake3.blake3(self.tx_body_hash + self.signature).digest()
|
|
354
|
-
else:
|
|
355
|
-
self.tx_hash = None
|
|
356
|
-
|
|
357
|
-
def sign(self, priv_key: ed25519.Ed25519PrivateKey) -> None:
|
|
358
|
-
if self.signature is not None:
|
|
359
|
-
raise ValueError("transaction already signed")
|
|
360
|
-
sig = priv_key.sign(self.tx_body_hash)
|
|
361
|
-
self.signature = sig
|
|
362
|
-
self.tx_hash = blake3.blake3(self.tx_body_hash + sig).digest()
|
|
363
|
-
|
|
364
|
-
def verify_signature(self) -> bool:
|
|
365
|
-
if self.signature is None:
|
|
366
|
-
return False
|
|
367
|
-
try:
|
|
368
|
-
pub = ed25519.Ed25519PublicKey.from_public_bytes(self.sender_pk)
|
|
369
|
-
pub.verify(self.signature, self.tx_body_hash)
|
|
370
|
-
return True
|
|
371
|
-
except Exception:
|
|
372
|
-
return False
|
|
373
|
-
|
|
374
|
-
def to_bytes(self) -> bytes:
|
|
375
|
-
sig = self.signature or b""
|
|
376
|
-
return encode([
|
|
377
|
-
self.sender_pk,
|
|
378
|
-
self.recipient_pk,
|
|
379
|
-
self.amount,
|
|
380
|
-
self.fee,
|
|
381
|
-
self.nonce,
|
|
382
|
-
sig,
|
|
383
|
-
])
|
|
384
|
-
|
|
385
|
-
@classmethod
|
|
386
|
-
def from_bytes(cls, blob: bytes) -> 'Transaction':
|
|
387
|
-
sender, recipient, amount, fee, nonce, sig = decode(blob)
|
|
388
|
-
return cls(sender, recipient, int(amount), int(fee), int(nonce), sig)
|
|
389
|
-
|
|
390
|
-
def _body_bytes(self) -> bytes:
|
|
391
|
-
return encode([
|
|
392
|
-
self.sender_pk,
|
|
393
|
-
self.recipient_pk,
|
|
394
|
-
self.amount,
|
|
395
|
-
self.fee,
|
|
396
|
-
self.nonce,
|
|
397
|
-
])
|
|
398
|
-
|
|
399
|
-
def __eq__(self, other: Any) -> bool:
|
|
400
|
-
if not isinstance(other, Transaction):
|
|
401
|
-
return NotImplemented
|
|
402
|
-
return self.tx_hash == other.tx_hash
|
|
403
|
-
|
|
404
|
-
def __hash__(self) -> int:
|
|
405
|
-
return int.from_bytes(self.tx_hash, 'big')
|
|
406
|
-
|
|
407
328
|
class Block:
|
|
408
329
|
def __init__(
|
|
409
330
|
self,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.13
|
|
4
4
|
Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
|
|
5
5
|
Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
|
|
6
6
|
Project-URL: Homepage, https://github.com/astreum/lib
|
|
@@ -118,6 +118,6 @@ except ParseError as e:
|
|
|
118
118
|
## Testing
|
|
119
119
|
|
|
120
120
|
```bash
|
|
121
|
-
|
|
121
|
+
source venv/bin/activate
|
|
122
122
|
python3 -m unittest discover -s tests
|
|
123
123
|
```
|
|
@@ -21,6 +21,7 @@ src/astreum/crypto/x25519.py
|
|
|
21
21
|
src/astreum/lispeum/__init__.py
|
|
22
22
|
src/astreum/lispeum/parser.py
|
|
23
23
|
src/astreum/lispeum/tokenizer.py
|
|
24
|
-
src/astreum/
|
|
25
|
-
src/astreum/
|
|
24
|
+
src/astreum/models/__init__.py
|
|
25
|
+
src/astreum/models/patricia.py
|
|
26
|
+
src/astreum/models/transaction.py
|
|
26
27
|
tests/test_node_machine.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|