Ejemplo n.º 1
0
def set_genuine():
    # PIN must be blank for this to work
    # - or logged in already as main
    from pincodes import pa

    if pa.is_secondary:
        return

    if not pa.is_successful():
        # assume blank pin during factory selftest
        pa.setup(b'')
        assert not pa.is_delay_needed()  # "PIN failures?"

        if not pa.is_successful():
            pa.login()
            assert pa.is_successful()  # "PIN not blank?"

    # do verify step
    pa.greenlight_firmware()

    dis.show()
Ejemplo n.º 2
0
def set_seed_value(words=None, encoded=None):
    # Save the seed words into secure element, and reboot. BIP-39 password
    # is not set at this point (empty string)
    if words:
        bip39.a2b_words(words)      # checksum check

        # map words to bip39 wordlist indices
        data = [bip39.wordlist_en.index(w) for w in words]

        # map to packed binary representation.
        val = 0
        for v in data:
            val <<= 11
            val |= v

        # remove the checksum part
        vlen = (len(words) * 4) // 3
        val >>= (len(words) // 3)

        # convert to bytes
        seed = val.to_bytes(vlen, 'big')
        assert len(seed) == vlen

        # encode it for our limited secret space
        nv = SecretStash.encode(seed_phrase=seed)
    else:
        nv = encoded

    from glob import dis
    dis.fullscreen('Applying...')
    pa.change(new_secret=nv)

    # re-read settings since key is now different
    # - also captures xfp, xpub at this point
    pa.new_main_secret(nv)

    # check and reload secret
    pa.reset()
    pa.login()
Ejemplo n.º 3
0
async def remember_bip39_passphrase():
    # Compute current xprv and switch to using that as root secret.
    import stash
    from glob import dis

    dis.fullscreen('Check...')

    with stash.SensitiveValues() as sv:
        nv = SecretStash.encode(xprv=sv.node)

    # Important: won't write new XFP to nvram if pw still set
    stash.bip39_passphrase = ''

    dis.fullscreen('Saving...')
    pa.change(new_secret=nv)

    # re-read settings since key is now different
    # - also captures xfp, xpub at this point
    pa.new_main_secret(nv)

    # check and reload secret
    pa.reset()
    pa.login()
Ejemplo n.º 4
0
# (c) Copyright 2020 by Coinkite Inc. This file is covered by license found in COPYING-CC.
#
# quickly main wipe seed; don't install anything new
from glob import numpad, dis
from pincodes import pa
from nvstore import settings
from pincodes import AE_SECRET_LEN, PA_IS_BLANK

if not pa.is_secret_blank():
    # clear settings associated with this key, since it will be no more
    settings.blank()

    # save a blank secret (all zeros is a special case, detected by bootloader)
    dis.fullscreen('Wipe Seed!')
    nv = bytes(AE_SECRET_LEN)
    pa.change(new_secret=nv)

    rv = pa.setup(pa.pin)
    pa.login()

    assert pa.is_secret_blank()

# reset top menu and go there
from actions import goto_top_menu
goto_top_menu()

numpad.abort_ux()