safe-eth-native 0.1.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.
- safe_eth_native-0.1.0/Cargo.lock +606 -0
- safe_eth_native-0.1.0/Cargo.toml +25 -0
- safe_eth_native-0.1.0/LICENSE +21 -0
- safe_eth_native-0.1.0/PKG-INFO +84 -0
- safe_eth_native-0.1.0/README.md +60 -0
- safe_eth_native-0.1.0/pyproject.toml +49 -0
- safe_eth_native-0.1.0/safe_eth_native.pyi +7 -0
- safe_eth_native-0.1.0/src/lib.rs +275 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "base16ct"
|
|
13
|
+
version = "1.0.0"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "block-buffer"
|
|
19
|
+
version = "0.12.1"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
|
|
22
|
+
dependencies = [
|
|
23
|
+
"hybrid-array",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[[package]]
|
|
27
|
+
name = "cc"
|
|
28
|
+
version = "1.11.2"
|
|
29
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
+
checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"find-msvc-tools",
|
|
33
|
+
"shlex",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "cfg-if"
|
|
38
|
+
version = "1.0.5"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
41
|
+
|
|
42
|
+
[[package]]
|
|
43
|
+
name = "cmov"
|
|
44
|
+
version = "0.5.4"
|
|
45
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
46
|
+
checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
|
|
47
|
+
|
|
48
|
+
[[package]]
|
|
49
|
+
name = "const-oid"
|
|
50
|
+
version = "0.10.3"
|
|
51
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
52
|
+
checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a"
|
|
53
|
+
|
|
54
|
+
[[package]]
|
|
55
|
+
name = "cpubits"
|
|
56
|
+
version = "0.1.1"
|
|
57
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
58
|
+
checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "cpufeatures"
|
|
62
|
+
version = "0.3.1"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
|
|
65
|
+
dependencies = [
|
|
66
|
+
"libc",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[[package]]
|
|
70
|
+
name = "crunchy"
|
|
71
|
+
version = "0.2.4"
|
|
72
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
73
|
+
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
|
74
|
+
|
|
75
|
+
[[package]]
|
|
76
|
+
name = "crypto-bigint"
|
|
77
|
+
version = "0.7.11"
|
|
78
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
79
|
+
checksum = "914c195c4d7fbc5ed7f88d14cbf85914d5c664967658d43404b263913a477e82"
|
|
80
|
+
dependencies = [
|
|
81
|
+
"cpubits",
|
|
82
|
+
"ctutils",
|
|
83
|
+
"hybrid-array",
|
|
84
|
+
"num-traits",
|
|
85
|
+
"rand_core 0.10.1",
|
|
86
|
+
"subtle",
|
|
87
|
+
"zeroize",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[[package]]
|
|
91
|
+
name = "crypto-common"
|
|
92
|
+
version = "0.2.2"
|
|
93
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
94
|
+
checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
|
|
95
|
+
dependencies = [
|
|
96
|
+
"hybrid-array",
|
|
97
|
+
"rand_core 0.10.1",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[[package]]
|
|
101
|
+
name = "ctutils"
|
|
102
|
+
version = "0.4.8"
|
|
103
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
104
|
+
checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f"
|
|
105
|
+
dependencies = [
|
|
106
|
+
"cmov",
|
|
107
|
+
"subtle",
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
[[package]]
|
|
111
|
+
name = "der"
|
|
112
|
+
version = "0.8.3"
|
|
113
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
114
|
+
checksum = "6a996a108feb8b427a6e12fcf6af4aa83409b79d72c15337d7741368131ee004"
|
|
115
|
+
dependencies = [
|
|
116
|
+
"const-oid",
|
|
117
|
+
"zeroize",
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
[[package]]
|
|
121
|
+
name = "digest"
|
|
122
|
+
version = "0.11.3"
|
|
123
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
124
|
+
checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
|
|
125
|
+
dependencies = [
|
|
126
|
+
"block-buffer",
|
|
127
|
+
"const-oid",
|
|
128
|
+
"crypto-common",
|
|
129
|
+
"ctutils",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
[[package]]
|
|
133
|
+
name = "ecdsa"
|
|
134
|
+
version = "0.17.0"
|
|
135
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
136
|
+
checksum = "c0681a4fc24c767085329728d8dfba959af91228aa4610cca4f8ce317ba46ae0"
|
|
137
|
+
dependencies = [
|
|
138
|
+
"der",
|
|
139
|
+
"digest",
|
|
140
|
+
"elliptic-curve",
|
|
141
|
+
"rfc6979",
|
|
142
|
+
"signature",
|
|
143
|
+
"zeroize",
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
[[package]]
|
|
147
|
+
name = "elliptic-curve"
|
|
148
|
+
version = "0.14.3"
|
|
149
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
150
|
+
checksum = "900f37e7e18d74a2347389af6cd69e3a30d5cc9e697f40004865679aa75e9c7c"
|
|
151
|
+
dependencies = [
|
|
152
|
+
"base16ct",
|
|
153
|
+
"crypto-bigint",
|
|
154
|
+
"crypto-common",
|
|
155
|
+
"digest",
|
|
156
|
+
"ff",
|
|
157
|
+
"group",
|
|
158
|
+
"hybrid-array",
|
|
159
|
+
"rand_core 0.10.1",
|
|
160
|
+
"sec1",
|
|
161
|
+
"subtle",
|
|
162
|
+
"zeroize",
|
|
163
|
+
]
|
|
164
|
+
|
|
165
|
+
[[package]]
|
|
166
|
+
name = "ff"
|
|
167
|
+
version = "0.14.0"
|
|
168
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
169
|
+
checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f"
|
|
170
|
+
dependencies = [
|
|
171
|
+
"rand_core 0.10.1",
|
|
172
|
+
"subtle",
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
[[package]]
|
|
176
|
+
name = "find-msvc-tools"
|
|
177
|
+
version = "0.1.15"
|
|
178
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
179
|
+
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
|
|
180
|
+
|
|
181
|
+
[[package]]
|
|
182
|
+
name = "getrandom"
|
|
183
|
+
version = "0.3.4"
|
|
184
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
185
|
+
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
|
186
|
+
dependencies = [
|
|
187
|
+
"cfg-if",
|
|
188
|
+
"libc",
|
|
189
|
+
"r-efi",
|
|
190
|
+
"wasip2",
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
[[package]]
|
|
194
|
+
name = "group"
|
|
195
|
+
version = "0.14.0"
|
|
196
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
197
|
+
checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4"
|
|
198
|
+
dependencies = [
|
|
199
|
+
"ff",
|
|
200
|
+
"rand_core 0.10.1",
|
|
201
|
+
"subtle",
|
|
202
|
+
]
|
|
203
|
+
|
|
204
|
+
[[package]]
|
|
205
|
+
name = "heck"
|
|
206
|
+
version = "0.5.0"
|
|
207
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
208
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
209
|
+
|
|
210
|
+
[[package]]
|
|
211
|
+
name = "hmac"
|
|
212
|
+
version = "0.13.0"
|
|
213
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
214
|
+
checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"
|
|
215
|
+
dependencies = [
|
|
216
|
+
"digest",
|
|
217
|
+
]
|
|
218
|
+
|
|
219
|
+
[[package]]
|
|
220
|
+
name = "hybrid-array"
|
|
221
|
+
version = "0.4.15"
|
|
222
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
223
|
+
checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
|
|
224
|
+
dependencies = [
|
|
225
|
+
"subtle",
|
|
226
|
+
"typenum",
|
|
227
|
+
"zeroize",
|
|
228
|
+
]
|
|
229
|
+
|
|
230
|
+
[[package]]
|
|
231
|
+
name = "libc"
|
|
232
|
+
version = "0.2.191"
|
|
233
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
234
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
235
|
+
|
|
236
|
+
[[package]]
|
|
237
|
+
name = "num-traits"
|
|
238
|
+
version = "0.2.19"
|
|
239
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
240
|
+
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
|
241
|
+
dependencies = [
|
|
242
|
+
"autocfg",
|
|
243
|
+
]
|
|
244
|
+
|
|
245
|
+
[[package]]
|
|
246
|
+
name = "once_cell"
|
|
247
|
+
version = "1.21.4"
|
|
248
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
249
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
250
|
+
|
|
251
|
+
[[package]]
|
|
252
|
+
name = "p256"
|
|
253
|
+
version = "0.14.0"
|
|
254
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
255
|
+
checksum = "d2c9239b2dbc807adbbe147e8cf72ea7450c3a0aabe62cb8e75ff4ec22e1f72a"
|
|
256
|
+
dependencies = [
|
|
257
|
+
"ecdsa",
|
|
258
|
+
"elliptic-curve",
|
|
259
|
+
"primefield",
|
|
260
|
+
"primeorder",
|
|
261
|
+
"sha2",
|
|
262
|
+
]
|
|
263
|
+
|
|
264
|
+
[[package]]
|
|
265
|
+
name = "portable-atomic"
|
|
266
|
+
version = "1.15.0"
|
|
267
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
268
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
269
|
+
|
|
270
|
+
[[package]]
|
|
271
|
+
name = "ppv-lite86"
|
|
272
|
+
version = "0.2.21"
|
|
273
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
274
|
+
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
|
275
|
+
dependencies = [
|
|
276
|
+
"zerocopy",
|
|
277
|
+
]
|
|
278
|
+
|
|
279
|
+
[[package]]
|
|
280
|
+
name = "primefield"
|
|
281
|
+
version = "0.14.0"
|
|
282
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
283
|
+
checksum = "c555a6e4eb7d4e158fcb028c835c3b8642206ddc279b5c6b202ef9a8bdb592f4"
|
|
284
|
+
dependencies = [
|
|
285
|
+
"crypto-bigint",
|
|
286
|
+
"crypto-common",
|
|
287
|
+
"ff",
|
|
288
|
+
"rand_core 0.10.1",
|
|
289
|
+
"subtle",
|
|
290
|
+
"zeroize",
|
|
291
|
+
]
|
|
292
|
+
|
|
293
|
+
[[package]]
|
|
294
|
+
name = "primeorder"
|
|
295
|
+
version = "0.14.0"
|
|
296
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
297
|
+
checksum = "5c9f42978c78a00e3d68f69fc03e57a234debae69da4020a4fb588fcdcd07b06"
|
|
298
|
+
dependencies = [
|
|
299
|
+
"elliptic-curve",
|
|
300
|
+
"primefield",
|
|
301
|
+
"wnaf",
|
|
302
|
+
]
|
|
303
|
+
|
|
304
|
+
[[package]]
|
|
305
|
+
name = "proc-macro2"
|
|
306
|
+
version = "1.0.107"
|
|
307
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
308
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
309
|
+
dependencies = [
|
|
310
|
+
"unicode-ident",
|
|
311
|
+
]
|
|
312
|
+
|
|
313
|
+
[[package]]
|
|
314
|
+
name = "pyo3"
|
|
315
|
+
version = "0.30.1"
|
|
316
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
317
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
318
|
+
dependencies = [
|
|
319
|
+
"libc",
|
|
320
|
+
"once_cell",
|
|
321
|
+
"portable-atomic",
|
|
322
|
+
"pyo3-build-config",
|
|
323
|
+
"pyo3-ffi",
|
|
324
|
+
"pyo3-macros",
|
|
325
|
+
]
|
|
326
|
+
|
|
327
|
+
[[package]]
|
|
328
|
+
name = "pyo3-build-config"
|
|
329
|
+
version = "0.30.1"
|
|
330
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
331
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
332
|
+
dependencies = [
|
|
333
|
+
"target-lexicon",
|
|
334
|
+
]
|
|
335
|
+
|
|
336
|
+
[[package]]
|
|
337
|
+
name = "pyo3-ffi"
|
|
338
|
+
version = "0.30.1"
|
|
339
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
340
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
341
|
+
dependencies = [
|
|
342
|
+
"libc",
|
|
343
|
+
"pyo3-build-config",
|
|
344
|
+
]
|
|
345
|
+
|
|
346
|
+
[[package]]
|
|
347
|
+
name = "pyo3-macros"
|
|
348
|
+
version = "0.30.1"
|
|
349
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
350
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
351
|
+
dependencies = [
|
|
352
|
+
"proc-macro2",
|
|
353
|
+
"pyo3-macros-backend",
|
|
354
|
+
"quote",
|
|
355
|
+
"syn 3.0.10",
|
|
356
|
+
]
|
|
357
|
+
|
|
358
|
+
[[package]]
|
|
359
|
+
name = "pyo3-macros-backend"
|
|
360
|
+
version = "0.30.1"
|
|
361
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
362
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
363
|
+
dependencies = [
|
|
364
|
+
"heck",
|
|
365
|
+
"proc-macro2",
|
|
366
|
+
"quote",
|
|
367
|
+
"syn 3.0.10",
|
|
368
|
+
]
|
|
369
|
+
|
|
370
|
+
[[package]]
|
|
371
|
+
name = "quote"
|
|
372
|
+
version = "1.0.47"
|
|
373
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
374
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
375
|
+
dependencies = [
|
|
376
|
+
"proc-macro2",
|
|
377
|
+
]
|
|
378
|
+
|
|
379
|
+
[[package]]
|
|
380
|
+
name = "r-efi"
|
|
381
|
+
version = "5.3.0"
|
|
382
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
383
|
+
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
|
384
|
+
|
|
385
|
+
[[package]]
|
|
386
|
+
name = "rand"
|
|
387
|
+
version = "0.9.5"
|
|
388
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
389
|
+
checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"
|
|
390
|
+
dependencies = [
|
|
391
|
+
"rand_chacha",
|
|
392
|
+
"rand_core 0.9.5",
|
|
393
|
+
]
|
|
394
|
+
|
|
395
|
+
[[package]]
|
|
396
|
+
name = "rand_chacha"
|
|
397
|
+
version = "0.9.0"
|
|
398
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
399
|
+
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
|
400
|
+
dependencies = [
|
|
401
|
+
"ppv-lite86",
|
|
402
|
+
"rand_core 0.9.5",
|
|
403
|
+
]
|
|
404
|
+
|
|
405
|
+
[[package]]
|
|
406
|
+
name = "rand_core"
|
|
407
|
+
version = "0.9.5"
|
|
408
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
409
|
+
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
|
|
410
|
+
dependencies = [
|
|
411
|
+
"getrandom",
|
|
412
|
+
]
|
|
413
|
+
|
|
414
|
+
[[package]]
|
|
415
|
+
name = "rand_core"
|
|
416
|
+
version = "0.10.1"
|
|
417
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
418
|
+
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
|
|
419
|
+
|
|
420
|
+
[[package]]
|
|
421
|
+
name = "rfc6979"
|
|
422
|
+
version = "0.6.0"
|
|
423
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
424
|
+
checksum = "b4a459cddafb3fe76b31fd8f1108007566c40301feb64dc7b54656eb7388172b"
|
|
425
|
+
dependencies = [
|
|
426
|
+
"crypto-bigint",
|
|
427
|
+
"hmac",
|
|
428
|
+
]
|
|
429
|
+
|
|
430
|
+
[[package]]
|
|
431
|
+
name = "safe-eth-native"
|
|
432
|
+
version = "0.1.0"
|
|
433
|
+
dependencies = [
|
|
434
|
+
"p256",
|
|
435
|
+
"pyo3",
|
|
436
|
+
"secp256k1",
|
|
437
|
+
"tiny-keccak",
|
|
438
|
+
]
|
|
439
|
+
|
|
440
|
+
[[package]]
|
|
441
|
+
name = "sec1"
|
|
442
|
+
version = "0.8.1"
|
|
443
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
444
|
+
checksum = "d56d437c2f19203ce5f7122e507831de96f3d2d4d3be5af44a0b0a09d8a80e4d"
|
|
445
|
+
dependencies = [
|
|
446
|
+
"base16ct",
|
|
447
|
+
"ctutils",
|
|
448
|
+
"der",
|
|
449
|
+
"hybrid-array",
|
|
450
|
+
"subtle",
|
|
451
|
+
"zeroize",
|
|
452
|
+
]
|
|
453
|
+
|
|
454
|
+
[[package]]
|
|
455
|
+
name = "secp256k1"
|
|
456
|
+
version = "0.33.1"
|
|
457
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
458
|
+
checksum = "d7f404a8dab7a7a5a631e741d8699aa9c8e1d689fc26ccf897c7187565490b69"
|
|
459
|
+
dependencies = [
|
|
460
|
+
"rand",
|
|
461
|
+
"secp256k1-sys",
|
|
462
|
+
]
|
|
463
|
+
|
|
464
|
+
[[package]]
|
|
465
|
+
name = "secp256k1-sys"
|
|
466
|
+
version = "0.14.1"
|
|
467
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
468
|
+
checksum = "f6b2992d4a3cd244539a7d5d0966aadbe5ca7fb868a5d7e38c29499b9e709bbd"
|
|
469
|
+
dependencies = [
|
|
470
|
+
"cc",
|
|
471
|
+
]
|
|
472
|
+
|
|
473
|
+
[[package]]
|
|
474
|
+
name = "sha2"
|
|
475
|
+
version = "0.11.1"
|
|
476
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
477
|
+
checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19"
|
|
478
|
+
dependencies = [
|
|
479
|
+
"cfg-if",
|
|
480
|
+
"cpufeatures",
|
|
481
|
+
"digest",
|
|
482
|
+
]
|
|
483
|
+
|
|
484
|
+
[[package]]
|
|
485
|
+
name = "shlex"
|
|
486
|
+
version = "2.0.1"
|
|
487
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
488
|
+
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
489
|
+
|
|
490
|
+
[[package]]
|
|
491
|
+
name = "signature"
|
|
492
|
+
version = "3.0.0"
|
|
493
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
494
|
+
checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5"
|
|
495
|
+
dependencies = [
|
|
496
|
+
"digest",
|
|
497
|
+
"rand_core 0.10.1",
|
|
498
|
+
]
|
|
499
|
+
|
|
500
|
+
[[package]]
|
|
501
|
+
name = "subtle"
|
|
502
|
+
version = "2.6.1"
|
|
503
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
504
|
+
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|
505
|
+
|
|
506
|
+
[[package]]
|
|
507
|
+
name = "syn"
|
|
508
|
+
version = "2.0.119"
|
|
509
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
510
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
511
|
+
dependencies = [
|
|
512
|
+
"proc-macro2",
|
|
513
|
+
"quote",
|
|
514
|
+
"unicode-ident",
|
|
515
|
+
]
|
|
516
|
+
|
|
517
|
+
[[package]]
|
|
518
|
+
name = "syn"
|
|
519
|
+
version = "3.0.10"
|
|
520
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
521
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
522
|
+
dependencies = [
|
|
523
|
+
"proc-macro2",
|
|
524
|
+
"quote",
|
|
525
|
+
"unicode-ident",
|
|
526
|
+
]
|
|
527
|
+
|
|
528
|
+
[[package]]
|
|
529
|
+
name = "target-lexicon"
|
|
530
|
+
version = "0.13.6"
|
|
531
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
532
|
+
checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
|
|
533
|
+
|
|
534
|
+
[[package]]
|
|
535
|
+
name = "tiny-keccak"
|
|
536
|
+
version = "2.0.2"
|
|
537
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
538
|
+
checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
|
|
539
|
+
dependencies = [
|
|
540
|
+
"crunchy",
|
|
541
|
+
]
|
|
542
|
+
|
|
543
|
+
[[package]]
|
|
544
|
+
name = "typenum"
|
|
545
|
+
version = "1.20.1"
|
|
546
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
547
|
+
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
|
548
|
+
|
|
549
|
+
[[package]]
|
|
550
|
+
name = "unicode-ident"
|
|
551
|
+
version = "1.0.27"
|
|
552
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
553
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
554
|
+
|
|
555
|
+
[[package]]
|
|
556
|
+
name = "wasip2"
|
|
557
|
+
version = "1.0.4+wasi-0.2.12"
|
|
558
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
559
|
+
checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"
|
|
560
|
+
dependencies = [
|
|
561
|
+
"wit-bindgen",
|
|
562
|
+
]
|
|
563
|
+
|
|
564
|
+
[[package]]
|
|
565
|
+
name = "wit-bindgen"
|
|
566
|
+
version = "0.57.1"
|
|
567
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
568
|
+
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
|
569
|
+
|
|
570
|
+
[[package]]
|
|
571
|
+
name = "wnaf"
|
|
572
|
+
version = "0.14.1"
|
|
573
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
574
|
+
checksum = "795ca18b3fdb5e62bf982199278341ddcf7ebf7d32e25e212ad05d496e95f6fa"
|
|
575
|
+
dependencies = [
|
|
576
|
+
"ff",
|
|
577
|
+
"group",
|
|
578
|
+
"hybrid-array",
|
|
579
|
+
"primefield",
|
|
580
|
+
]
|
|
581
|
+
|
|
582
|
+
[[package]]
|
|
583
|
+
name = "zerocopy"
|
|
584
|
+
version = "0.8.63"
|
|
585
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
586
|
+
checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8"
|
|
587
|
+
dependencies = [
|
|
588
|
+
"zerocopy-derive",
|
|
589
|
+
]
|
|
590
|
+
|
|
591
|
+
[[package]]
|
|
592
|
+
name = "zerocopy-derive"
|
|
593
|
+
version = "0.8.63"
|
|
594
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
595
|
+
checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f"
|
|
596
|
+
dependencies = [
|
|
597
|
+
"proc-macro2",
|
|
598
|
+
"quote",
|
|
599
|
+
"syn 2.0.119",
|
|
600
|
+
]
|
|
601
|
+
|
|
602
|
+
[[package]]
|
|
603
|
+
name = "zeroize"
|
|
604
|
+
version = "1.9.2"
|
|
605
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
606
|
+
checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "safe-eth-native"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
rust-version = "1.88"
|
|
6
|
+
description = "Native ecrecover, P-256 verify, keccak256 and EIP-55 checksum helpers for safe-eth-py"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
repository = "https://github.com/safe-global/safe-eth-py"
|
|
9
|
+
publish = false
|
|
10
|
+
include = ["/src", "/Cargo.toml", "/Cargo.lock", "/pyproject.toml", "/README.md", "/LICENSE", "/safe_eth_native.pyi"]
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
|
|
13
|
+
[lib]
|
|
14
|
+
name = "safe_eth_native"
|
|
15
|
+
crate-type = ["cdylib"]
|
|
16
|
+
|
|
17
|
+
[dependencies]
|
|
18
|
+
p256 = { version = "0.14.0", default-features = false, features = ["ecdsa", "arithmetic"] }
|
|
19
|
+
pyo3 = { version = "0.30.1", features = ["abi3-py311", "extension-module"] }
|
|
20
|
+
secp256k1 = { version = "0.33.1", default-features = false, features = ["recovery", "std"] }
|
|
21
|
+
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
|
|
22
|
+
|
|
23
|
+
[profile.release]
|
|
24
|
+
lto = "fat"
|
|
25
|
+
codegen-units = 1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Safe Ecosystem Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: safe-eth-native
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Intended Audience :: Developers
|
|
5
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
11
|
+
Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
|
|
12
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
13
|
+
Classifier: Programming Language :: Rust
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Summary: Native ecrecover, P-256 verify, keccak256 and EIP-55 checksum helpers for safe-eth-py
|
|
16
|
+
Author-email: Uxío <uxio@safe.global>
|
|
17
|
+
License-Expression: MIT
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
20
|
+
Project-URL: Homepage, https://github.com/safe-global/safe-eth-py
|
|
21
|
+
Project-URL: Source, https://github.com/safe-global/safe-eth-py/tree/main/native
|
|
22
|
+
Project-URL: Tracker, https://github.com/safe-global/safe-eth-py/issues
|
|
23
|
+
|
|
24
|
+
# safe-eth-native
|
|
25
|
+
|
|
26
|
+
Native (Rust) versions of the hot paths of [safe-eth-py](https://github.com/safe-global/safe-eth-py):
|
|
27
|
+
|
|
28
|
+
| Function | Replaces | Backed by |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| `ecrecover(message_hash, v, r, s) -> bytes \| None` | eth-keys `ecdsa_recover` | [libsecp256k1](https://github.com/bitcoin-core/secp256k1) |
|
|
31
|
+
| `p256_verify(message_hash, r, s, public_key_x, public_key_y) -> bool` | `safe_eth.safe.p256.verify` | RustCrypto [`p256`](https://github.com/RustCrypto/elliptic-curves) |
|
|
32
|
+
| `keccak256(data) -> bytes` | pysha3 `keccak_256` | [`tiny-keccak`](https://github.com/debris/tiny-keccak) |
|
|
33
|
+
| `to_checksum_address(value) -> str` | `fast_to_checksum_address` | |
|
|
34
|
+
| `is_checksum_address(value) -> bool` | `fast_is_checksum_address` | |
|
|
35
|
+
|
|
36
|
+
`ecrecover` and `p256_verify` follow the input rules of the EVM `ecrecover` and `P256VERIFY`
|
|
37
|
+
precompiles: `v` must be 27 or 28, `r` and `s` in `[1, n - 1]`, and high `s` values are
|
|
38
|
+
accepted. Values out of those ranges return `None` / `False` instead of raising; only a
|
|
39
|
+
wrong type, or a hash that is not 32 bytes for `ecrecover`, raises. Both release the GIL
|
|
40
|
+
while they run, and so does `keccak256` for inputs of 2048 bytes or more.
|
|
41
|
+
|
|
42
|
+
The package is not meant to be used directly. Install it with the `native` extra of
|
|
43
|
+
safe-eth-py, which uses it when it is installed and falls back to the Python code when it is
|
|
44
|
+
not:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install "safe-eth-py[native]"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Wheels
|
|
51
|
+
|
|
52
|
+
Platforms: Linux (glibc 2.28+ and musl) x86_64 and aarch64, macOS x86_64 and arm64, and
|
|
53
|
+
Windows x86_64. For each one:
|
|
54
|
+
|
|
55
|
+
- One `abi3` wheel for CPython 3.11 and newer, 3.15 included
|
|
56
|
+
- One wheel per free-threaded CPython version, 3.14t and 3.15t, as `abi3` wheels do not load
|
|
57
|
+
on free-threaded builds. The module runs without the GIL: importing it does not enable the
|
|
58
|
+
GIL again
|
|
59
|
+
|
|
60
|
+
Other platforms and Python versions build from the sdist, which needs a Rust toolchain and a
|
|
61
|
+
C compiler.
|
|
62
|
+
|
|
63
|
+
## Development
|
|
64
|
+
|
|
65
|
+
From the root of the safe-eth-py repository, `uv sync --group dev --all-extras --frozen` builds the
|
|
66
|
+
extension and installs it in the safe-eth-py environment, and `pytest native/tests` runs
|
|
67
|
+
its tests. uv rebuilds it when a file in `src/` changes.
|
|
68
|
+
|
|
69
|
+
The tests compare every function with reference implementations (eth-keys, eth-utils,
|
|
70
|
+
pycryptodome, and pysha3 in the safe-eth-py tests) and run the vectors of the Keccak team,
|
|
71
|
+
Wycheproof, EIP-55, and the test suites of go-ethereum, eth-keys, eth-utils, coincurve and
|
|
72
|
+
libsecp256k1. See
|
|
73
|
+
[`tests/vectors`](https://github.com/safe-global/safe-eth-py/blob/main/native/tests/vectors/README.md)
|
|
74
|
+
for their sources. CI runs them on every wheel except the musl ones, which are built but not
|
|
75
|
+
tested.
|
|
76
|
+
|
|
77
|
+
## Releasing
|
|
78
|
+
|
|
79
|
+
Bump `version` in `Cargo.toml`, then push a `native-v<version>` tag on a commit of `main`. Push
|
|
80
|
+
only the tag: a GitHub release would also run the safe-eth-py release workflow, for nothing.
|
|
81
|
+
The `Native extension` workflow builds the wheels and the sdist and publishes them to PyPI with
|
|
82
|
+
trusted publishing. Before the first release, add a trusted publisher (a pending one while the
|
|
83
|
+
project does not exist) on PyPI for `safe-global/safe-eth-py` and the `native.yml` workflow.
|
|
84
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# safe-eth-native
|
|
2
|
+
|
|
3
|
+
Native (Rust) versions of the hot paths of [safe-eth-py](https://github.com/safe-global/safe-eth-py):
|
|
4
|
+
|
|
5
|
+
| Function | Replaces | Backed by |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| `ecrecover(message_hash, v, r, s) -> bytes \| None` | eth-keys `ecdsa_recover` | [libsecp256k1](https://github.com/bitcoin-core/secp256k1) |
|
|
8
|
+
| `p256_verify(message_hash, r, s, public_key_x, public_key_y) -> bool` | `safe_eth.safe.p256.verify` | RustCrypto [`p256`](https://github.com/RustCrypto/elliptic-curves) |
|
|
9
|
+
| `keccak256(data) -> bytes` | pysha3 `keccak_256` | [`tiny-keccak`](https://github.com/debris/tiny-keccak) |
|
|
10
|
+
| `to_checksum_address(value) -> str` | `fast_to_checksum_address` | |
|
|
11
|
+
| `is_checksum_address(value) -> bool` | `fast_is_checksum_address` | |
|
|
12
|
+
|
|
13
|
+
`ecrecover` and `p256_verify` follow the input rules of the EVM `ecrecover` and `P256VERIFY`
|
|
14
|
+
precompiles: `v` must be 27 or 28, `r` and `s` in `[1, n - 1]`, and high `s` values are
|
|
15
|
+
accepted. Values out of those ranges return `None` / `False` instead of raising; only a
|
|
16
|
+
wrong type, or a hash that is not 32 bytes for `ecrecover`, raises. Both release the GIL
|
|
17
|
+
while they run, and so does `keccak256` for inputs of 2048 bytes or more.
|
|
18
|
+
|
|
19
|
+
The package is not meant to be used directly. Install it with the `native` extra of
|
|
20
|
+
safe-eth-py, which uses it when it is installed and falls back to the Python code when it is
|
|
21
|
+
not:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install "safe-eth-py[native]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Wheels
|
|
28
|
+
|
|
29
|
+
Platforms: Linux (glibc 2.28+ and musl) x86_64 and aarch64, macOS x86_64 and arm64, and
|
|
30
|
+
Windows x86_64. For each one:
|
|
31
|
+
|
|
32
|
+
- One `abi3` wheel for CPython 3.11 and newer, 3.15 included
|
|
33
|
+
- One wheel per free-threaded CPython version, 3.14t and 3.15t, as `abi3` wheels do not load
|
|
34
|
+
on free-threaded builds. The module runs without the GIL: importing it does not enable the
|
|
35
|
+
GIL again
|
|
36
|
+
|
|
37
|
+
Other platforms and Python versions build from the sdist, which needs a Rust toolchain and a
|
|
38
|
+
C compiler.
|
|
39
|
+
|
|
40
|
+
## Development
|
|
41
|
+
|
|
42
|
+
From the root of the safe-eth-py repository, `uv sync --group dev --all-extras --frozen` builds the
|
|
43
|
+
extension and installs it in the safe-eth-py environment, and `pytest native/tests` runs
|
|
44
|
+
its tests. uv rebuilds it when a file in `src/` changes.
|
|
45
|
+
|
|
46
|
+
The tests compare every function with reference implementations (eth-keys, eth-utils,
|
|
47
|
+
pycryptodome, and pysha3 in the safe-eth-py tests) and run the vectors of the Keccak team,
|
|
48
|
+
Wycheproof, EIP-55, and the test suites of go-ethereum, eth-keys, eth-utils, coincurve and
|
|
49
|
+
libsecp256k1. See
|
|
50
|
+
[`tests/vectors`](https://github.com/safe-global/safe-eth-py/blob/main/native/tests/vectors/README.md)
|
|
51
|
+
for their sources. CI runs them on every wheel except the musl ones, which are built but not
|
|
52
|
+
tested.
|
|
53
|
+
|
|
54
|
+
## Releasing
|
|
55
|
+
|
|
56
|
+
Bump `version` in `Cargo.toml`, then push a `native-v<version>` tag on a commit of `main`. Push
|
|
57
|
+
only the tag: a GitHub release would also run the safe-eth-py release workflow, for nothing.
|
|
58
|
+
The `Native extension` workflow builds the wheels and the sdist and publishes them to PyPI with
|
|
59
|
+
trusted publishing. Before the first release, add a trusted publisher (a pending one while the
|
|
60
|
+
project does not exist) on PyPI for `safe-global/safe-eth-py` and the `native.yml` workflow.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.9,<2"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "safe-eth-native"
|
|
7
|
+
dynamic = ["version", "description"]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Uxío", email = "uxio@safe.global" },
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Programming Language :: Python :: 3.15",
|
|
22
|
+
"Programming Language :: Python :: Free Threading :: 3 - Stable",
|
|
23
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
24
|
+
"Programming Language :: Rust",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/safe-global/safe-eth-py"
|
|
29
|
+
Source = "https://github.com/safe-global/safe-eth-py/tree/main/native"
|
|
30
|
+
Tracker = "https://github.com/safe-global/safe-eth-py/issues"
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
# Reference implementations the tests compare against. They have no C extension that
|
|
34
|
+
# turns the GIL back on, and pycryptodome builds from source where it has no wheel (3.14t)
|
|
35
|
+
test = [
|
|
36
|
+
"eth-keys",
|
|
37
|
+
"eth-utils",
|
|
38
|
+
"pycryptodome",
|
|
39
|
+
"pytest",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[tool.uv]
|
|
43
|
+
# Rebuild the extension when the Rust code changes, not only pyproject.toml
|
|
44
|
+
cache-keys = [
|
|
45
|
+
{ file = "pyproject.toml" },
|
|
46
|
+
{ file = "Cargo.toml" },
|
|
47
|
+
{ file = "Cargo.lock" },
|
|
48
|
+
{ file = "src/**/*.rs" },
|
|
49
|
+
]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
def ecrecover(message_hash: bytes, v: int, r: int, s: int) -> bytes | None: ...
|
|
2
|
+
def p256_verify(
|
|
3
|
+
message_hash: int, r: int, s: int, public_key_x: int, public_key_y: int
|
|
4
|
+
) -> bool: ...
|
|
5
|
+
def keccak256(data: bytes | bytearray | memoryview) -> bytes: ...
|
|
6
|
+
def to_checksum_address(value: str | bytes) -> str: ...
|
|
7
|
+
def is_checksum_address(value: object) -> bool: ...
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
use pyo3::buffer::PyBuffer;
|
|
2
|
+
use pyo3::exceptions::{PyTypeError, PyValueError};
|
|
3
|
+
use pyo3::prelude::*;
|
|
4
|
+
use pyo3::types::{PyBytes, PyInt, PyString};
|
|
5
|
+
use secp256k1::Message;
|
|
6
|
+
use secp256k1::ecdsa::{RecoverableSignature, RecoveryId};
|
|
7
|
+
use tiny_keccak::{Hasher, Keccak};
|
|
8
|
+
|
|
9
|
+
const ADDRESS_LENGTH: usize = 20;
|
|
10
|
+
const HEX_ADDRESS_LENGTH: usize = 40;
|
|
11
|
+
/// Same threshold as `hashlib` and pysha3: smaller inputs hash faster than the cost of
|
|
12
|
+
/// releasing and taking back the GIL
|
|
13
|
+
const KECCAK_RELEASE_GIL_MIN_LENGTH: usize = 2048;
|
|
14
|
+
|
|
15
|
+
fn keccak256_digest(data: &[u8]) -> [u8; 32] {
|
|
16
|
+
let mut hasher = Keccak::v256();
|
|
17
|
+
let mut digest = [0u8; 32];
|
|
18
|
+
hasher.update(data);
|
|
19
|
+
hasher.finalize(&mut digest);
|
|
20
|
+
digest
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// Python int to 32 bytes big endian. `None` if it is negative or does not fit.
|
|
24
|
+
fn int_to_be_bytes32(value: &Bound<'_, PyInt>) -> Option<[u8; 32]> {
|
|
25
|
+
// `int.to_bytes(value, ...)`, so an `int` subclass cannot change the conversion
|
|
26
|
+
let be_bytes_object = value
|
|
27
|
+
.py()
|
|
28
|
+
.get_type::<PyInt>()
|
|
29
|
+
.call_method1("to_bytes", (value, 32, "big"))
|
|
30
|
+
.ok()?;
|
|
31
|
+
let be_bytes = be_bytes_object.cast::<PyBytes>().ok()?;
|
|
32
|
+
be_bytes.as_bytes().try_into().ok()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// Ethereum `v` (27 or 28) to the recovery id (y parity of the `R` point)
|
|
36
|
+
fn recovery_id_from_v(v: &Bound<'_, PyInt>) -> Option<RecoveryId> {
|
|
37
|
+
match v.extract::<u64>().ok()? {
|
|
38
|
+
27 => Some(RecoveryId::Zero),
|
|
39
|
+
28 => Some(RecoveryId::One),
|
|
40
|
+
_ => None,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fn recover_address(
|
|
45
|
+
message_hash: &[u8; 32],
|
|
46
|
+
recovery_id: RecoveryId,
|
|
47
|
+
r: &[u8; 32],
|
|
48
|
+
s: &[u8; 32],
|
|
49
|
+
) -> Option<[u8; ADDRESS_LENGTH]> {
|
|
50
|
+
let mut compact_signature = [0u8; 64];
|
|
51
|
+
compact_signature[..32].copy_from_slice(r);
|
|
52
|
+
compact_signature[32..].copy_from_slice(s);
|
|
53
|
+
let signature = RecoverableSignature::from_compact(&compact_signature, recovery_id).ok()?;
|
|
54
|
+
let public_key = signature
|
|
55
|
+
.recover_ecdsa(Message::from_digest(*message_hash))
|
|
56
|
+
.ok()?;
|
|
57
|
+
let digest = keccak256_digest(&public_key.serialize_uncompressed()[1..]);
|
|
58
|
+
let mut address = [0u8; ADDRESS_LENGTH];
|
|
59
|
+
address.copy_from_slice(&digest[32 - ADDRESS_LENGTH..]);
|
|
60
|
+
Some(address)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// Recover the signer address of an Ethereum ECDSA signature over a 32 bytes hash,
|
|
64
|
+
/// with the input rules of the EVM `ecrecover` precompile: `v` must be 27 or 28,
|
|
65
|
+
/// `r` and `s` in `[1, n - 1]`, and high `s` values are accepted.
|
|
66
|
+
///
|
|
67
|
+
/// Returns the 20 bytes address, or `None` if no address can be recovered.
|
|
68
|
+
/// Raises `ValueError` if `message_hash` is not 32 bytes.
|
|
69
|
+
#[pyfunction]
|
|
70
|
+
fn ecrecover<'py>(
|
|
71
|
+
py: Python<'py>,
|
|
72
|
+
message_hash: &[u8],
|
|
73
|
+
v: &Bound<'py, PyInt>,
|
|
74
|
+
r: &Bound<'py, PyInt>,
|
|
75
|
+
s: &Bound<'py, PyInt>,
|
|
76
|
+
) -> PyResult<Option<Bound<'py, PyBytes>>> {
|
|
77
|
+
let message_hash: [u8; 32] = message_hash
|
|
78
|
+
.try_into()
|
|
79
|
+
.map_err(|_| PyValueError::new_err("message_hash must be 32 bytes"))?;
|
|
80
|
+
let (Some(recovery_id), Some(r), Some(s)) = (
|
|
81
|
+
recovery_id_from_v(v),
|
|
82
|
+
int_to_be_bytes32(r),
|
|
83
|
+
int_to_be_bytes32(s),
|
|
84
|
+
) else {
|
|
85
|
+
return Ok(None);
|
|
86
|
+
};
|
|
87
|
+
let address = py.detach(|| recover_address(&message_hash, recovery_id, &r, &s));
|
|
88
|
+
Ok(address.map(|address| PyBytes::new(py, &address)))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fn verify_p256(
|
|
92
|
+
message_hash: &[u8; 32],
|
|
93
|
+
r: &[u8; 32],
|
|
94
|
+
s: &[u8; 32],
|
|
95
|
+
public_key_x: &[u8; 32],
|
|
96
|
+
public_key_y: &[u8; 32],
|
|
97
|
+
) -> bool {
|
|
98
|
+
use p256::ecdsa::signature::hazmat::PrehashVerifier;
|
|
99
|
+
use p256::ecdsa::{Signature, VerifyingKey};
|
|
100
|
+
|
|
101
|
+
let Ok(signature) = Signature::from_scalars(*r, *s) else {
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
let mut uncompressed_public_key = [0u8; 65];
|
|
105
|
+
uncompressed_public_key[0] = 0x04;
|
|
106
|
+
uncompressed_public_key[1..33].copy_from_slice(public_key_x);
|
|
107
|
+
uncompressed_public_key[33..].copy_from_slice(public_key_y);
|
|
108
|
+
let Ok(verifying_key) = VerifyingKey::from_sec1_bytes(&uncompressed_public_key) else {
|
|
109
|
+
return false;
|
|
110
|
+
};
|
|
111
|
+
verifying_key
|
|
112
|
+
.verify_prehash(message_hash, &signature)
|
|
113
|
+
.is_ok()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/// Verify a `secp256r1` (P-256) ECDSA signature over a 32 bytes digest, with the rules of
|
|
117
|
+
/// the RIP-7212 / EIP-7951 `P256VERIFY` precompile: `r` and `s` in `[1, n - 1]`, the public
|
|
118
|
+
/// key a point on the curve, and high `s` values accepted.
|
|
119
|
+
///
|
|
120
|
+
/// Returns `False` for any value out of range, and raises `TypeError` if a value is not an `int`.
|
|
121
|
+
#[pyfunction]
|
|
122
|
+
fn p256_verify(
|
|
123
|
+
py: Python<'_>,
|
|
124
|
+
message_hash: &Bound<'_, PyInt>,
|
|
125
|
+
r: &Bound<'_, PyInt>,
|
|
126
|
+
s: &Bound<'_, PyInt>,
|
|
127
|
+
public_key_x: &Bound<'_, PyInt>,
|
|
128
|
+
public_key_y: &Bound<'_, PyInt>,
|
|
129
|
+
) -> bool {
|
|
130
|
+
let (Some(message_hash), Some(r), Some(s), Some(public_key_x), Some(public_key_y)) = (
|
|
131
|
+
int_to_be_bytes32(message_hash),
|
|
132
|
+
int_to_be_bytes32(r),
|
|
133
|
+
int_to_be_bytes32(s),
|
|
134
|
+
int_to_be_bytes32(public_key_x),
|
|
135
|
+
int_to_be_bytes32(public_key_y),
|
|
136
|
+
) else {
|
|
137
|
+
return false;
|
|
138
|
+
};
|
|
139
|
+
py.detach(|| verify_p256(&message_hash, &r, &s, &public_key_x, &public_key_y))
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
fn keccak256_digest_releasing_gil(py: Python<'_>, data: &[u8]) -> [u8; 32] {
|
|
143
|
+
if data.len() >= KECCAK_RELEASE_GIL_MIN_LENGTH {
|
|
144
|
+
py.detach(|| keccak256_digest(data))
|
|
145
|
+
} else {
|
|
146
|
+
keccak256_digest(data)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// Keccak-256 digest (Ethereum flavour, not NIST SHA3-256) of `bytes`, `bytearray`, or any
|
|
151
|
+
/// other buffer of unsigned bytes like a `memoryview` of them.
|
|
152
|
+
///
|
|
153
|
+
/// Raises `TypeError` for any other value.
|
|
154
|
+
#[pyfunction]
|
|
155
|
+
fn keccak256<'py>(py: Python<'py>, data: &Bound<'py, PyAny>) -> PyResult<Bound<'py, PyBytes>> {
|
|
156
|
+
if let Ok(data_bytes) = data.cast::<PyBytes>() {
|
|
157
|
+
let digest = keccak256_digest_releasing_gil(py, data_bytes.as_bytes());
|
|
158
|
+
return Ok(PyBytes::new(py, &digest));
|
|
159
|
+
}
|
|
160
|
+
// Other threads can write to a mutable buffer while it is hashed, so it is copied first
|
|
161
|
+
let buffer = PyBuffer::<u8>::get(data).map_err(|_| {
|
|
162
|
+
PyTypeError::new_err("Expected bytes, bytearray or another buffer of unsigned bytes")
|
|
163
|
+
})?;
|
|
164
|
+
let data_copy = buffer.to_vec(py)?;
|
|
165
|
+
let digest = keccak256_digest_releasing_gil(py, &data_copy);
|
|
166
|
+
Ok(PyBytes::new(py, &digest))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/// Lowercase hex of the address, without `0x`. `None` if `address_bytes` is not 20 bytes.
|
|
170
|
+
fn lowercase_hex_from_bytes(address_bytes: &[u8]) -> Option<[u8; HEX_ADDRESS_LENGTH]> {
|
|
171
|
+
const HEX_DIGITS: &[u8; 16] = b"0123456789abcdef";
|
|
172
|
+
if address_bytes.len() != ADDRESS_LENGTH {
|
|
173
|
+
return None;
|
|
174
|
+
}
|
|
175
|
+
let mut lowercase_hex = [0u8; HEX_ADDRESS_LENGTH];
|
|
176
|
+
for (index, byte) in address_bytes.iter().enumerate() {
|
|
177
|
+
lowercase_hex[index * 2] = HEX_DIGITS[(byte >> 4) as usize];
|
|
178
|
+
lowercase_hex[index * 2 + 1] = HEX_DIGITS[(byte & 0x0f) as usize];
|
|
179
|
+
}
|
|
180
|
+
Some(lowercase_hex)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/// Lowercase hex of the address, without `0x`. `None` if `address_text` is not 40 ASCII hex
|
|
184
|
+
/// characters in any case, with an optional `0x`/`0X` prefix.
|
|
185
|
+
fn lowercase_hex_from_text(address_text: &str) -> Option<[u8; HEX_ADDRESS_LENGTH]> {
|
|
186
|
+
let hex_digits = address_text
|
|
187
|
+
.strip_prefix("0x")
|
|
188
|
+
.or_else(|| address_text.strip_prefix("0X"))
|
|
189
|
+
.unwrap_or(address_text)
|
|
190
|
+
.as_bytes();
|
|
191
|
+
if hex_digits.len() != HEX_ADDRESS_LENGTH {
|
|
192
|
+
return None;
|
|
193
|
+
}
|
|
194
|
+
let mut lowercase_hex = [0u8; HEX_ADDRESS_LENGTH];
|
|
195
|
+
for (index, character) in hex_digits.iter().enumerate() {
|
|
196
|
+
if !character.is_ascii_hexdigit() {
|
|
197
|
+
return None;
|
|
198
|
+
}
|
|
199
|
+
lowercase_hex[index] = character.to_ascii_lowercase();
|
|
200
|
+
}
|
|
201
|
+
Some(lowercase_hex)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/// EIP-55 checksum of a lowercase hex address, `0x` prefixed.
|
|
205
|
+
fn checksum_from_lowercase_hex(lowercase_hex: &[u8; HEX_ADDRESS_LENGTH]) -> [u8; 42] {
|
|
206
|
+
let address_hash = keccak256_digest(lowercase_hex);
|
|
207
|
+
let mut checksum_address = [0u8; 42];
|
|
208
|
+
checksum_address[0] = b'0';
|
|
209
|
+
checksum_address[1] = b'x';
|
|
210
|
+
for (index, character) in lowercase_hex.iter().enumerate() {
|
|
211
|
+
let hash_nibble = if index % 2 == 0 {
|
|
212
|
+
address_hash[index / 2] >> 4
|
|
213
|
+
} else {
|
|
214
|
+
address_hash[index / 2] & 0x0f
|
|
215
|
+
};
|
|
216
|
+
checksum_address[index + 2] = if hash_nibble > 7 {
|
|
217
|
+
character.to_ascii_uppercase()
|
|
218
|
+
} else {
|
|
219
|
+
*character
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
checksum_address
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/// EIP-55 checksum address from 20 bytes, or from 40 hex characters in any case with an
|
|
226
|
+
/// optional `0x`/`0X` prefix.
|
|
227
|
+
///
|
|
228
|
+
/// Raises `ValueError` if `value` is not an address, and `TypeError` if it is not `bytes`
|
|
229
|
+
/// or `str`.
|
|
230
|
+
#[pyfunction]
|
|
231
|
+
fn to_checksum_address<'py>(
|
|
232
|
+
py: Python<'py>,
|
|
233
|
+
value: &Bound<'py, PyAny>,
|
|
234
|
+
) -> PyResult<Bound<'py, PyString>> {
|
|
235
|
+
let lowercase_hex = if let Ok(address_bytes) = value.cast::<PyBytes>() {
|
|
236
|
+
lowercase_hex_from_bytes(address_bytes.as_bytes())
|
|
237
|
+
} else if let Ok(address_text) = value.cast::<PyString>() {
|
|
238
|
+
address_text.to_str().ok().and_then(lowercase_hex_from_text)
|
|
239
|
+
} else {
|
|
240
|
+
return Err(PyTypeError::new_err("Expected bytes or str"));
|
|
241
|
+
}
|
|
242
|
+
.ok_or_else(|| PyValueError::new_err("Expected 20 bytes or a 40 characters hex address"))?;
|
|
243
|
+
let checksum_address = checksum_from_lowercase_hex(&lowercase_hex);
|
|
244
|
+
// Only ASCII hex digits and `0x` are written above
|
|
245
|
+
let checksum_text = std::str::from_utf8(&checksum_address).expect("ASCII address");
|
|
246
|
+
Ok(PyString::new(py, checksum_text))
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/// `True` if `value` is a `0x` prefixed EIP-55 checksum address. `False` for any other
|
|
250
|
+
/// value, including other types.
|
|
251
|
+
#[pyfunction]
|
|
252
|
+
fn is_checksum_address(value: &Bound<'_, PyAny>) -> bool {
|
|
253
|
+
let Some(address_text) = value
|
|
254
|
+
.cast::<PyString>()
|
|
255
|
+
.ok()
|
|
256
|
+
.and_then(|address_text| address_text.to_str().ok())
|
|
257
|
+
else {
|
|
258
|
+
return false;
|
|
259
|
+
};
|
|
260
|
+
address_text.starts_with("0x")
|
|
261
|
+
&& lowercase_hex_from_text(address_text).is_some_and(|lowercase_hex| {
|
|
262
|
+
checksum_from_lowercase_hex(&lowercase_hex) == address_text.as_bytes()
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// No shared mutable state, so the module runs on free-threaded Python without the GIL
|
|
267
|
+
#[pymodule(gil_used = false)]
|
|
268
|
+
fn safe_eth_native(module: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
269
|
+
module.add_function(wrap_pyfunction!(ecrecover, module)?)?;
|
|
270
|
+
module.add_function(wrap_pyfunction!(p256_verify, module)?)?;
|
|
271
|
+
module.add_function(wrap_pyfunction!(keccak256, module)?)?;
|
|
272
|
+
module.add_function(wrap_pyfunction!(to_checksum_address, module)?)?;
|
|
273
|
+
module.add_function(wrap_pyfunction!(is_checksum_address, module)?)?;
|
|
274
|
+
Ok(())
|
|
275
|
+
}
|