python-slip39 icon indicating copy to clipboard operation
python-slip39 copied to clipboard

API does not support single-share slip39 menmonic

Open onvej-sl opened this issue 1 year ago • 0 comments

This function incorrectly assumes that slip39 backups consists of at least two shares.

This can lead to "Invalid mnemonic words." exception. You can test it using the following test:

def test_slip39_compatibility():
    """Test that SLIP-39 backup of a wallet generated by Trezor can be recevered"""
    # The 1th vector from https://github.com/trezor/python-shamir-mnemonic/blob/master/vectors.json
    mnemonics = [
        "duckling enlarge academic academic agency result length solution fridge kidney coal piece deal husband erode duke ajar critical decision keyboard"
    ]
    account = Account( crypto="Bitcoin", format="legacy" )
    account.from_mnemonic( "\n".join(mnemonics), passphrase = 'TREZOR', path="m/" )
    assert account.xprvkey == "xprv9s21ZrQH143K4QViKpwKCpS2zVbz8GrZgpEchMDg6KME9HZtjfL7iThE9w5muQA4YPHKN1u5VM1w8D4pvnjxa2BmpGMfXr7hnRrRHZ93awZ"

Interestingly enough, the slip39.recovery module works correctly:

python3 -m slip39.recovery -p TREZOR -m "duckling enlarge academic academic agency result length solution fridge kidney coal piece deal husband erode duke ajar critical decision keyboard" 
bb54aac4b89dc868ba37d9cc21b2cece

onvej-sl avatar May 31 '24 12:05 onvej-sl