Skip to content

Instantly share code, notes, and snippets.

@bnonni
Last active May 31, 2023 23:24
Show Gist options
  • Save bnonni/3cb8f813d6ad7224ae4bf71716a9ccbb to your computer and use it in GitHub Desktop.
Save bnonni/3cb8f813d6ad7224ae4bf71716a9ccbb to your computer and use it in GitHub Desktop.

Bitcoin Socratic Seminar #18

https://atlantabitdevs.org/2023/05/30/bitcoin-socratic-seminar-18/ https://www.meetup.com/atlantabitdevs/events/293790513/

Topics

Bitcoin Core v25.0 Release

  1. P2P and network changes

    • Txns with min size of 65 bytes of non-witness data are now allowed by mempool and relay policy
    • Continues to mitigate CVE-2017-12842 64 byte vulnerability while opening up additional smaller transaction size use-cases
    • CVE-2017-18350 is a buffer overflow vulnerability which allows a malicious SOCKS proxy server to overwrite the program stack on systems with a signed char type (including common 32-bit and 64-bit x86 PCs).
    • The vulnerability is specific to avoiding propagating txns of size 64 bytes or less

    Timeline:

    • 2012-04-01: Vulnerability introduced in PR #1141.
    • 2012-05-08: Vulnerability merged to master git repository.
    • 2012-08-27: Vulnerability published in v0.7.0rc1.
    • 2012-09-17: Vulnerability released in v0.7.0. ...
    • 2017-09-21: practicalswift discloses vulnerability to security team.
    • 2017-09-23: Wladimir opens PR #11397 to quietly fix vulernability.
    • 2017-09-27: Fix merged to master git repository.
    • 2017-10-18: Fix merged to 0.15 git repository.
    • 2017-11-04: Fix published in v0.15.1rc1.
    • 2017-11-09: Fix released in v0.15.1. ...
    • 2019-06-22: Vulnerability existence disclosed to bitcoin-dev ML.
    • 2019-11-08: Vulnerability details disclosure to bitcoin-dev ML.
    src/policy/policy.h (May 2018)
    /** The minimum non-witness size for transactions we're willing to relay/mine (1 segwit input + 1 P2WPKH output = 82 bytes) */
    static constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{82};
    src/validation.cpp (May 2018)
    // Transactions smaller than this are not relayed to mitigate CVE-2017-12842 by not relaying 64-byte transactions
    if (::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) < MIN_STANDARD_TX_NONWITNESS_SIZE)
        return state.Invalid(ValidationInvalidReason::TX_NOT_STANDARD, false, REJECT_NONSTANDARD, "tx-size-small");

    So I think the question to ask would be "why can't we just make sure it's not 64?"

    Greg Sanders May 23, 2020 Bitcoin ML

    src/policy/policy.h (v25.0 release)
    /** The minimum non-witness size for transactions we're willing to relay/mine: one byte larger than 64 bytes */
    static constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{65};
    src/validation.cpp (v25.0 release)
    // Transactions smaller than 65 non-witness bytes are not relayed to mitigate CVE-2017-12842.
    if (::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) < MIN_STANDARD_TX_NONWITNESS_SIZE)
        return state.Invalid(TxValidationResult::TX_NOT_STANDARD, "tx-size-small");

    bitcoin/bitcoin#26265

  2. New RPCs

    • New scanblocks RPC returns blockhashes based on args passed by user
    • Can be used in combination with getblockheader and rescanblockchain
    • Can only be used by setting blockfilterindex=1
    • Allows pruned nodes to resync wallet back to the genesis block (or prior to last pruned block)
    • Allows a sort of hybrid-SPV mode; SPV nodes can build the blockfilterindex from the p2p network (rather than deriving them from the blocks)
    • Example
