Convert Figma logo to code with AI

trezor logotrezor-firmware

:lock: Trezor Firmware Monorepo

1,329
649
1,329
387

Top Related Projects

Accept Bitcoin payments. Free, open-source & self-hosted, Bitcoin payment processor.

Bitcoin wallet for iOS & Android. Built with React Native

Quick Overview

Trezor-firmware is the official repository for the firmware of Trezor hardware wallets, developed by SatoshiLabs. It contains the source code for both Trezor One and Trezor Model T devices, as well as the associated tools and libraries for development and testing.

Pros

  • Open-source, allowing for community audits and contributions
  • Supports multiple cryptocurrencies and tokens
  • Regular updates and security improvements
  • Extensive documentation and developer resources

Cons

  • Complexity may be challenging for new contributors
  • Limited to Trezor hardware devices
  • Requires specialized knowledge in embedded systems and cryptography
  • Potential for security vulnerabilities if not properly maintained

Code Examples

This is not a code library in the traditional sense, but rather a firmware project. However, here are a few examples of how developers might interact with the project:

  1. Building the firmware:
# Clone the repository
git clone https://github.com/trezor/trezor-firmware.git
cd trezor-firmware

# Install dependencies
pip3 install -r requirements.txt

# Build firmware for Trezor Model T
make -C core
  1. Running tests:
# Run unit tests for core
pytest tests/device_tests
  1. Flashing firmware to a device:
# Flash firmware to Trezor Model T
python3 -m trezorctl firmware-update -f build/core/firmware.bin

Getting Started

To get started with Trezor firmware development:

  1. Set up the development environment:

    git clone https://github.com/trezor/trezor-firmware.git
    cd trezor-firmware
    pip3 install -r requirements.txt
    
  2. Build the firmware:

    make -C core
    
  3. Run the emulator:

    ./core/emu.py
    
  4. For more detailed instructions, refer to the official documentation.

Competitor Comparisons

Accept Bitcoin payments. Free, open-source & self-hosted, Bitcoin payment processor.

Pros of BTCPayServer

  • More comprehensive payment processing solution for merchants and businesses
  • Supports multiple cryptocurrencies beyond just Bitcoin
  • Offers a wider range of features, including invoicing and store management

Cons of BTCPayServer

  • Larger codebase and potentially more complex to set up and maintain
  • May have a steeper learning curve for non-technical users
  • Less focused on hardware security compared to Trezor Firmware

Code Comparison

BTCPayServer (C#):

public async Task<IActionResult> CreateInvoice(CreateInvoiceRequest request)
{
    var store = HttpContext.GetStoreData();
    var result = await _invoiceController.CreateInvoiceCoreRaw(request, store);
    return Ok(result);
}

Trezor Firmware (Python):

def sign_tx(self, tx: SignTx) -> None:
    self.signing = True
    self.tx = tx
    self.tx_info = TxInfo(tx)
    self.serialize_input_hash = tx.serialize_input_hash
    self.serialize_output_hash = tx.serialize_output_hash
    self.multisig_fingerprint = tx.multisig_fingerprint

BTCPayServer is a more comprehensive payment processing solution, while Trezor Firmware focuses on hardware wallet security. BTCPayServer's code example shows invoice creation, whereas Trezor Firmware's code demonstrates transaction signing functionality.

Bitcoin wallet for iOS & Android. Built with React Native

Pros of BlueWallet

  • Mobile-focused Bitcoin wallet with a user-friendly interface
  • Supports multiple wallet types, including Lightning Network
  • Active development with frequent updates and new features

Cons of BlueWallet

  • Less secure than hardware wallet solutions like Trezor
  • Limited to Bitcoin and Lightning Network transactions
  • Relies on third-party servers for some functionalities

Code Comparison

BlueWallet (JavaScript):

export const getAddress = async wallet => {
  if (wallet.type === HDSegwitBech32Wallet.type) {
    return wallet.getAddressAsync();
  }
  return wallet.getAddress();
};

Trezor Firmware (C):

void fsm_msgGetAddress(const GetAddress *msg) {
  RESP_INIT(Address);

  CHECK_INITIALIZED

  CHECK_PIN

  const CoinInfo *coin = fsm_getCoin(msg->has_coin_name, msg->coin_name);
  if (!coin) return;

  HDNode *node = fsm_getDerivedNode(coin->curve_name, msg->address_n, msg->address_n_count, NULL);
  if (!node) return;

  hdnode_fill_public_key(node);

  if (msg->has_show_display && msg->show_display) {
    if (!fsm_layoutAddress(node, coin, msg->has_multisig, &msg->multisig)) {
      return;
    }
  }

  resp->has_address = true;
  hdnode_get_address(node, coin->address_type, resp->address, sizeof(resp->address));

  msg_write(MessageType_MessageType_Address, resp);

  layoutHome();
}

The code snippets demonstrate the different approaches and complexity levels between the two projects, with BlueWallet focusing on mobile wallet functionality and Trezor Firmware implementing low-level hardware interactions.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Trezor Firmware

img

Repository Structure

  • ci: Gitlab CI configuration files
  • common/defs: JSON coin definitions and support tables
  • common/protob: Common protobuf definitions for the Trezor protocol
  • common/tools: Tools for managing coin definitions and related data
  • core: Trezor Core, firmware implementation for Trezor T
  • crypto: Stand-alone cryptography library used by both Trezor Core and the Trezor One firmware
  • docs: Assorted documentation
  • legacy: Trezor One firmware implementation
  • python: Python client library and the trezorctl command
  • storage: NORCOW storage implementation used by both Trezor Core and the Trezor One firmware
  • tests: Firmware unit test suite
  • tools: Miscellaneous build and helper scripts
  • vendor: Submodules for external dependencies

Contribute

See CONTRIBUTING.md.

Using Conventional Commits is strongly recommended and might be enforced in future.

Also please have a look at the docs, either in the docs folder or at docs.trezor.io before contributing. The misc chapter should be read in particular because it contains some useful assorted knowledge.

Security vulnerability disclosure

Please report suspected security vulnerabilities in private to security@satoshilabs.com, also see the disclosure section on the Trezor.io website. Please do NOT create publicly viewable issues for suspected security vulnerabilities.

Documentation

See the docs folder or visit docs.trezor.io.