Skip to content

Instantly share code, notes, and snippets.

View odudex's full-sized avatar

Odudex odudex

View GitHub Profile
@odudex
odudex / Krux_on_Windows.md
Last active January 29, 2024 16:44
Developing Krux on Windows

Motivation

Linux and Ubuntu are ideal for Krux development, but if you have a computer that lacks Linux support, with no drivers available for peripherals like the webcam (the webcam is integral to many Krux workflows), you can consider developing for Krux on Windows.

Development Environment Preparation

We will use the combo Window WSL(2), running Ubuntu and VS Code for simulation, code edition and compiling. To edit Krux source code, when preparation is finished, you’ll be able to open Ubuntu, navigate to Krux project and run: code . This will open VS Code on Windows, which will be editing the project inside Ubuntu.

Install WSL and VS Code and clone Krux

Open PowerShell and type the command:

@odudex
odudex / krux_decrypt_lite.py
Created April 23, 2024 16:31
Decrypt a mnemonic from a Krux .json file or QR code
# The MIT License (MIT)
# Copyright (c) 2021-2023 Krux contributors
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
import random
def pattern_detection(rolls, num_sides):
"""Calculate Shannon's entropy of roll derivatives to detect arithmetic progression patterns.
Args:
rolls (list of int): List of dice rolls.
num_sides (int): Number of sides on the dice.
Returns:
int: A percentage representing how much the sequence deviates from maximum entropy (0% is random, 100% is non-random).
"""
@odudex
odudex / flash_map.py
Created September 30, 2024 15:53
Creates a map of used flash bocks for Krux
import flash
from . import Page, MENU_CONTINUE, DEFAULT_PADDING
from ..themes import theme, GREEN, LIGHT_PINK, PURPLE, BLUE, YELLOW
from ..krux_settings import t
from ..display import FONT_HEIGHT
from ..wdt import wdt
from ..firmware import FLASH_SIZE, SPIFFS_ADDR, FIRMWARE_SLOT_1, FIRMWARE_SLOT_2
FLASH_ROWS = 64
BLOCK_SIZE = 0x1000
@odudex
odudex / krux_flash_viewer.py
Created October 2, 2024 14:32
Render images from Krux flash dumps
import os
import tkinter as tk
from tkinter import filedialog
from PIL import Image, ImageTk
def create_image_from_file(filename, start_pos):
def maxv(number_of_bits):
return (2**number_of_bits) - 1
with open(filename, 'rb') as f:

Krux Ethos

The purpose of this ethos is not to virtue signal, but to introduce newcomers to Krux's philosophy and provide a guiding reference for decision-making and the long-term mission for dedicated Krux users.

Mission

To implement ideas that make self-custody more powerful, accessible, and user-friendly.

Don't Trust

Do not trust developers’ intentions or competence. Krux is a DIY, use-at-your-own-risk project. We are committed to continuously improving security, but will not make claims or create marketing narratives about it.

Donations

@odudex
odudex / Context on Tamper Detection Tool.md
Created November 12, 2024 19:01
Context on Krux Tamper Detection Tool

After a user reported that the settings on their Krux device changed unexpectedly, and with the disclosure of threads like "Dark Skippy" I decided to invest time in protecting Krux from tampering.

My first objective was to investigate if it was possible to implement some type of tamper protection for Krux K210-based boards, such as secure boot. The K210 specifications mention firmware encryption and One-Time Programmable (OTP) memory, which could make secure boot viable, but there was no documentation on how to implement it.

The lack of documentation didn't stop us from exploring K210 features before, so I started a quick investigation.

My first finding was that I was not the first to explore these poorly documented characteristics of the K210. Wladimir van der Laan, while still the lead Bitcoin Core maintainer, conducted a deep investigation into the K210, also trying to determine how to use the chip's OTP memory.

[Wladimir's OTP Layout Documentation](https://github.com/laanwj/

@odudex
odudex / krux_decrypt.py
Last active December 23, 2024 10:01
Load and decrypt Krux encrypted mnemonics from JSON, QR codes, save them as .txt and load as .txt
# The MIT License (MIT)
# Copyright (c) 2021-2023 Krux contributors
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@odudex
odudex / qr_templater.py
Last active December 23, 2024 17:47
Generate QR Code templates for manual transcription as SVG and PNG files
# The MIT License (MIT)
# Copyright (c) 2024-2024 Krux contributors
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
class Node:
"""
A simple parse-tree node to represent Miniscript expressions.
"""
def __init__(self, node_type, children=None, value=None, level=0):
self.node_type = node_type # e.g. "AND", "OR", "PK", "OLDER"
self.children = children if children is not None else []
self.value = value # used by PK(...) or OLDER(...)
self.level = level # for indentation