astreum 0.1.15__py3-none-any.whl → 0.1.16__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.

Potentially problematic release.


This version of astreum might be problematic. Click here for more details.

File without changes
@@ -0,0 +1,50 @@
1
+ # EdDSA signature algorithm over Curve25519
2
+
3
+ # ed25519.py
4
+ from cryptography.hazmat.primitives.asymmetric import ed25519
5
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
6
+ from cryptography.exceptions import InvalidSignature
7
+ from typing import Tuple
8
+
9
+ def generate_key_pair() -> Tuple[Ed25519PrivateKey, Ed25519PublicKey]:
10
+ """
11
+ Generate an Ed25519 private and public key pair.
12
+
13
+ Returns:
14
+ Tuple[Ed25519PrivateKey, Ed25519PublicKey]: The generated key pair.
15
+ """
16
+ private_key: Ed25519PrivateKey = ed25519.Ed25519PrivateKey.generate()
17
+ public_key: Ed25519PublicKey = private_key.public_key()
18
+ return private_key, public_key
19
+
20
+ def sign_message(private_key: Ed25519PrivateKey, message: bytes) -> bytes:
21
+ """
22
+ Sign a message using the provided Ed25519 private key.
23
+
24
+ Args:
25
+ private_key (Ed25519PrivateKey): The private key used for signing.
26
+ message (bytes): The message to sign.
27
+
28
+ Returns:
29
+ bytes: The signature.
30
+ """
31
+ signature: bytes = private_key.sign(message)
32
+ return signature
33
+
34
+ def verify_signature(public_key: Ed25519PublicKey, message: bytes, signature: bytes) -> bool:
35
+ """
36
+ Verify a message signature using the provided Ed25519 public key.
37
+
38
+ Args:
39
+ public_key (Ed25519PublicKey): The public key corresponding to the private key that signed.
40
+ message (bytes): The original message.
41
+ signature (bytes): The signature to verify.
42
+
43
+ Returns:
44
+ bool: True if the signature is valid, False otherwise.
45
+ """
46
+ try:
47
+ public_key.verify(signature, message)
48
+ return True
49
+ except InvalidSignature:
50
+ return False
@@ -0,0 +1,31 @@
1
+ # Diffie-Hellman key exchange over Curve25519
2
+
3
+ # x25519.py
4
+ from cryptography.hazmat.primitives.asymmetric import x25519
5
+ from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
6
+ from typing import Tuple
7
+
8
+ def generate_key_pair() -> Tuple[X25519PrivateKey, X25519PublicKey]:
9
+ """
10
+ Generate an X25519 private and public key pair.
11
+
12
+ Returns:
13
+ Tuple[X25519PrivateKey, X25519PublicKey]: The generated key pair.
14
+ """
15
+ private_key: X25519PrivateKey = x25519.X25519PrivateKey.generate()
16
+ public_key: X25519PublicKey = private_key.public_key()
17
+ return private_key, public_key
18
+
19
+ def generate_shared_key(private_key: X25519PrivateKey, peer_public_key: X25519PublicKey) -> bytes:
20
+ """
21
+ Generate a shared key using the provided private key and peer's public key.
22
+
23
+ Args:
24
+ private_key (X25519PrivateKey): Our private key.
25
+ peer_public_key (X25519PublicKey): The peer's public key.
26
+
27
+ Returns:
28
+ bytes: The shared key.
29
+ """
30
+ shared_key: bytes = private_key.exchange(peer_public_key)
31
+ return shared_key
@@ -0,0 +1,90 @@
1
+ from .account import Account
2
+
3
+ class Transaction:
4
+ def __init__(
5
+ self,
6
+ sender: Account,
7
+ recipient: Account,
8
+ amount: int,
9
+ data: bytes = None,
10
+ counter: int = 0
11
+ ):
12
+ self.sender = sender
13
+ self.recipient = recipient
14
+ self.amount = amount
15
+ self.data = data
16
+ self.counter = counter
17
+ self.timestamp = time.time()
18
+ self.signature = None
19
+
20
+
21
+ def get_tx_from_storage(hash: bytes) -> Optional[Transaction]:
22
+ """Resolves storage objects to get a transaction.
23
+
24
+ Args:
25
+ hash: Hash of the transaction and merkle root of the transaction
26
+
27
+ Returns:
28
+ Transaction object if found, None otherwise
29
+ """
30
+ return None
31
+
32
+
33
+ def put_tx_to_storage(transaction: Transaction):
34
+ """Puts a transaction into storage.
35
+
36
+ Args:
37
+ transaction: Transaction object to put into storage
38
+
39
+ Returns:
40
+ None
41
+ """
42
+ return None
43
+
44
+
45
+ def get_tx_hash(transaction: Transaction) -> bytes:
46
+ """Get the hash of a transaction.
47
+
48
+ Args:
49
+ transaction: Transaction object to get hash for
50
+
51
+ Returns:
52
+ Merkle root of the transaction body hash and signature
53
+ """
54
+ return hash_data(get_tx_body_hash(transaction) + hash_data(transaction.signature))
55
+
56
+ def get_tx_body_hash(transaction: Transaction) -> bytes:
57
+ """Get the hash of the transaction body.
58
+
59
+ Args:
60
+ transaction: Transaction object to get hash for
61
+
62
+ Returns:
63
+ Hash of the transaction body
64
+ """
65
+ return hash_data(transaction)
66
+
67
+ def sign_tx(transaction: Transaction, private_key: bytes) -> Transaction:
68
+ """Sign a transaction.
69
+
70
+ Args:
71
+ transaction: Transaction object to sign
72
+ private_key: Private key to sign with
73
+
74
+ Returns:
75
+ Signed transaction
76
+ """
77
+ transaction.signature = hash_data(get_tx_body_hash(transaction) + private_key)
78
+ return transaction
79
+
80
+
81
+ def verify_tx(transaction: Transaction) -> bool:
82
+ """Verify a transaction.
83
+
84
+ Args:
85
+ transaction: Transaction object to verify,with sender public key
86
+
87
+ Returns:
88
+ True if the transaction is valid, False otherwise
89
+ """
90
+ return True
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: astreum
3
- Version: 0.1.15
3
+ Version: 0.1.16
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
@@ -14,6 +14,7 @@ License-File: LICENSE
14
14
  Requires-Dist: pycryptodomex==3.21.0