$ bitcoin-cli scanblocks start '["addr(mzrj4QmPhk98vc2yQw42uCsgwfBjVzPPLM)"]' 1000000
  1. Updated RPCs

    • All JSON-RPC methods support both by-position and by-name parameters
    • convenience to allow some parameter values to be passed by name without having to name every value. The python test framework and bitcoin-cli tool both take advantage of this, so for example:
    bitcoin-cli -named createwallet wallet_name=mywallet load_on_startup=1

    Can now be shortened to:

    bitcoin-cli -named createwallet mywallet load_on_startup=1
    • decodescript supports Miniscript descriptors in P2WSH context
    • finalizepsbt supports finalizing a transaction with Miniscript-compatible P2WSH inputs
  2. Build System

    • Two build flags deprecated: --enable-upnp-default and --enable-natpmp-default
    • To enable these features, set them in bitcoin.conf like so:
    # Use NAT-PMP to map the listening port.
    natpmp=1
    
    # Use UPnP to map the listening port.
    upnp=1
    
  3. Updated settings

    • Setting blocksonly=1 reduces max mempool memory to 5MB (users may still use -maxmempool to override)
    • Previous default was 300MB
    • Setting -maxconnections=0 will now disable dnsseed and listen
    • Can still set these in bitcoin.conf
    # Query for peer addresses via DNS lookup
    dnsseed=1
    
    # Listen for peers on both clear and tor
    listen=1
    
  4. Wallet

    • minconf option allows specifying the minimum number of confirmations on a UTXO being spent
    • maxconf option allows specifying the maximum number of confirmations on a UTXO being spent
    • Applies to the following RPC commands:
      • fundrawtransaction
      • send
      • walletcreatefundedpsbt
      • sendall
    • Descriptor wallets can now spend coins sent to P2WSH Miniscript descriptors. (#24149)

Lava Loans Protocol

  • Enables you to borrow against your bitcoin without rehypothecation or counterparty risk

Serving a role as a digital store of value, bitcoin is a strong candidate for loan collateral. However, there exist no good options for users that wish to use native-bitcoin as collateral for loans without trusting a custodian. We present a solution that adapts methods from invisible smart contracts, otherwise known as discreet log contracts, to enable people to borrow assets against native-bitcoin as collateral. One of the most important use-cases of the Lava Loans Protocol is that it enables people to borrow stablecoins against native-bitcoin in the most secure and trustless way currently possible.

  • Bitcoin is a strong loan collateral, but only custodial lending services have existed up until now (BlockFi, FTX). Lava uses DLCs to enable self-custodial, bitcoin-collateralized loans to borrow stable assets.
  • TLDR: Borrow stable coins using bitcoin as collateral without giving full custody to a counterparty.

image

LNDK

  • Standalone daemon that connects to LND
  • Allows LND nodes to implement bolt 12 functionality
  • Leverages LDK to act as a thin "shim" between LND's APIs and LDK's lightning library
Status
  • v0.1.0: Onion message forwarding for LND
  • v0.2.0: Payment to offers with blinded paths.
Architecture
  • Onion messaging is implemented using a custom version of LDK's OnionMessenger that uses an LND node's key to process onion messages
  • Done by using the NodeSigner trait to make calls to LND's signerrpc API
  • Specifically performing ECDH ops with the node's private key

image

Enigma

Ark

  • L2 designed to help scale Bitcoin transactions

  • Uses shared utxo model to enable anonymous, off-chain payments through an untrusted intermediary called the Ark Service Provider (ASP)

  • ASPs are always-on servers that provide liquidity to the network, similar to how Lightning service providers work

  • Compared to other L2s image

  • Interoperable with the Lightning Network

  • Less on-chain footprint than Lightning

  • No concept of opening and closing channels

  • Like a wallet UTXO set, users possess a set of coins called vTXOs

  • vTXOs are created, live and die entirely off chain but can be unilaterally reverted to on-chain

  • Covenants used to commit a large set of unrevealed transaction outputs to a single transaction output creating virtual transaction outputs (vTXOs)

  • Acquire xTXOs by lifting: an atomic two-way peg mechanism that doesn't require trust

  • Lets users lift their on-chain utxos off the chain for a 1:1 virtual utxo

  • vTXOs are destroyed, and new vTXOs are created when a payment is made on the protocol, similar to how on-chain funds flow

  • Absolute atomicity of transfer ensured by a txlock: i.e. the existance of a mutually agreed upon transaction identifier

TBD Web5.js

  • Web5.js release allows developers to start building decentralized applications on TBD’s developer platform today

  • Starting is as simple as ... image

  • TBD is hosting DWNs for use with the current Web5.js library

  • Can swap in your own DWN today or use theirs

  • Provides functionality that does this stuff ... image

  • ATL BitLab is implementing this tech for its members! Coming soon!

  • Get setup with a web5 did and verifiable credential image

  • Use the VC to authenticate, pay invoices, manage membership, get access to members only features / content and more! image

  • Other fun visualizations ...

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment