transcrypto 1.2.0__tar.gz → 1.3.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: transcrypto
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Basic crypto primitives, not intended for actual use, but as a companion to --Criptografia, Métodos e Algoritmos--
5
5
  Author-email: Daniel Balparda <balparda@github.com>
6
6
  License-Expression: Apache-2.0
@@ -62,28 +62,40 @@ Started in July/2025, by Daniel Balparda. Since version 1.0.2 it is PyPI package
62
62
  - [`rsa`](#rsa)
63
63
  - [`rsa new`](#rsa-new)
64
64
  - [`rsa rawencrypt`](#rsa-rawencrypt)
65
+ - [`rsa encrypt`](#rsa-encrypt)
65
66
  - [`rsa rawdecrypt`](#rsa-rawdecrypt)
67
+ - [`rsa decrypt`](#rsa-decrypt)
66
68
  - [`rsa rawsign`](#rsa-rawsign)
69
+ - [`rsa sign`](#rsa-sign)
67
70
  - [`rsa rawverify`](#rsa-rawverify)
71
+ - [`rsa verify`](#rsa-verify)
68
72
  - [`elgamal`](#elgamal)
69
73
  - [`elgamal shared`](#elgamal-shared)
70
74
  - [`elgamal new`](#elgamal-new)
71
75
  - [`elgamal rawencrypt`](#elgamal-rawencrypt)
76
+ - [`elgamal encrypt`](#elgamal-encrypt)
72
77
  - [`elgamal rawdecrypt`](#elgamal-rawdecrypt)
78
+ - [`elgamal decrypt`](#elgamal-decrypt)
73
79
  - [`elgamal rawsign`](#elgamal-rawsign)
80
+ - [`elgamal sign`](#elgamal-sign)
74
81
  - [`elgamal rawverify`](#elgamal-rawverify)
82
+ - [`elgamal verify`](#elgamal-verify)
75
83
  - [`dsa`](#dsa)
76
84
  - [`dsa shared`](#dsa-shared)
77
85
  - [`dsa new`](#dsa-new)
78
86
  - [`dsa rawsign`](#dsa-rawsign)
87
+ - [`dsa sign`](#dsa-sign)
79
88
  - [`dsa rawverify`](#dsa-rawverify)
89
+ - [`dsa verify`](#dsa-verify)
80
90
  - [`bid`](#bid)
81
91
  - [`bid new`](#bid-new)
82
92
  - [`bid verify`](#bid-verify)
83
93
  - [`sss`](#sss)
84
94
  - [`sss new`](#sss-new)
85
95
  - [`sss rawshares`](#sss-rawshares)
96
+ - [`sss shares`](#sss-shares)
86
97
  - [`sss rawrecover`](#sss-rawrecover)
98
+ - [`sss recover`](#sss-recover)
87
99
  - [`sss rawverify`](#sss-rawverify)
88
100
  - [`doc`](#doc)
89
101
  - [`doc md`](#doc-md)
@@ -185,7 +197,7 @@ poetry run transcrypto <command> [sub-command] [options...]
185
197
  |---|---|
186
198
  | `-v, --verbose` | Increase verbosity (use -v/-vv/-vvv/-vvvv for ERROR/WARN/INFO/DEBUG) |
187
199
  | `--hex` | Treat inputs as hex string (default) |
188
- | `--b64` | Treat inputs as base64url |
200
+ | `--b64` | Treat inputs as base64url; sometimes base64 will start with "-" and that can conflict with flags, so use "--" before positional args if needed |
189
201
  | `--bin` | Treat inputs as binary (bytes) |
190
202
  | `--out-hex` | Outputs as hex (default) |
191
203
  | `--out-b64` | Outputs as base64url |
@@ -237,13 +249,13 @@ Examples:
237
249
 
238
250
  # --- Hashing ---
239
251
  poetry run transcrypto hash sha256 xyz
240
- poetry run transcrypto --b64 hash sha512 eHl6
252
+ poetry run transcrypto --b64 hash sha512 -- eHl6
241
253
  poetry run transcrypto hash file /etc/passwd --digest sha512
242
254
 
243
255
  # --- AES ---
244
256
  poetry run transcrypto --out-b64 aes key "correct horse battery staple"
245
- poetry run transcrypto --b64 --out-b64 aes encrypt -k "<b64key>" "secret"
246
- poetry run transcrypto --b64 --out-b64 aes decrypt -k "<b64key>" "<ciphertext>"
257
+ poetry run transcrypto --b64 --out-b64 aes encrypt -k "<b64key>" -- "secret"
258
+ poetry run transcrypto --b64 --out-b64 aes decrypt -k "<b64key>" -- "<ciphertext>"
247
259
  poetry run transcrypto aes ecb -k "<b64key>" encrypt "<128bithexblock>"
248
260
  poetry run transcrypto aes ecb -k "<b64key>" decrypt "<128bithexblock>"
249
261
 
@@ -254,6 +266,11 @@ Examples:
254
266
  poetry run transcrypto -p rsa-key.priv rsa rawsign <message>
255
267
  poetry run transcrypto -p rsa-key.pub rsa rawverify <message> <signature>
256
268
 
269
+ poetry run transcrypto --bin --out-b64 -p rsa-key.pub rsa encrypt -a <aad> <plaintext>
270
+ poetry run transcrypto --b64 --out-bin -p rsa-key.priv rsa decrypt -a <aad> -- <ciphertext>
271
+ poetry run transcrypto --bin --out-b64 -p rsa-key.priv rsa sign <message>
272
+ poetry run transcrypto --b64 -p rsa-key.pub rsa verify -- <message> <signature>
273
+
257
274
  # --- ElGamal ---
258
275
  poetry run transcrypto -p eg-key elgamal shared --bits 2048
259
276
  poetry run transcrypto -p eg-key elgamal new
@@ -262,21 +279,31 @@ Examples:
262
279
  poetry run transcrypto -p eg-key.priv elgamal rawsign <message>
263
280
  poetry run transcrypto-p eg-key.pub elgamal rawverify <message> <s1:s2>
264
281
 
282
+ poetry run transcrypto --bin --out-b64 -p eg-key.pub elgamal encrypt <plaintext>
283
+ poetry run transcrypto --b64 --out-bin -p eg-key.priv elgamal decrypt -- <ciphertext>
284
+ poetry run transcrypto --bin --out-b64 -p eg-key.priv elgamal sign <message>
285
+ poetry run transcrypto --b64 -p eg-key.pub elgamal verify -- <message> <signature>
286
+
265
287
  # --- DSA ---
266
288
  poetry run transcrypto -p dsa-key dsa shared --p-bits 2048 --q-bits 256
267
289
  poetry run transcrypto -p dsa-key dsa new
268
290
  poetry run transcrypto -p dsa-key.priv dsa rawsign <message>
269
291
  poetry run transcrypto -p dsa-key.pub dsa rawverify <message> <s1:s2>
270
292
 
293
+ poetry run transcrypto --bin --out-b64 -p dsa-key.priv dsa sign <message>
294
+ poetry run transcrypto --b64 -p dsa-key.pub dsa verify -- <message> <signature>
295
+
271
296
  # --- Public Bid ---
272
297
  poetry run transcrypto --bin bid new "tomorrow it will rain"
273
298
  poetry run transcrypto --out-bin bid verify
274
299
 
275
300
  # --- Shamir Secret Sharing (SSS) ---
276
301
  poetry run transcrypto -p sss-key sss new 3 --bits 1024
277
- poetry run transcrypto -p sss-key sss rawshares <secret> 5
302
+ poetry run transcrypto -p sss-key sss rawshares <secret> <n>
278
303
  poetry run transcrypto -p sss-key sss rawrecover
279
- poetry run transcrypto -p sss-key sss rawverify <secret>
304
+ poetry run transcrypto -p sss-key sss rawverify <secret> poetry run transcrypto --bin -p sss-key sss shares <secret> <n>
305
+ poetry run transcrypto --out-bin -p sss-key sss recover
306
+
280
307
  ```
281
308
 
282
309
  ---
@@ -671,7 +698,7 @@ poetry run transcrypto hash sha256 [-h] data
671
698
  ```bash
672
699
  $ poetry run transcrypto --bin hash sha256 xyz
673
700
  3608bca1e44ea6c4d268eb6db02260269892c0b42b86bbf1e77a6fa16c3c9282
674
- $ poetry run transcrypto --b64 hash sha256 eHl6 # "xyz" in base-64
701
+ $ poetry run transcrypto --b64 hash sha256 -- eHl6 # "xyz" in base-64
675
702
  3608bca1e44ea6c4d268eb6db02260269892c0b42b86bbf1e77a6fa16c3c9282
676
703
  ```
677
704
 
@@ -692,7 +719,7 @@ poetry run transcrypto hash sha512 [-h] data
692
719
  ```bash
693
720
  $ poetry run transcrypto --bin hash sha512 xyz
694
721
  4a3ed8147e37876adc8f76328e5abcc1b470e6acfc18efea0135f983604953a58e183c1a6086e91ba3e821d926f5fdeb37761c7ca0328a963f5e92870675b728
695
- $ poetry run transcrypto --b64 hash sha512 eHl6 # "xyz" in base-64
722
+ $ poetry run transcrypto --b64 hash sha512 -- eHl6 # "xyz" in base-64
696
723
  4a3ed8147e37876adc8f76328e5abcc1b470e6acfc18efea0135f983604953a58e183c1a6086e91ba3e821d926f5fdeb37761c7ca0328a963f5e92870675b728
697
724
  ```
698
725
 
@@ -764,9 +791,9 @@ poetry run transcrypto aes encrypt [-h] [-k KEY] [-a AAD] plaintext
764
791
  **Example:**
765
792
 
766
793
  ```bash
767
- $ poetry run transcrypto --b64 --out-b64 aes encrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= AAAAAAB4eXo=
794
+ $ poetry run transcrypto --b64 --out-b64 aes encrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -- AAAAAAB4eXo=
768
795
  F2_ZLrUw5Y8oDnbTP5t5xCUWX8WtVILLD0teyUi_37_4KHeV-YowVA==
769
- $ poetry run transcrypto --b64 --out-b64 aes encrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -a eHl6 AAAAAAB4eXo=
796
+ $ poetry run transcrypto --b64 --out-b64 aes encrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -a eHl6 -- AAAAAAB4eXo=
770
797
  xOlAHPUPpeyZHId-f3VQ_QKKMxjIW0_FBo9WOfIBrzjn0VkVV6xTRA==
771
798
  ```
772
799
 
@@ -787,9 +814,9 @@ poetry run transcrypto aes decrypt [-h] [-k KEY] [-a AAD] ciphertext
787
814
  **Example:**
788
815
 
789
816
  ```bash
790
- $ poetry run transcrypto --b64 --out-b64 aes decrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= F2_ZLrUw5Y8oDnbTP5t5xCUWX8WtVILLD0teyUi_37_4KHeV-YowVA==
817
+ $ poetry run transcrypto --b64 --out-b64 aes decrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -- F2_ZLrUw5Y8oDnbTP5t5xCUWX8WtVILLD0teyUi_37_4KHeV-YowVA==
791
818
  AAAAAAB4eXo=
792
- $ poetry run transcrypto --b64 --out-b64 aes decrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -a eHl6 xOlAHPUPpeyZHId-f3VQ_QKKMxjIW0_FBo9WOfIBrzjn0VkVV6xTRA==
819
+ $ poetry run transcrypto --b64 --out-b64 aes decrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -a eHl6 -- xOlAHPUPpeyZHId-f3VQ_QKKMxjIW0_FBo9WOfIBrzjn0VkVV6xTRA==
793
820
  AAAAAAB4eXo=
794
821
  ```
795
822
 
@@ -947,7 +974,7 @@ poetry run transcrypto rsa decrypt [-h] [-a AAD] ciphertext
947
974
  **Example:**
948
975
 
949
976
  ```bash
950
- $ poetry run transcrypto --b64 --out-bin -p rsa-key.priv rsa decrypt "AO6knI6xwq6TGR…Qy22jiFhXi1eQ==" -a "eHl6"
977
+ $ poetry run transcrypto --b64 --out-bin -p rsa-key.priv rsa decrypt -a eHl6 -- AO6knI6xwq6TGR…Qy22jiFhXi1eQ==
951
978
  abcde
952
979
  ```
953
980
 
@@ -1029,9 +1056,9 @@ poetry run transcrypto rsa verify [-h] [-a AAD] message signature
1029
1056
  **Example:**
1030
1057
 
1031
1058
  ```bash
1032
- $ poetry run transcrypto --b64 -p rsa-key.pub rsa verify "eHl6" "91TS7gC6LORiL…6RD23Aejsfxlw=="
1059
+ $ poetry run transcrypto --b64 -p rsa-key.pub rsa verify -- eHl6 91TS7gC6LORiL…6RD23Aejsfxlw==
1033
1060
  RSA signature: OK
1034
- $ poetry run transcrypto --b64 -p rsa-key.pub rsa verify "eLl6" "91TS7gC6LORiL…6RD23Aejsfxlw=="
1061
+ $ poetry run transcrypto --b64 -p rsa-key.pub rsa verify -- eLl6 91TS7gC6LORiL…6RD23Aejsfxlw==
1035
1062
  RSA signature: INVALID
1036
1063
  ```
1037
1064
 
@@ -1154,7 +1181,7 @@ poetry run transcrypto elgamal decrypt [-h] [-a AAD] ciphertext
1154
1181
  **Example:**
1155
1182
 
1156
1183
  ```bash
1157
- $ poetry run transcrypto --b64 --out-bin -p eg-key.priv elgamal decrypt "CdFvoQ_IIPFPZLua…kqjhcUTspISxURg==" -a "eHl6"
1184
+ $ poetry run transcrypto --b64 --out-bin -p eg-key.priv elgamal decrypt -a eHl6 -- CdFvoQ_IIPFPZLua…kqjhcUTspISxURg==
1158
1185
  abcde
1159
1186
  ```
1160
1187
 
@@ -1236,9 +1263,9 @@ poetry run transcrypto elgamal verify [-h] [-a AAD] message signature
1236
1263
  **Example:**
1237
1264
 
1238
1265
  ```bash
1239
- $ poetry run transcrypto --b64 -p eg-key.pub elgamal verify "eHl6" "Xl4hlYK8SHVGw…0fCKJE1XVzA=="
1266
+ $ poetry run transcrypto --b64 -p eg-key.pub elgamal verify -- eHl6 Xl4hlYK8SHVGw…0fCKJE1XVzA==
1240
1267
  El-Gamal signature: OK
1241
- $ poetry run transcrypto --b64 -p eg-key.pub elgamal verify "eLl6" "Xl4hlYK8SHVGw…0fCKJE1XVzA=="
1268
+ $ poetry run transcrypto --b64 -p eg-key.pub elgamal verify -- eLl6 Xl4hlYK8SHVGw…0fCKJE1XVzA==
1242
1269
  El-Gamal signature: INVALID
1243
1270
  ```
1244
1271
 
@@ -1367,9 +1394,9 @@ poetry run transcrypto dsa verify [-h] [-a AAD] message signature
1367
1394
  **Example:**
1368
1395
 
1369
1396
  ```bash
1370
- $ poetry run transcrypto --b64 -p dsa-key.pub dsa verify "eHl6" "yq8InJVpViXh9…BD4par2XuA="
1397
+ $ poetry run transcrypto --b64 -p dsa-key.pub dsa verify -- eHl6 yq8InJVpViXh9…BD4par2XuA=
1371
1398
  DSA signature: OK
1372
- $ poetry run transcrypto --b64 -p dsa-key.pub dsa verify "eLl6" "yq8InJVpViXh9…BD4par2XuA="
1399
+ $ poetry run transcrypto --b64 -p dsa-key.pub dsa verify -- eLl6 yq8InJVpViXh9…BD4par2XuA=
1373
1400
  DSA signature: INVALID
1374
1401
  ```
1375
1402
 
@@ -1947,7 +1974,7 @@ for p in modmath.PrimeGenerator(1_000_000):
1947
1974
  break
1948
1975
 
1949
1976
  # Secure random 384-bit prime (for RSA/ECC experiments)
1950
- p384 = modmath.NBitRandomPrime(384)
1977
+ p384 = modmath.NBitRandomPrimes(384).pop()
1951
1978
 
1952
1979
  for k, m_p, perfect in modmath.MersennePrimesGenerator(0):
1953
1980
  print(f'p = {k:>8} M = {m_p} perfect = {perfect}')
@@ -2437,7 +2464,7 @@ To activate like a regular environment do:
2437
2464
  ```sh
2438
2465
  poetry env activate
2439
2466
  # will print activation command which you next execute, or you can do:
2440
- source .env/bin/activate # if .env is local to the project
2467
+ source .venv/bin/activate # if .venv is local to the project
2441
2468
  source "$(poetry env info --path)/bin/activate" # for other paths
2442
2469
 
2443
2470
  pytest # or other commands
@@ -2505,11 +2532,31 @@ poetry run transcrypto doc md > CLI.md
2505
2532
  You can find the 10 top slowest tests by running:
2506
2533
 
2507
2534
  ```sh
2508
- poetry run pytest -vvv -q --durations=10
2535
+ poetry run pytest -vvv -q --durations=30
2536
+
2537
+ poetry run pytest -vvv -q --durations=30 -m "not slow" # find slow > 0.1s
2538
+ poetry run pytest -vvv -q --durations=30 -m "not veryslow" # find veryslow > 1s
2539
+
2540
+ poetry run pytest -vvv -q --durations=30 -m slow # check
2541
+ poetry run pytest -vvv -q --durations=30 -m veryslow # check
2509
2542
  ```
2510
2543
 
2511
- You can search for flaky tests by running all tests 100 times:
2544
+ You can search for flaky tests by running all tests 100 times, or more:
2512
2545
 
2513
2546
  ```sh
2514
2547
  poetry run pytest --flake-finder --flake-runs=100
2548
+ poetry run pytest --flake-finder --flake-runs=500 -m "not veryslow"
2549
+ poetry run pytest --flake-finder --flake-runs=10000 -m "not slow"
2515
2550
  ```
2551
+
2552
+ You can instrument your code to find bottlenecks:
2553
+
2554
+ ```sh
2555
+ $ source .venv/bin/activate
2556
+ $ which transcrypto
2557
+ /path/to/.venv/bin/transcrypto # place this in the command below:
2558
+ $ pyinstrument -r html -o dsa_shared.html -- /path/to/.venv/bin/transcrypto -p rsa-key rsa new
2559
+ $ deactivate
2560
+ ```
2561
+
2562
+ Hint: 85%+ is inside `MillerRabinIsPrime()`/`ModExp()`...
@@ -44,28 +44,40 @@ Started in July/2025, by Daniel Balparda. Since version 1.0.2 it is PyPI package
44
44
  - [`rsa`](#rsa)
45
45
  - [`rsa new`](#rsa-new)
46
46
  - [`rsa rawencrypt`](#rsa-rawencrypt)
47
+ - [`rsa encrypt`](#rsa-encrypt)
47
48
  - [`rsa rawdecrypt`](#rsa-rawdecrypt)
49
+ - [`rsa decrypt`](#rsa-decrypt)
48
50
  - [`rsa rawsign`](#rsa-rawsign)
51
+ - [`rsa sign`](#rsa-sign)
49
52
  - [`rsa rawverify`](#rsa-rawverify)
53
+ - [`rsa verify`](#rsa-verify)
50
54
  - [`elgamal`](#elgamal)
51
55
  - [`elgamal shared`](#elgamal-shared)
52
56
  - [`elgamal new`](#elgamal-new)
53
57
  - [`elgamal rawencrypt`](#elgamal-rawencrypt)
58
+ - [`elgamal encrypt`](#elgamal-encrypt)
54
59
  - [`elgamal rawdecrypt`](#elgamal-rawdecrypt)
60
+ - [`elgamal decrypt`](#elgamal-decrypt)
55
61
  - [`elgamal rawsign`](#elgamal-rawsign)
62
+ - [`elgamal sign`](#elgamal-sign)
56
63
  - [`elgamal rawverify`](#elgamal-rawverify)
64
+ - [`elgamal verify`](#elgamal-verify)
57
65
  - [`dsa`](#dsa)
58
66
  - [`dsa shared`](#dsa-shared)
59
67
  - [`dsa new`](#dsa-new)
60
68
  - [`dsa rawsign`](#dsa-rawsign)
69
+ - [`dsa sign`](#dsa-sign)
61
70
  - [`dsa rawverify`](#dsa-rawverify)
71
+ - [`dsa verify`](#dsa-verify)
62
72
  - [`bid`](#bid)
63
73
  - [`bid new`](#bid-new)
64
74
  - [`bid verify`](#bid-verify)
65
75
  - [`sss`](#sss)
66
76
  - [`sss new`](#sss-new)
67
77
  - [`sss rawshares`](#sss-rawshares)
78
+ - [`sss shares`](#sss-shares)
68
79
  - [`sss rawrecover`](#sss-rawrecover)
80
+ - [`sss recover`](#sss-recover)
69
81
  - [`sss rawverify`](#sss-rawverify)
70
82
  - [`doc`](#doc)
71
83
  - [`doc md`](#doc-md)
@@ -167,7 +179,7 @@ poetry run transcrypto <command> [sub-command] [options...]
167
179
  |---|---|
168
180
  | `-v, --verbose` | Increase verbosity (use -v/-vv/-vvv/-vvvv for ERROR/WARN/INFO/DEBUG) |
169
181
  | `--hex` | Treat inputs as hex string (default) |
170
- | `--b64` | Treat inputs as base64url |
182
+ | `--b64` | Treat inputs as base64url; sometimes base64 will start with "-" and that can conflict with flags, so use "--" before positional args if needed |
171
183
  | `--bin` | Treat inputs as binary (bytes) |
172
184
  | `--out-hex` | Outputs as hex (default) |
173
185
  | `--out-b64` | Outputs as base64url |
@@ -219,13 +231,13 @@ Examples:
219
231
 
220
232
  # --- Hashing ---
221
233
  poetry run transcrypto hash sha256 xyz
222
- poetry run transcrypto --b64 hash sha512 eHl6
234
+ poetry run transcrypto --b64 hash sha512 -- eHl6
223
235
  poetry run transcrypto hash file /etc/passwd --digest sha512
224
236
 
225
237
  # --- AES ---
226
238
  poetry run transcrypto --out-b64 aes key "correct horse battery staple"
227
- poetry run transcrypto --b64 --out-b64 aes encrypt -k "<b64key>" "secret"
228
- poetry run transcrypto --b64 --out-b64 aes decrypt -k "<b64key>" "<ciphertext>"
239
+ poetry run transcrypto --b64 --out-b64 aes encrypt -k "<b64key>" -- "secret"
240
+ poetry run transcrypto --b64 --out-b64 aes decrypt -k "<b64key>" -- "<ciphertext>"
229
241
  poetry run transcrypto aes ecb -k "<b64key>" encrypt "<128bithexblock>"
230
242
  poetry run transcrypto aes ecb -k "<b64key>" decrypt "<128bithexblock>"
231
243
 
@@ -236,6 +248,11 @@ Examples:
236
248
  poetry run transcrypto -p rsa-key.priv rsa rawsign <message>
237
249
  poetry run transcrypto -p rsa-key.pub rsa rawverify <message> <signature>
238
250
 
251
+ poetry run transcrypto --bin --out-b64 -p rsa-key.pub rsa encrypt -a <aad> <plaintext>
252
+ poetry run transcrypto --b64 --out-bin -p rsa-key.priv rsa decrypt -a <aad> -- <ciphertext>
253
+ poetry run transcrypto --bin --out-b64 -p rsa-key.priv rsa sign <message>
254
+ poetry run transcrypto --b64 -p rsa-key.pub rsa verify -- <message> <signature>
255
+
239
256
  # --- ElGamal ---
240
257
  poetry run transcrypto -p eg-key elgamal shared --bits 2048
241
258
  poetry run transcrypto -p eg-key elgamal new
@@ -244,21 +261,31 @@ Examples:
244
261
  poetry run transcrypto -p eg-key.priv elgamal rawsign <message>
245
262
  poetry run transcrypto-p eg-key.pub elgamal rawverify <message> <s1:s2>
246
263
 
264
+ poetry run transcrypto --bin --out-b64 -p eg-key.pub elgamal encrypt <plaintext>
265
+ poetry run transcrypto --b64 --out-bin -p eg-key.priv elgamal decrypt -- <ciphertext>
266
+ poetry run transcrypto --bin --out-b64 -p eg-key.priv elgamal sign <message>
267
+ poetry run transcrypto --b64 -p eg-key.pub elgamal verify -- <message> <signature>
268
+
247
269
  # --- DSA ---
248
270
  poetry run transcrypto -p dsa-key dsa shared --p-bits 2048 --q-bits 256
249
271
  poetry run transcrypto -p dsa-key dsa new
250
272
  poetry run transcrypto -p dsa-key.priv dsa rawsign <message>
251
273
  poetry run transcrypto -p dsa-key.pub dsa rawverify <message> <s1:s2>
252
274
 
275
+ poetry run transcrypto --bin --out-b64 -p dsa-key.priv dsa sign <message>
276
+ poetry run transcrypto --b64 -p dsa-key.pub dsa verify -- <message> <signature>
277
+
253
278
  # --- Public Bid ---
254
279
  poetry run transcrypto --bin bid new "tomorrow it will rain"
255
280
  poetry run transcrypto --out-bin bid verify
256
281
 
257
282
  # --- Shamir Secret Sharing (SSS) ---
258
283
  poetry run transcrypto -p sss-key sss new 3 --bits 1024
259
- poetry run transcrypto -p sss-key sss rawshares <secret> 5
284
+ poetry run transcrypto -p sss-key sss rawshares <secret> <n>
260
285
  poetry run transcrypto -p sss-key sss rawrecover
261
- poetry run transcrypto -p sss-key sss rawverify <secret>
286
+ poetry run transcrypto -p sss-key sss rawverify <secret> poetry run transcrypto --bin -p sss-key sss shares <secret> <n>
287
+ poetry run transcrypto --out-bin -p sss-key sss recover
288
+
262
289
  ```
263
290
 
264
291
  ---
@@ -653,7 +680,7 @@ poetry run transcrypto hash sha256 [-h] data
653
680
  ```bash
654
681
  $ poetry run transcrypto --bin hash sha256 xyz
655
682
  3608bca1e44ea6c4d268eb6db02260269892c0b42b86bbf1e77a6fa16c3c9282
656
- $ poetry run transcrypto --b64 hash sha256 eHl6 # "xyz" in base-64
683
+ $ poetry run transcrypto --b64 hash sha256 -- eHl6 # "xyz" in base-64
657
684
  3608bca1e44ea6c4d268eb6db02260269892c0b42b86bbf1e77a6fa16c3c9282
658
685
  ```
659
686
 
@@ -674,7 +701,7 @@ poetry run transcrypto hash sha512 [-h] data
674
701
  ```bash
675
702
  $ poetry run transcrypto --bin hash sha512 xyz
676
703
  4a3ed8147e37876adc8f76328e5abcc1b470e6acfc18efea0135f983604953a58e183c1a6086e91ba3e821d926f5fdeb37761c7ca0328a963f5e92870675b728
677
- $ poetry run transcrypto --b64 hash sha512 eHl6 # "xyz" in base-64
704
+ $ poetry run transcrypto --b64 hash sha512 -- eHl6 # "xyz" in base-64
678
705
  4a3ed8147e37876adc8f76328e5abcc1b470e6acfc18efea0135f983604953a58e183c1a6086e91ba3e821d926f5fdeb37761c7ca0328a963f5e92870675b728
679
706
  ```
680
707
 
@@ -746,9 +773,9 @@ poetry run transcrypto aes encrypt [-h] [-k KEY] [-a AAD] plaintext
746
773
  **Example:**
747
774
 
748
775
  ```bash
749
- $ poetry run transcrypto --b64 --out-b64 aes encrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= AAAAAAB4eXo=
776
+ $ poetry run transcrypto --b64 --out-b64 aes encrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -- AAAAAAB4eXo=
750
777
  F2_ZLrUw5Y8oDnbTP5t5xCUWX8WtVILLD0teyUi_37_4KHeV-YowVA==
751
- $ poetry run transcrypto --b64 --out-b64 aes encrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -a eHl6 AAAAAAB4eXo=
778
+ $ poetry run transcrypto --b64 --out-b64 aes encrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -a eHl6 -- AAAAAAB4eXo=
752
779
  xOlAHPUPpeyZHId-f3VQ_QKKMxjIW0_FBo9WOfIBrzjn0VkVV6xTRA==
753
780
  ```
754
781
 
@@ -769,9 +796,9 @@ poetry run transcrypto aes decrypt [-h] [-k KEY] [-a AAD] ciphertext
769
796
  **Example:**
770
797
 
771
798
  ```bash
772
- $ poetry run transcrypto --b64 --out-b64 aes decrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= F2_ZLrUw5Y8oDnbTP5t5xCUWX8WtVILLD0teyUi_37_4KHeV-YowVA==
799
+ $ poetry run transcrypto --b64 --out-b64 aes decrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -- F2_ZLrUw5Y8oDnbTP5t5xCUWX8WtVILLD0teyUi_37_4KHeV-YowVA==
773
800
  AAAAAAB4eXo=
774
- $ poetry run transcrypto --b64 --out-b64 aes decrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -a eHl6 xOlAHPUPpeyZHId-f3VQ_QKKMxjIW0_FBo9WOfIBrzjn0VkVV6xTRA==
801
+ $ poetry run transcrypto --b64 --out-b64 aes decrypt -k DbWJ_ZrknLEEIoq_NpoCQwHYfjskGokpueN2O_eY0es= -a eHl6 -- xOlAHPUPpeyZHId-f3VQ_QKKMxjIW0_FBo9WOfIBrzjn0VkVV6xTRA==
775
802
  AAAAAAB4eXo=
776
803
  ```
777
804
 
@@ -929,7 +956,7 @@ poetry run transcrypto rsa decrypt [-h] [-a AAD] ciphertext
929
956
  **Example:**
930
957
 
931
958
  ```bash
932
- $ poetry run transcrypto --b64 --out-bin -p rsa-key.priv rsa decrypt "AO6knI6xwq6TGR…Qy22jiFhXi1eQ==" -a "eHl6"
959
+ $ poetry run transcrypto --b64 --out-bin -p rsa-key.priv rsa decrypt -a eHl6 -- AO6knI6xwq6TGR…Qy22jiFhXi1eQ==
933
960
  abcde
934
961
  ```
935
962
 
@@ -1011,9 +1038,9 @@ poetry run transcrypto rsa verify [-h] [-a AAD] message signature
1011
1038
  **Example:**
1012
1039
 
1013
1040
  ```bash
1014
- $ poetry run transcrypto --b64 -p rsa-key.pub rsa verify "eHl6" "91TS7gC6LORiL…6RD23Aejsfxlw=="
1041
+ $ poetry run transcrypto --b64 -p rsa-key.pub rsa verify -- eHl6 91TS7gC6LORiL…6RD23Aejsfxlw==
1015
1042
  RSA signature: OK
1016
- $ poetry run transcrypto --b64 -p rsa-key.pub rsa verify "eLl6" "91TS7gC6LORiL…6RD23Aejsfxlw=="
1043
+ $ poetry run transcrypto --b64 -p rsa-key.pub rsa verify -- eLl6 91TS7gC6LORiL…6RD23Aejsfxlw==
1017
1044
  RSA signature: INVALID
1018
1045
  ```
1019
1046
 
@@ -1136,7 +1163,7 @@ poetry run transcrypto elgamal decrypt [-h] [-a AAD] ciphertext
1136
1163
  **Example:**
1137
1164
 
1138
1165
  ```bash
1139
- $ poetry run transcrypto --b64 --out-bin -p eg-key.priv elgamal decrypt "CdFvoQ_IIPFPZLua…kqjhcUTspISxURg==" -a "eHl6"
1166
+ $ poetry run transcrypto --b64 --out-bin -p eg-key.priv elgamal decrypt -a eHl6 -- CdFvoQ_IIPFPZLua…kqjhcUTspISxURg==
1140
1167
  abcde
1141
1168
  ```
1142
1169
 
@@ -1218,9 +1245,9 @@ poetry run transcrypto elgamal verify [-h] [-a AAD] message signature
1218
1245
  **Example:**
1219
1246
 
1220
1247
  ```bash
1221
- $ poetry run transcrypto --b64 -p eg-key.pub elgamal verify "eHl6" "Xl4hlYK8SHVGw…0fCKJE1XVzA=="
1248
+ $ poetry run transcrypto --b64 -p eg-key.pub elgamal verify -- eHl6 Xl4hlYK8SHVGw…0fCKJE1XVzA==
1222
1249
  El-Gamal signature: OK
1223
- $ poetry run transcrypto --b64 -p eg-key.pub elgamal verify "eLl6" "Xl4hlYK8SHVGw…0fCKJE1XVzA=="
1250
+ $ poetry run transcrypto --b64 -p eg-key.pub elgamal verify -- eLl6 Xl4hlYK8SHVGw…0fCKJE1XVzA==
1224
1251
  El-Gamal signature: INVALID
1225
1252
  ```
1226
1253
 
@@ -1349,9 +1376,9 @@ poetry run transcrypto dsa verify [-h] [-a AAD] message signature
1349
1376
  **Example:**
1350
1377
 
1351
1378
  ```bash
1352
- $ poetry run transcrypto --b64 -p dsa-key.pub dsa verify "eHl6" "yq8InJVpViXh9…BD4par2XuA="
1379
+ $ poetry run transcrypto --b64 -p dsa-key.pub dsa verify -- eHl6 yq8InJVpViXh9…BD4par2XuA=
1353
1380
  DSA signature: OK
1354
- $ poetry run transcrypto --b64 -p dsa-key.pub dsa verify "eLl6" "yq8InJVpViXh9…BD4par2XuA="
1381
+ $ poetry run transcrypto --b64 -p dsa-key.pub dsa verify -- eLl6 yq8InJVpViXh9…BD4par2XuA=
1355
1382
  DSA signature: INVALID
1356
1383
  ```
1357
1384
 
@@ -1929,7 +1956,7 @@ for p in modmath.PrimeGenerator(1_000_000):
1929
1956
  break
1930
1957
 
1931
1958
  # Secure random 384-bit prime (for RSA/ECC experiments)
1932
- p384 = modmath.NBitRandomPrime(384)
1959
+ p384 = modmath.NBitRandomPrimes(384).pop()
1933
1960
 
1934
1961
  for k, m_p, perfect in modmath.MersennePrimesGenerator(0):
1935
1962
  print(f'p = {k:>8} M = {m_p} perfect = {perfect}')
@@ -2419,7 +2446,7 @@ To activate like a regular environment do:
2419
2446
  ```sh
2420
2447
  poetry env activate
2421
2448
  # will print activation command which you next execute, or you can do:
2422
- source .env/bin/activate # if .env is local to the project
2449
+ source .venv/bin/activate # if .venv is local to the project
2423
2450
  source "$(poetry env info --path)/bin/activate" # for other paths
2424
2451
 
2425
2452
  pytest # or other commands
@@ -2487,11 +2514,31 @@ poetry run transcrypto doc md > CLI.md
2487
2514
  You can find the 10 top slowest tests by running:
2488
2515
 
2489
2516
  ```sh
2490
- poetry run pytest -vvv -q --durations=10
2517
+ poetry run pytest -vvv -q --durations=30
2518
+
2519
+ poetry run pytest -vvv -q --durations=30 -m "not slow" # find slow > 0.1s
2520
+ poetry run pytest -vvv -q --durations=30 -m "not veryslow" # find veryslow > 1s
2521
+
2522
+ poetry run pytest -vvv -q --durations=30 -m slow # check
2523
+ poetry run pytest -vvv -q --durations=30 -m veryslow # check
2491
2524
  ```
2492
2525
 
2493
- You can search for flaky tests by running all tests 100 times:
2526
+ You can search for flaky tests by running all tests 100 times, or more:
2494
2527
 
2495
2528
  ```sh
2496
2529
  poetry run pytest --flake-finder --flake-runs=100
2530
+ poetry run pytest --flake-finder --flake-runs=500 -m "not veryslow"
2531
+ poetry run pytest --flake-finder --flake-runs=10000 -m "not slow"
2497
2532
  ```
2533
+
2534
+ You can instrument your code to find bottlenecks:
2535
+
2536
+ ```sh
2537
+ $ source .venv/bin/activate
2538
+ $ which transcrypto
2539
+ /path/to/.venv/bin/transcrypto # place this in the command below:
2540
+ $ pyinstrument -r html -o dsa_shared.html -- /path/to/.venv/bin/transcrypto -p rsa-key rsa new
2541
+ $ deactivate
2542
+ ```
2543
+
2544
+ Hint: 85%+ is inside `MillerRabinIsPrime()`/`ModExp()`...
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
8
8
 
9
9
  [project]
10
10
  name = "transcrypto"
11
- version = "1.2.0"
11
+ version = "1.3.0"
12
12
  description = "Basic crypto primitives, not intended for actual use, but as a companion to --Criptografia, Métodos e Algoritmos--"
13
13
  readme = "README.md"
14
14
  license = "Apache-2.0"
@@ -43,8 +43,9 @@ include = ["transcrypto*"] # avoid picking up stuff not in "transcrypto"
43
43
  requires-poetry = "^2.1"
44
44
 
45
45
  [tool.poetry.dependencies]
46
- cryptography = ">=45.0.6"
46
+ cryptography = ">=45.0.7"
47
47
  zstandard = ">=0.23.0"
48
+ gmpy2 = "^2.2.1"
48
49
 
49
50
  [tool.poetry.requires-plugins]
50
51
  poetry-plugin-export = ">=1.8"
@@ -56,9 +57,10 @@ pyright = "^1.1"
56
57
  pytest = ">=8.4"
57
58
  pytest-pythonpath = ">=0.7"
58
59
  pytest-flakefinder = ">=1.1"
59
- coverage = ">=7.9"
60
+ coverage = ">=7.10"
60
61
  tomli = ">=2.2.1"
61
62
  typeguard = ">=4.4.4"
63
+ pyinstrument = ">=5.1.1"
62
64
 
63
65
  [tool.poetry.scripts]
64
66
  transcrypto = "transcrypto.transcrypto:main"
@@ -23,7 +23,7 @@ from typing import Any, Callable, final, MutableSequence, Protocol, runtime_chec
23
23
  import zstandard
24
24
 
25
25
  __author__ = 'balparda@github.com'
26
- __version__ = '1.2.0' # 2025-09-05, Fri
26
+ __version__ = '1.3.0' # 2025-09-07, Sun
27
27
  __version_tuple__: tuple[int, ...] = tuple(int(v) for v in __version__.split('.'))
28
28
 
29
29
  # MIN_TM = int( # minimum allowed timestamp