Skip to content

Commit eaeffdc

Browse files
committed
Fix SDK RTD
1 parent 3ede25e commit eaeffdc

File tree

5 files changed

+222
-6
lines changed

5 files changed

+222
-6
lines changed

sdk/docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
'python': ('https://docs.python.org/3', None)
2727
}
2828

29-
autoapi_dirs = ['../../']
30-
autoapi_file_patterns = ['aleo.pyi']
29+
autoapi_dirs = ['./', '../../python/aleo']
30+
autoapi_file_patterns = ['__init__.pyi']
3131
autoapi_generate_api_docs = True
3232
autoapi_add_toctree_entry = False
3333
autoapi_keep_files = False

sdk/docs/source/examples.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ Working with accounts
1717
>>> same_account = aleo.Account.from_private_key(private_key)
1818
>>> assert account == same_account
1919

20+
Encrypted key materials
21+
************************************
22+
23+
.. doctest::
24+
25+
>>> ciphertext = aleo.Ciphertext.from_string(
26+
... "ciphertext1qvqt0sp0pp49gjeh50alfalt7ug3g8y7ha6\
27+
... cl3jkavcsnz8d0y9jwr27taxfrwd5kly8lah53qure3vxav\
28+
... 6zxr7txattdvscv0kf3vcuqv9cmzj32znx4uwxdawcj3273\
29+
... zhgm8qwpxqczlctuvjvc596mgsqjxwz37f")
30+
>>> decrypted = aleo.Encryptor.decrypt_private_key_with_secret(ciphertext, "qwe123")
31+
>>> account = aleo.Account.from_private_key(decrypted)
32+
>>> str(account)
33+
'aleo1w58eg85ckl76c0pzzf4mdg2y39t9t7jfvp9u2fvnj2a2t8aquqpqrlycqt'
2034

2135
Working with signatures
2236
***********************

sdk/python/aleo/__init__.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class ComputeKey:
6060
def pr_sig(self) -> Group: ...
6161
def sk_prf(self) -> Scalar: ...
6262

63+
class Encryptor:
64+
@staticmethod
65+
def encrypt_private_key_with_secret(private_key: PrivateKey, secret: str) -> Ciphertext: ...
66+
@staticmethod
67+
def decrypt_private_key_with_secret(ciphertext: Ciphertext, secret: str) -> PrivateKey: ...
6368

6469
class EpochChallenge:
6570
@staticmethod
@@ -207,7 +212,7 @@ class Network:
207212
@staticmethod
208213
def name() -> str: ...
209214
@staticmethod
210-
def version() -> int: ...
215+
def id() -> int: ...
211216
@staticmethod
212217
def edition() -> int: ...
213218
@staticmethod

sdk/python/aleo/_aleolib.pyi

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
from __future__ import annotations
2+
3+
class Account:
4+
pass
5+
6+
7+
class Address:
8+
pass
9+
10+
11+
class Authorization:
12+
pass
13+
14+
15+
class Boolean:
16+
pass
17+
18+
19+
class Ciphertext:
20+
pass
21+
22+
23+
class Credits:
24+
pass
25+
26+
27+
class CoinbasePuzzle:
28+
pass
29+
30+
31+
class CoinbaseVerifyingKey:
32+
pass
33+
34+
35+
class ComputeKey:
36+
pass
37+
38+
39+
class EpochChallenge:
40+
pass
41+
42+
43+
class Execution:
44+
pass
45+
46+
47+
class Fee:
48+
pass
49+
50+
51+
class Field:
52+
pass
53+
54+
55+
class Group:
56+
pass
57+
58+
59+
class Identifier:
60+
pass
61+
62+
63+
class I8:
64+
pass
65+
66+
67+
class I16:
68+
pass
69+
70+
71+
class I32:
72+
pass
73+
74+
75+
class I64:
76+
pass
77+
78+
79+
class I128:
80+
pass
81+
82+
83+
class Literal:
84+
pass
85+
86+
87+
class Locator:
88+
pass
89+
90+
91+
class Network:
92+
pass
93+
94+
95+
class MicroCredits:
96+
pass
97+
98+
99+
class Plaintext:
100+
pass
101+
102+
103+
class PrivateKey:
104+
pass
105+
106+
107+
class Process:
108+
pass
109+
110+
111+
class Program:
112+
pass
113+
114+
115+
class ProgramID:
116+
pass
117+
118+
119+
class ProverSolution:
120+
pass
121+
122+
123+
class ProvingKey:
124+
pass
125+
126+
127+
class Query:
128+
pass
129+
130+
131+
class RecordCiphertext:
132+
pass
133+
134+
135+
class RecordPlaintext:
136+
pass
137+
138+
139+
class Response:
140+
pass
141+
142+
143+
class Scalar:
144+
pass
145+
146+
147+
class Signature:
148+
pass
149+
150+
151+
class Trace:
152+
pass
153+
154+
155+
class Transaction:
156+
pass
157+
158+
159+
class Transition:
160+
pass
161+
162+
163+
class U8:
164+
pass
165+
166+
167+
class U16:
168+
pass
169+
170+
171+
class U32:
172+
pass
173+
174+
175+
class U64:
176+
pass
177+
178+
179+
class U128:
180+
pass
181+
182+
183+
class Value:
184+
pass
185+
186+
187+
class VerifyingKey:
188+
pass
189+
190+
191+
class ViewKey:
192+
pass
193+

sdk/python/aleo/encryptor.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
from __future__ import annotations
22

3-
from ._aleolib import PrivateKey, Ciphertext, Field, Network, Identifier, Plaintext, Literal
3+
from . import PrivateKey, Ciphertext, Field, Network, Identifier, Plaintext, Literal
44

55

66
class Encryptor:
7+
"""Class for encrypting and decrypting Aleo key material into ciphertext.
8+
"""
79
@staticmethod
8-
# Encrypt a private key into ciphertext using a secret
910
def encrypt_private_key_with_secret(private_key: PrivateKey, secret: str) -> Ciphertext:
11+
"""Encrypts a private key into ciphertext using a secret.
12+
"""
1013
seed = private_key.seed()
1114
return Encryptor.__encrypt_field(seed, secret, "private_key")
1215

1316
@staticmethod
14-
# Decrypt a private key from ciphertext using a secret
1517
def decrypt_private_key_with_secret(ciphertext: Ciphertext, secret: str) -> PrivateKey:
18+
"""Decrypts a private key from ciphertext using a secret.
19+
"""
1620
seed = Encryptor.__decrypt_field(ciphertext, secret, "private_key")
1721
return PrivateKey.from_seed(seed)
1822

0 commit comments

Comments
 (0)