Skip to content

Commit 9633b83

Browse files
committed
Paper wallet support requires eth-account, scrypt and pycryptodome
1 parent 6ca08e9 commit 9633b83

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

requirements-wallet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
eth-account >=0.6.0, <1
22
scrypt >=0.8.17
3+
pycryptodome >=3.10.1

slip39/api.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
import re
99
import secrets
1010

11-
from Crypto.Cipher import AES
1211
from collections import namedtuple
1312
from typing import Dict, List, Sequence, Tuple, Union, Callable
1413

1514
from shamir_mnemonic import generate_mnemonics
1615

1716
import hdwallet
17+
18+
# Support for private key encryption via BIP-38 and Ethereum JSON wallet is optional; pip install slip39[wallet]
19+
try:
20+
from Crypto.Cipher import AES
21+
except ImportError:
22+
AES = None
1823
try:
1924
import scrypt
2025
except ImportError:
@@ -245,7 +250,7 @@ def from_encrypted( self, encrypted_privkey, passphrase, strict=True ):
245250

246251
def bip38( self, passphrase, flagbyte=b'\xe0' ):
247252
"""BIP-38 encrypt the private key"""
248-
if not scrypt:
253+
if not scrypt or not AES:
249254
raise NotImplementedError( "The scrypt module is required to support BIP-38 encryption; pip install slip39[wallet]" )
250255
if self.crypto not in self.BIP38_ENCRYPT:
251256
raise NotImplementedError( f"{self.crypto} does not support BIP-38 private key encryption" )
@@ -267,7 +272,7 @@ def bip38( self, passphrase, flagbyte=b'\xe0' ):
267272

268273
def from_bip38( self, encrypted_privkey, passphrase, strict=True ):
269274
"""Bip-38 decrypt and import the private key."""
270-
if not scrypt:
275+
if not scrypt or not AES:
271276
raise NotImplementedError( "The scrypt module is required to support BIP-38 decryption; pip install slip39[wallet]" )
272277
if self.crypto not in self.BIP38_ENCRYPT:
273278
raise NotImplementedError( f"{self.crypto} does not support BIP-38 private key decryption" )

0 commit comments

Comments
 (0)