Subject: Re: [bitcoin-dev] Civ Kit: A Peer-to-Peer Electronic Market System

From: Antoine Riard <[email-masked]>
Date: Mon, 1 May 2023 18:47:46 +0100

Hi all,

One of the most relevant feedback I received on the paper publication
was the lack of underscoring front-running resistance as a fundamental
property wished for a peer-to-peer marketplace.

It is expected the level of front-running resistance aimed by the
market participants to be heavily functioned by the types of trades
considered: fiat currencies, real goods, services. For some classes of
goods, e.g commodities one cannot expect the same level of item
liquidity due to cycle of production and exogenous factors like
weather. Some types of trades marketplaces might be exposed to far
less front-running risks and rather would have to deal with accurate
risk modelling of the underlying goods. E.g attest there is a
decentralized identifier or any other linkage proof of the physical
good existence staying valid for the duration of offer lifetime.
Offers conditions themselves might be far more verbose and precise
special Bitcoin Script paths to morph the shipment risks.

On the other hand, the types of trades like fiat currencies or bitcoin
financial contracts (e.g discreet log contracts or submarine swaps),
front-running risk by the bulletin board sounds a qualified concern.
In traditional finance, front-running is defined as "entering into an
equity trade, options or future contracts with advance knowledge of a
block transaction that will influence the price of the underlying
security to capitlize on the trade" [0]. In Bitcoin/Civkit parlance, a
front-running could be a board on the discovery of a batch of market
offers increasing liquidity for a fiat-2-btc pair, seizing the
opportunity by forwarding a HTLC across a Lightning payment path to
enter into the trade, before publishing the offer on its board.

I think you have at least two security paradigms to mitigate
front-running happening peer-to-peer marketplace. The first one is to
duplicate the announcement of the offers to a number of concurrent
board operated by independent identities and in parallel monitor the
latency. Latency anomalies should be spotted on by watchtower-like
infrastructure at the service of makers/takers and in case of repeated
anomalies a maker should disqualify the misbehaving board from future
announcements. As all statistical mitigation it is not perfect and
open the way to some margin of exploitation by the boards, as the
watchtower monitoring frequency can be guessed. Additionally, this
latency monitoring paradigm sounds to be valid under the assumption
that at least one board is "honest" and board might have a holistic
interest to silently collude. Running or accessing monitoring
infrastructure comes with a new liveliness requirement or additional
cost for mobile clients.

Another paradigm can be to run the bulletin boards as a federation e.g
under Honey Badger BFT as used by Fedimint [1]. The incoming board
offers become consensus items that must be announced to all the
federations members onion gateway and which are not announced before a
consensus proposal has been adopted. The e-cash tokens can be rather
Bitcoin-paid credentials required by the board federation for
publication. The federation members earn an income as a group to
follow the consensus rules and be paid only when there is "consensus"
publication. The federation could adopt some "DynFed" techniques to
extend the federation set [2]. One can imagine a federation consisting
of all the significant market participants, leveling the field for
all.

Is there another security paradigm direction to mitigate front-running
and other asymmetries of information ? I can't immediately imagine
more though I believe it stays an interesting open question.

In fine, the Civkit proposes a flexible framework for peer-to-peer
marketplace, where propagation latency monitoring and federation set
and rules can be tweaked as "front-running resistance" parameters,
adapting to the types of trades and market participants tolerance.
Configuration of those parameters will at the end be function of
real-world deployments. Somehow mass front-running on the board is a
"champagne" issue  I'll be happy to have.

Best,
Antoine

[0] https://www.finra.org/investors/insights/getting-speed-high-frequency-trading
[1] https://fedimint.org/docs/CommonTerms/HBBFTConsensus
[2] https://blockstream.com/assets/downloads/pdf/liquid-whitepaper.pdf

Le jeu. 13 avr. 2023 à 15:10, Antoine Riard <[email-masked]> a
écrit :

> Hi list,
>
> We have been working since a while with Nicholas Gregory (Commerce Block),
> Ray Youssef (the Built With Bitcoin foundation) and few others on a new
> peer-to-peer market system to enable censorship-resistant and
> permissionless global trading in all parts of the world. While the design
> aims in priority to serve on-ramp/off-ramp trading, it can be extended to
> support any kind of trading: goods, services, bitcoin financial derivatives
> like discreet log contracts.
>
> The design combines the Nostr architecture of simple relays announcing
> trade orders to their clients with Lightning onion routing infrastructure,
> therefore granting high-level of confidentiality to the market
> participants. The market boards are Nostr relays with a Lightning gateway,
> each operating autonomously and in competition. The market boards can be
> runned as a federation however there is no "decentralized orderbook" logged
> into the blockchain. The trades are escrowed under Bitcoin Script
> contracts, relying on moderations and know your peer oracles for
> adjudication.
>
> The scoring of trades, counterparties and services operators should be
> enabled by the introduction of a Web-of-Stakes, assembled from previous
> ideas [0]. From the Bitcoin UTXO set servicing as a trustless source of
> truth, an economic weight can be assigned to each market entity. This
> reputation paradigm could be composed with state-of-the-art Web-of-Trust
> techniques like decentralized identifiers [1].
>
> A consistent incentive framework for service operators is proposed by the
> intermediary of privacy-preserving credentials backed by Bitcoin payments,
> following the lineaments of IETF's Privacy Pass [2]. Services operators
> like market boards and oracles are incentivized to thrive for efficiency,
> akin to routing hops on Lightning and miners on the base layer.
>
> The whitepaper goes deep in the architecture of the system [3] (Thanks to
> the peer reviewers!).
>
> We'll gradually release code and modules, extensively building on top of
> the Lightning Dev Kit [4] and Nostr libraries. All according to the best
> Bitcoin open-source and decentralized standards established by Bitcoin Core
> and we're looking forward to collaborating with everyone in the community
> to standardize libraries and guarantee interoperability between clients
> with long-term thinking.
>
> Feedback is very welcome!
>
> Cheers,
> Nick, Ray and Antoine
>
> [0]
> https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-November/002884.html
> [1] https://www.w3.org/TR/2022/REC-did-core-20220719/
> [2] https://privacypass.github.io
> [3] https://github.com/civkit/paper/blob/main/civ_kit_paper.pdf
> [4] https://lightningdevkit.org
>