DILSHAD737 commited on
Commit
22aa86c
·
1 Parent(s): d5d7e15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -54
app.py CHANGED
@@ -1,55 +1,2 @@
1
- # debug_which.py
2
- from mnemonic import Mnemonic
3
- from eth_account import Account
4
- from eth_utils import keccak, to_checksum_address
5
- import coincurve, hmac, hashlib
6
-
7
- Account.enable_unaudited_hdwallet_features()
8
- phrase = "lesson cushion crane affair federal decline limb spend reunion chief cart zebra"
9
- TARGET = "0x3f0482fc3e9132c3d3acb5f588e980d7b3a5af07"
10
-
11
- # --- Manual BIP32 (aapke code se) ---
12
- _N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
13
- _H = 0x80000000
14
- def _child(priv, chain, i):
15
- if i >= _H:
16
- data = b'\x00' + priv + i.to_bytes(4, 'big')
17
- else:
18
- pub = coincurve.PrivateKey(priv).public_key.format(compressed=True)
19
- data = pub + i.to_bytes(4, 'big')
20
- I = hmac.new(chain, data, hashlib.sha512).digest()
21
- ki = (int.from_bytes(I[:32], 'big') + int.from_bytes(priv, 'big')) % _N
22
- return ki.to_bytes(32, 'big'), I[32:]
23
-
24
- def seed_to_privkey_hd(seed, idx=0):
25
- I = hmac.new(b"Bitcoin seed", seed, hashlib.sha512).digest()
26
- key, chain = I[:32], I[32:]
27
- for i in [44+_H, 60+_H, _H, 0, idx]:
28
- key, chain = _child(key, chain, i)
29
- return key
30
-
31
- # --- Test 1: Python mnemonic seed + manual BIP32 ---
32
- seed_py = Mnemonic("english").to_seed(phrase, "")
33
- priv_py = seed_to_privkey_hd(seed_py, 0)
34
- pub = coincurve.PrivateKey(priv_py).public_key.format(compressed=False)[1:]
35
- addr_manual = to_checksum_address(keccak(pub)[-20:])
36
-
37
- # --- Test 2: bip39 (Rust/Python) seed + manual BIP32 ---
38
  import bip39
39
- seed_rust = bip39.phrase_to_seed(phrase, "")
40
- priv_rust = seed_to_privkey_hd(seed_rust, 0)
41
- pub2 = coincurve.PrivateKey(priv_rust).public_key.format(compressed=False)[1:]
42
- addr_rust = to_checksum_address(keccak(pub2)[-20:])
43
-
44
- # --- Test 3: eth_account ---
45
- acct = Account.from_mnemonic(phrase, account_path="m/44'/60'/0'/0/0")
46
-
47
- print(f"Manual(Python seed): {addr_manual}")
48
- print(f"Manual(Rust seed): {addr_rust}")
49
- print(f"eth_account: {acct.address}")
50
- print(f"Target: {TARGET}")
51
- print()
52
- print(f"Manual(Python) == Target: {addr_manual.lower() == TARGET}")
53
- print(f"Manual(Rust) == Target: {addr_rust.lower() == TARGET}")
54
- print(f"eth_account == Target: {acct.address.lower() == TARGET}")
55
- print(f"Manual(Python) == eth_account: {addr_manual.lower() == acct.address.lower()}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import bip39
2
+ print(dir(bip39))