15
15
  Requires-Dist: cryptography==44.0.2
16
16
  Requires-Dist: blake3==1.0.4
17
+ Dynamic: license-file
17
18
 
18
19
  # lib
19
20
 
@@ -23,6 +23,9 @@ astreum/machine/environment.py,sha256=K0084U6B7wwjrDZ9b2_7cEcbBzsB7UOy_Zpbrr7B3G
23
23
  astreum/machine/error.py,sha256=MvqBaZZt33rNELNhUJ2lER3TE3aS8WVqsWF2hz2AwoA,38
24
24
  astreum/node/__init__.py,sha256=K7F21c7V9vlJuTWoSw9arsLA8RF5KNR5I6QS3Frl_Ys,19481
25
25
  astreum/node/utils.py,sha256=amGhNYHVMjvAO-9vBRAcim-S5LlLSRudqooBN-XPdm4,702
26
+ astreum/node/crypto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ astreum/node/crypto/ed25519.py,sha256=FRnvlN0kZlxn4j-sJKl-C9tqiz_0z4LZyXLj3KIj1TQ,1760
28
+ astreum/node/crypto/x25519.py,sha256=i29v4BmwKRcbz9E7NKqFDQyxzFtJUqN0St9jd7GS1uA,1137
26
29
  astreum/node/relay/__init__.py,sha256=0zvbchIbLUPqGA7QXJbXokKupcIq6Iu3X3VUpxejIQc,14981
27
30
  astreum/node/relay/bucket.py,sha256=pcmollbbM-xeHlmDxLZnzvf0Ut-9v9RoN6SijYiQuu8,2893
28
31
  astreum/node/relay/envelope.py,sha256=sDKsIvJruQKLWgWs92sx1mCjMHF7yQVoLguPygw2Pz8,10037
@@ -39,6 +42,7 @@ astreum/node/validation/account.py,sha256=gFoJHoSAZs7BKGaewNaLiziivKINTCh8MBpOoN
39
42
  astreum/node/validation/constants.py,sha256=ImIdLZFtMKx1iWg60YssEKl2tdDqZQnIa2JaJE6CX0o,422
40
43
  astreum/node/validation/stake.py,sha256=Z9EPM-X9c92fpsZIYsdVpvgz4DhxQViPM-RDktWUZq8,7141
41
44
  astreum/node/validation/state.py,sha256=QMXY7h4da-o79wMjJW93ixtepyhgcbJEf101yVuZurg,7661
45
+ astreum/node/validation/transaction.py,sha256=mHnQX5AAVlVb6GXvty20SnARU0qMidjxyU4bLN_hL9o,2315
42
46
  astreum/node/validation/vdf.py,sha256=HDdnqn9O_LicfE7SNCmncawKoR-ojLyjlpn74OvRNOU,2194
43
47
  astreum/node/validation/block/__init__.py,sha256=n2HaMG_5cpa7y5xko-c7vbHz8rL-1wAGthmr8boNrCs,216
44
48
  astreum/node/validation/block/create.py,sha256=apD9h92b9Y146zeppSzKNk_NJPgyBy7FhxoEkypQQNk,2515
@@ -46,8 +50,8 @@ astreum/node/validation/block/model.py,sha256=d7x3_tX2MPLnGODL_5_vNjQfLdYa405blc
46
50
  astreum/node/validation/block/validate.py,sha256=niLexCNhEwUJLclyrdNZSvHcVa_J6jlu7J3FiWY7XBU,6232
47
51
  astreum/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
52
  astreum/utils/bytes_format.py,sha256=X4tG5GGPweNCE54bHYkLFiuLTbmpy5upO_s1Cef-MGA,2711
49
- astreum-0.1.15.dist-info/LICENSE,sha256=gYBvRDP-cPLmTyJhvZ346QkrYW_eleke4Z2Yyyu43eQ,1089
50
- astreum-0.1.15.dist-info/METADATA,sha256=dkXfuFNHZTgGlPpIHmcYC8hReofWF52gD_4_6JcCQSA,3290
51
- astreum-0.1.15.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
52
- astreum-0.1.15.dist-info/top_level.txt,sha256=1EG1GmkOk3NPmUA98FZNdKouhRyget-KiFiMk0i2Uz0,8
53
- astreum-0.1.15.dist-info/RECORD,,
53
+ astreum-0.1.16.dist-info/licenses/LICENSE,sha256=gYBvRDP-cPLmTyJhvZ346QkrYW_eleke4Z2Yyyu43eQ,1089
54
+ astreum-0.1.16.dist-info/METADATA,sha256=cNSuluyEijqvfLHqHOrtPE3Jy-09CsIXIvXzJvoSId8,3312
55
+ astreum-0.1.16.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
56
+ astreum-0.1.16.dist-info/top_level.txt,sha256=1EG1GmkOk3NPmUA98FZNdKouhRyget-KiFiMk0i2Uz0,8
57
+ astreum-0.1.16.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.0.0)
2
+ Generator: setuptools (77.0.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5