-
Notifications
You must be signed in to change notification settings - Fork 3
/
sig.py
35 lines (31 loc) · 881 Bytes
/
sig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from py_eth_sig_utils import utils
from py_eth_sig_utils.signing import recover_typed_data, signature_to_v_r_s
data = {
"types": {
"EIP712Domain": [
{ "name": 'name', "type": 'string' },
{ "name": 'version', "type": 'string' },
{ "name": 'chainId', "type": 'uint256' },
],
"Message": [
{ "name": 'content', "type": 'string' }
]
},
"primaryType": 'Message',
"domain": {
"name": 'DwebLab Alpha',
"version": '1',
"chainId": 80001,
},
"message": {
"content": 'Sign this msg to login',
},
}
def recover_address(signature):
try:
signer_address = recover_typed_data(data, *signature_to_v_r_s(bytes.fromhex(signature)))
except Exception as e:
print(signature)
print(e)
return ''
return signer_address