owned this note
owned this note
Published
Linked with GitHub
# FROST DKG Signing Using bdk-cli
## One-Time Setup Steps
### Install the `frost-zcash-tools` repo:
1. Clone the repo:
```bash
git clone https://github.com/BlockchainCommons/zcash-frost-tools
```
2. Check out the `taproot-tweak` branch:
```bash
git checkout taproot-tweak
```
3. Install the tools.
- This installs `frost-client`, `coordinator`, `dkg`, `participant`, `trusted-dealer`, and `frostd`.
- This demo only uses `frostd` and `frost-client`.
```bash
cargo install --path frost-client && cargo install --path frostd
```
### Install `toml-cli`
We will use this to extract the public keys from the TOML files.
```bash
cargo install toml-cli
```
### Install the `sighash-helper` tool
`bdk-cli` does not have a way to extract a transaction sighash in a format suitable for FROST signing, so we need to write a small Rust program that does just that.
```bash
cargo new sighash-helper --bin
cd sighash-helper
```
Open `Cargo.toml` and replace its `[dependencies]` section with:
```toml
bdk = { version = "0.30.2", default-features = false, features = ["std"] }
```
Replace the contents of `src/main.rs` with the following code:
```rust
use std::io::{self, Read};
use std::str::FromStr;
use bdk::bitcoin::psbt::PartiallySignedTransaction as Psbt;
use bdk::bitcoin::sighash::{Prevouts, SighashCache, TapSighashType};
fn main() {
// 1. read the base‑64 PSBT from stdin
let mut b64 = String::new();
io::stdin().read_to_string(&mut b64).unwrap();
let psbt = Psbt::from_str(b64.trim()).expect("valid base64 PSBT");
// 2. assume exactly one input (enforced by the demo)
let tx = &psbt.unsigned_tx;
// 3. clone the single witness_utxo so it lives long enough
let txout = psbt.inputs[0]
.witness_utxo
.as_ref()
.expect("witness_utxo present")
.clone();
let prevouts_arr = [txout]; // concrete array on the stack
let prevouts = Prevouts::All(&prevouts_arr);
// 4. compute Taproot key‑path sighash
let mut cache = SighashCache::new(tx);
let msg = cache
.taproot_key_spend_signature_hash(0, &prevouts, TapSighashType::Default)
.expect("sighash");
// 5. print the 32‑byte message as hex
println!("{:064x}", msg);
}
```
Build the tool. This should make it available in your `$PATH`.
```bash
cargo install --path .
cd ..
```
### Install the `psbt-sig-attach` tool
bdk‑cli 1.0 doesn’t yet expose a command to “just stick this signature in input 0”, so we’ll use another tiny Rust helper to do the surgery.
```bash
cargo new psbt-sig-attach --bin
cd psbt-sig-attach
```
Open `Cargo.toml` and replace its `[dependencies]` section with:
```toml
[dependencies]
bdk = { version = "0.30.2", default-features = false, features = ["std"] }
base64 = "0.22.1"
hex = "0.4"
bitcoin = "0.30.2"
```
Replace the contents of `src/main.rs` with the following code:
```rust
use std::io::{self, Read};
use std::str::FromStr;
use bitcoin::{
psbt::PartiallySignedTransaction as Psbt,
secp256k1::schnorr::Signature as SchnorrSig,
sighash::TapSighashType,
taproot::Signature as TaprootSignature,
};
use hex::FromHex;
fn main() {
// r||s hex comes as first CLI arg
let sig_hex = std::env::args()
.nth(1)
.expect("usage: psbt-sig-attach <64-byte r||s hex>");
let sig_vec = Vec::<u8>::from_hex(sig_hex.trim()).expect("hex sig");
assert_eq!(sig_vec.len(), 64, "need 64-byte Schnorr sig");
// wrap in TaprootSignature with default sighash flag
let tap_sig = TaprootSignature {
sig: SchnorrSig::from_slice(&sig_vec).expect("schnorr sig"),
hash_ty: TapSighashType::Default,
};
// read base-64 PSBT from stdin
let mut b64 = String::new();
io::stdin().read_to_string(&mut b64).unwrap();
let mut psbt = Psbt::from_str(b64.trim()).expect("base64 PSBT");
// insert signature in input 0
psbt.inputs[0].tap_key_sig = Some(tap_sig);
// write updated PSBT as base-64
println!("{}", psbt.to_string());
}
```
Build the tool. This should make it available in your `$PATH`.
```bash
cargo install --path .
cd ..
```
### Add an SSL certificate for `frostd`
The instructions below are for macOS. See [the `mkcert` repo](https://github.com/FiloSottile/mkcert) for more information.
Install `mkcert`:
```bash
brew install mkcert
│ ...
│ 🍺 /opt/homebrew/Cellar/mkcert/1.4.4: 7 files, 4.0MB
│ ...
```
Install the local CA:
```bash
mkcert -install
│ Created a new local CA 💥
│ Sudo password: <enter login password>
│ The local CA is now installed in the system trust store! ⚡️
│ The local CA is now installed in the Firefox trust store (requires browser restart)! 🦊
```
Create a certificate signed by the local CA for `frostd` to use running on `localhost`:
```bash
mkcert localhost 127.0.0.1 ::1
│ Created a new certificate valid for the following names 📜
│ - "localhost"
│ - "127.0.0.1"
│ - "::1"
│
│ The certificate is at "./localhost+2.pem" and the key at "./localhost+2-key.pem" ✅
│
│ It will expire on 17 November 2027 🗓
```
### Set Up `bitcoind` regtest node
```bash
export BITCOIN_DIR="$HOME/Library/Application Support/Bitcoin"
brew install bitcoin
cat >"$BITCOIN_DIR/bitcoin.conf"<<EOF
regtest=1
server=1
rpcuser=wolf
rpcpassword=topsecret
fallbackfee=0.0001
EOF
```
## Demo Steps
### Start the Bitcoin node
Start node. Add `-daemon` to run in the background:
```bash
bitcoind
```
The daemon is now listening on 127.0.0.1:18443.
### Set Up the Test Environment
```bash
export DEMO_DIR=`pwd`/demo
export REG_DIR="$DEMO_DIR/regular-wallet"
export FROST_DIR="$DEMO_DIR/frost-wallet"
export NETWORK=regtest
export RPC_URL=127.0.0.1:18443 # host:port
export RPC_USER=wolf # from bitcoin.conf above
export RPC_PASS=topsecret # from bitcoin.conf above
export RPC_AUTH="$RPC_USER:$RPC_PASS" # for bdk-cli
mkdir -p "$DEMO_DIR" "$REG_DIR" "$FROST_DIR"
cd "$DEMO_DIR"
```
### Set up and fund the regular wallet
#### Create the regular wallet in the test node
Set up the regtest wallet, then generate 101 blocks to mature the block reward and get the node going:
```bash
bitcoin-cli -regtest createwallet regtest || \
bitcoin-cli -regtest loadwallet regtest
bitcoin-cli -regtest -generate 101
│ {
│ "name": "regtest"
│ }
│ {
│ "address": "bcrt1qgekrq9j278ua769skqsh6p4n3z06lxjge3zjwf",
│ "blocks": [
│ "3fa077dd4a2aa50c3987c8913117abd4f8b55b3e798221e9756263d647822933",
│ "793159faf43ff756eccc774b5d7343e1303ec5c003b5a9d464ced706b2d9ce25",
│ "29253f081875fd4ebeccb8e15dd6fac3ff83878a5661c76dfdcc52705843bde2",
| ...
│ ]
│ }
```
You can delete `$DEMO_DIR` from a previous run to reset the demo environment and start a new demo run. For results consistent with this document, starting with a fresh shell environment and resetting the Bitcoin regtest node is also recommended.
#### Generate a BIP‑86 master key and descriptors
```bash
REG_KEY_JSON=$(bdk-cli --network $NETWORK key generate)
REG_XPRV=$(echo "$REG_KEY_JSON" | jq -r '.xprv')
REG_FPRINT=$(echo "$REG_KEY_JSON" | jq -r '.fingerprint')
REG_EXT_DESC="tr([${REG_FPRINT}/86h/1h/0h]${REG_XPRV}/0/*)"
REG_INT_DESC="tr([${REG_FPRINT}/86h/1h/0h]${REG_XPRV}/1/*)"
echo $REG_EXT_DESC
echo $REG_INT_DESC
│ tr([4daeaf7d/86h/1h/0h]tprv8ZgxMBicQKsPfQhfWNRsbPnFZoWvQYvwBvNtUBX4bwwmW5WDhbc17RM7A4VkUrKVYEgB742qRNykBa9KvZh7Qz4bcfBh5u3EyVkHH9DzRJH/0/*)
│ tr([4daeaf7d/86h/1h/0h]tprv8ZgxMBicQKsPfQhfWNRsbPnFZoWvQYvwBvNtUBX4bwwmW5WDhbc17RM7A4VkUrKVYEgB742qRNykBa9KvZh7Qz4bcfBh5u3EyVkHH9DzRJH/1/*)
```
#### Grab a fresh address from the regular wallet
```bash
REG_ADDR=$(bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$REG_EXT_DESC" \
--int-descriptor "$REG_INT_DESC" \
new_address | jq -r '.address')
echo "$REG_ADDR" # should start with bcrt1…
│ bcrt1pkhesty85r3594xasr0t4982h4v385nwcdt45y0jgf3nepmsd5pdsme9jlj
```
#### Mine a block straight into that address
```bash
bitcoin-cli -regtest generatetoaddress 1 "$REG_ADDR"
│ [
│ "2213ba549f53777d53d6897d65bc84613a5a88d2faf7d47a7b406971458a7351"
│ ]
```
#### Mine 100 more blocks to mature the block reward
```bash
bitcoin-cli -regtest -generate 100
│ {
│ "address": "bcrt1q65vljwpfm6ameggyr85ylgz77vddly0s8eex4m",
│ "blocks": [
│ "54015aaaf6d953d3063c2c387d3f55cacfb3dca0022da92a4133411f79e3ab80",
│ "00395c9d7964cb79a0474ee6db0a092fec8423b0c9f9e6fb7ef4dac47e2566ae",
│ "3357c4cef2daf9321551e7a3581cb7abea6b090527775a7982fe580cd94d23d7",
│ ...
│ ]
│ }
```
#### Let BDK notice its money and verify the balance
```bash
bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
sync
bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
balance
│ {}
│ {
│ "satoshi": {
│ "confirmed": 5000000000,
│ "immature": 0,
│ "trusted_pending": 0,
│ "untrusted_pending": 0
│ }
│ }
```
The regular wallet now has 5,000,000,000 satoshis (50 BTC) in confirmed balance.
### Create the FROST group
#### Create the FROST client configurations
Use `frost-client` to create each participant’s local config + network identity and then exchange “contact” strings.
On each machine (or each terminal), run:
```bash
frost-client init -c alice.toml
frost-client init -c bob.toml
frost-client init -c eve.toml
│ Generating keypair...
│ Writing to config file at alice.toml...
│ Done.
│ WARNING: the config file will contain your private FROST shares in clear. Keep it safe and never share it with anyone. Future versions of this tool might encrypt the config file.
│ Generating keypair...
│ Writing to config file at bob.toml...
│ Done.
│ WARNING: the config file will contain your private FROST shares in clear. Keep it safe and never share it with anyone. Future versions of this tool might encrypt the config file.
│ Generating keypair...
│ Writing to config file at eve.toml...
│ Done.
│ WARNING: the config file will contain your private FROST shares in clear. Keep it safe and never share it with anyone. Future versions of this tool might encrypt the config file.
```
#### Record the participant's public keys
⚠️ Run this in all the participants' terminals.
```bash
ALICE_PUBKEY=`toml get alice.toml 'communication_key.pubkey' | sed 's/"//g'`
BOB_PUBKEY=`toml get bob.toml 'communication_key.pubkey' | sed 's/"//g'`
EVE_PUBKEY=`toml get eve.toml 'communication_key.pubkey' | sed 's/"//g'`
echo $ALICE_PUBKEY
echo $BOB_PUBKEY
echo $EVE_PUBKEY
│ b0fb13901b6eca549f00ef3d69484435362b7b96efdd116b2693706c6d2a6025
│ 2a47a1184bce04239b479851286a025e0705936248d56e43a15b2e88e13ccc51
│ 4aabbfb4ceb393bb9a4bcac181334e07c7fef6ffd5037f8c755d7e2f1b0d0e22
```
#### Export the client contact strings
```bash
ALICE_CONTACT=`frost-client export --name "Alice" -c alice.toml 2>&1 | tail -n 1`
BOB_CONTACT=`frost-client export --name "Bob" -c bob.toml 2>&1 | tail -n 1`
EVE_CONTACT=`frost-client export --name "Eve" -c eve.toml 2>&1 | tail -n 1`
echo $ALICE_CONTACT
echo $BOB_CONTACT
echo $EVE_CONTACT
│ zffrost1qyqq2stvd93k2g9slvfeqxmwef2f7q808455s3p4xc4hh9h0m5gkkf5nwpkx62nqy5j9qg33
│ zffrost1qyqqxsn0vgsz53aprp9uupprndres5fgdgp9upc9jd3y34twgws4kt5guy7vc5g795au2
│ zffrost1qyqqx3tkv5sy42alkn8t8yamnf9u4svpxd8q03l77mla2qml33646l30rvxsugs6rslfs
```
#### Each client imports the other two clients' contact strings
```bash
frost-client import -c alice.toml $BOB_CONTACT
frost-client import -c alice.toml $EVE_CONTACT
frost-client import -c bob.toml $ALICE_CONTACT
frost-client import -c bob.toml $EVE_CONTACT
frost-client import -c eve.toml $ALICE_CONTACT
frost-client import -c eve.toml $BOB_CONTACT
│ Imported this contact:
│ Name: Bob
│ Public Key: d1129058500ee4f1eb9cb13ae5438898ca85214a2461b81025987b84956df754
│ Imported this contact:
│ Name: Eve
│ Public Key: 7ac45af5e45841e4a17533066d22d7132101aa87b16634a545810f426bd36221
│ Imported this contact:
│ Name: Alice
│ Public Key: 22f2f696f4d8074aa842b0ab0465626678ba3e618cc512523608f1b5ce1d8927
│ Imported this contact:
│ Name: Eve
│ Public Key: 7ac45af5e45841e4a17533066d22d7132101aa87b16634a545810f426bd36221
│ Imported this contact:
│ Name: Alice
│ Public Key: 22f2f696f4d8074aa842b0ab0465626678ba3e618cc512523608f1b5ce1d8927
│ Imported this contact:
│ Name: Bob
│ Public Key: d1129058500ee4f1eb9cb13ae5438898ca85214a2461b81025987b84956df754
```
#### Start the FROST server
```bash
frostd \
--tls-cert localhost+2.pem \
--tls-key localhost+2-key.pem
│ 2025-08-08T23:47:22.551822Z INFO frostd: server running
│ 2025-08-08T23:47:22.559393Z INFO frostd: starting HTTPS server at 0.0.0.0:2744
```
#### Start the DKG session
NOTE: If you get the error `Error: user has more than one FROST session active`, you can restart `frostd` to clear its in-memory state. There are more elegant ways to to this but for the demo it's not a concern.
On Alice's terminal:
```bash
frost-client dkg \
-d "Demo DKG: Alice, Bob, Eve" \
-s https://127.0.0.1:2744 \
-S $BOB_PUBKEY,$EVE_PUBKEY \
-t 2 \
-C "secp256k1-tr" \
-c alice.toml
│ Logging in...
│ Creating DKG session...
│ Getting session info...
│ Waiting for other participants to send their Round 1 Packages.....
```
#### Add the second participant
On Bob's terminal:
```bash
frost-client dkg \
-d "Demo DKG: Alice, Bob, Eve" \
-s https://127.0.0.1:2744 \
-t 2 \
-C "secp256k1-tr" \
-c bob.toml
│ Logging in...
│ Joining DKG session...
│ Getting session info...
│ Waiting for other participants to send their Round 1 Packages.....
```
#### Add the third participant
On Eve's terminal:
```bash
frost-client dkg \
-d "Demo DKG: Alice, Bob, Eve" \
-s https://127.0.0.1:2744 \
-t 2 \
-C "secp256k1-tr" \
-c eve.toml
│ Logging in...
│ Joining DKG session...
│ Getting session info...
│ Waiting for other participants to send their Round 1 Packages.....
```
#### The participants exchange their packets:
Alice
```
│ Waiting for other participants to send their broadcasted Round 1 Packages....
│ Waiting for other participants to send their Round 2 Packages.....
│ Taproot DKG: storing P in PublicKeyPackage for FROST signing
│ Internal key (P): 3e18b2b17af80180aa3c766a13b27bb0dfd724ad5f16107c54cf38557b1ea1ea
│ Tweaked key (Q): 3c18a30c878fe6ebabf0960952810d0a8130507a1b10c518bf07165049fe790b
│ Group ID will use Q for identification
│ Group created; information written to alice.toml
```
Bob
```
│ Waiting for other participants to send their broadcasted Round 1 Packages.....
│ Waiting for other participants to send their Round 2 Packages....
│ Taproot DKG: storing P in PublicKeyPackage for FROST signing
│ Internal key (P): 3e18b2b17af80180aa3c766a13b27bb0dfd724ad5f16107c54cf38557b1ea1ea
│ Tweaked key (Q): 3c18a30c878fe6ebabf0960952810d0a8130507a1b10c518bf07165049fe790b
│ Group ID will use Q for identification
│ Group created; information written to bob.toml
```
Eve
```
│ Waiting for other participants to send their broadcasted Round 1 Packages.....
│ Waiting for other participants to send their Round 2 Packages.....
│ Taproot DKG: storing P in PublicKeyPackage for FROST signing
│ Internal key (P): 3e18b2b17af80180aa3c766a13b27bb0dfd724ad5f16107c54cf38557b1ea1ea
│ Tweaked key (Q): 3c18a30c878fe6ebabf0960952810d0a8130507a1b10c518bf07165049fe790b
│ Group ID will use Q for identification
│ Group created; information written to eve.toml
```
#### Inspect the results of the DKG
⚠️ Run this in all participant terminals:
```bash
GROUP_ID=$(grep -oE '^\[group\.[0-9a-f]+' alice.toml | head -1 | sed 's/^\[group\.//')
DESC=$(toml get alice.toml "group.$GROUP_ID.description" | tr -d '"')
CS=$(toml get alice.toml "group.$GROUP_ID.ciphersuite" | tr -d '"')
SRV=$(toml get alice.toml "group.$GROUP_ID.server_url" | tr -d '"')
PUBKEY_PKG=$(toml get alice.toml "group.$GROUP_ID.public_key_package" | tr -d '"')
PX=$(echo $PUBKEY_PKG | tail -c 65)
KEY_PKG=$(toml get alice.toml "group.$GROUP_ID.key_package" | tr -d '"')
echo "group ID: $GROUP_ID"
echo "description: $DESC"
echo "ciphersuite: $CS"
echo "server_url: $SRV"
echo "group_id: $GROUP_ID"
echo "pubkey_pkg: ${#PUBKEY_PKG} hex chars"
echo "px: $PX"
echo "key_pkg: ${#KEY_PKG} hex chars"
│ group ID: 023c18a30c878fe6ebabf0960952810d0a8130507a1b10c518bf07165049fe790b
│ description: Demo DKG: Alice, Bob, Eve
│ ciphersuite: FROST-secp256k1-SHA256-TR-v1
│ server_url: https://127.0.0.1:2744
│ group_id: 023c18a30c878fe6ebabf0960952810d0a8130507a1b10c518bf07165049fe790b
│ pubkey_pkg: 468 hex chars
│ px: 3e18b2b17af80180aa3c766a13b27bb0dfd724ad5f16107c54cf38557b1ea1ea
│ key_pkg: 272 hex chars
```
Participants listed under this group:
```bash
grep -oE "^\[group\.$GROUP_ID\.participant\.[0-9a-f]+\]" alice.toml \
| sed -E "s/^\[group\.$GROUP_ID\.participant\.([0-9a-f]+)\]/\1/" \
| while read -r ID; do
PK=$(toml get alice.toml "group.$GROUP_ID.participant.$ID.pubkey" | tr -d '"')
echo "participant id=$ID pubkey=$PK"
done
│ participant id=28bb139e267a16ea2564d10fcc2f1aa4e9c2f21f9e3c384b9d918596fa1e6d21 pubkey=2a47a1184bce04239b479851286a025e0705936248d56e43a15b2e88e13ccc51
│ participant id=76495f429dc1fdb289fa252e12e4be1521eb7d6bf00ed23d886c55a3b4063019 pubkey=4aabbfb4ceb393bb9a4bcac181334e07c7fef6ffd5037f8c755d7e2f1b0d0e22
│ participant id=875f38aae71ab60455415d46f43e05744accac1a5271ebfe95e6484cacf1730d pubkey=b0fb13901b6eca549f00ef3d69484435362b7b96efdd116b2693706c6d2a6025
```
### Create and send funds to the FROST wallet
#### Extract the FROST quorum verifying key and compose the watch‑only descriptors
```bash
FROST_AGG_KEY=$PX
FROST_EXT_DESC="tr($FROST_AGG_KEY)"
FROST_INT_DESC="tr($FROST_AGG_KEY,pk($FROST_AGG_KEY))"
echo $FROST_AGG_KEY
echo $FROST_EXT_DESC
echo $FROST_INT_DESC
│ 3e18b2b17af80180aa3c766a13b27bb0dfd724ad5f16107c54cf38557b1ea1ea
│ tr(3e18b2b17af80180aa3c766a13b27bb0dfd724ad5f16107c54cf38557b1ea1ea)
│ tr(3e18b2b17af80180aa3c766a13b27bb0dfd724ad5f16107c54cf38557b1ea1ea,pk(3e18b2b17af80180aa3c766a13b27bb0dfd724ad5f16107c54cf38557b1ea1ea))
```
#### Create the FROST wallet using the descriptors, and ask for its first address
```bash
FROST_ADDR=$(bdk-cli \
--network "$NETWORK" \
--datadir "$FROST_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$FROST_EXT_DESC" \
--int-descriptor "$FROST_INT_DESC" \
new_address | jq -r '.address')
echo "$FROST_ADDR" # bcrt1…
│ bcrt1p8sv2xry83lnwh2lsjcy49qgdp2qnq5r6rvgv2x9lqut9qj070y9srye47a
```
#### Fund the FROST address from the regular wallet
Send 100,000,000 satoshis (1 BTC) to the FROST address
```bash
# Compose PSBT
AMOUNT=100000000
SEND_PSBT=$(bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$REG_EXT_DESC" \
--int-descriptor "$REG_INT_DESC" \
create_tx \
--to ${FROST_ADDR}:${AMOUNT} \
--fee_rate 1.5 \
| jq -r '.psbt')
# Sign PSBT
SIGNED_PSBT=$(bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$REG_EXT_DESC" \
--int-descriptor "$REG_INT_DESC" \
sign "$SEND_PSBT" | jq -r '.psbt')
# Broadcast PSBT
TXID=$(bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$REG_EXT_DESC" \
--int-descriptor "$REG_INT_DESC" \
broadcast --psbt "$SIGNED_PSBT" | jq -r '.txid')
echo "$TXID"
│ 807d29f634525c562c8c784830159eef9dcf6b3d028c06e86978c6181cb36916
```
#### Mine a block to confirm the transaction
```bash
bitcoin-cli -regtest -generate 1
│ {
│ "address": "bcrt1qzcrkftrmetgcve8cdjnpflgggs24jl5ga8emql",
│ "blocks": [
│ "24cbfc4eb86f3a729edc4270dfdacc20b49cda1cf286ac820a6564288a291281"
│ ]
│ }
```
#### Refresh the regular wallet and verify the reduced balance
```bash
bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
sync
bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
balance
│ {}
│ {
│ "satoshi": {
│ "confirmed": 4899999845,
│ "immature": 0,
│ "trusted_pending": 0,
│ "untrusted_pending": 0
│ }
│ }
```
The new balance is 5,000,000,000 (original balance) - 100,000,000 (sent) - 155 (fee) = 4,899,999,845
#### Refresh the FROST wallet and verify the 100,000,000 sat balance
```bash
bdk-cli \
--network "$NETWORK" \
--datadir "$FROST_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$FROST_EXT_DESC" \
--int-descriptor "$FROST_INT_DESC" \
sync
bdk-cli \
--network "$NETWORK" \
--datadir "$FROST_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$FROST_EXT_DESC" \
--int-descriptor "$FROST_INT_DESC" \
balance
│ {}
│ {
│ "satoshi": {
│ "confirmed": 100000000,
│ "immature": 0,
│ "trusted_pending": 0,
│ "untrusted_pending": 0
│ }
│ }
```
### Create the unsigned FROST -> Regular transaction
#### Identify the unique UTXO we just received
This optional step guarantees the PSBT has exactly one input, so the later FROST‑signing code (which computes just one sighash) always works. If the FROST wallet owns multiple UTXOs the script aborts with a clear message instead of producing an unsignable PSBT.
```bash
# sanity‑check: For the purposes of this demo, the FROST wallet **must** have exactly one UTXO
UNSPENT=$(bdk-cli \
--network "$NETWORK" \
--datadir "$FROST_DIR" \
wallet \
--client-type rpc \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--database-type sqlite \
--ext-descriptor "$FROST_EXT_DESC" \
--int-descriptor "$FROST_INT_DESC" \
unspent \
)
COUNT=$(echo "$UNSPENT" | \
jq -r 'length')
echo $COUNT
if [ "$COUNT" -ne 1 ]; then
echo "Demo requires exactly one UTXO in the FROST wallet (found $COUNT)."; exit 1;
fi
FROST_UTXO=$(echo "$UNSPENT" | \
jq -r '.[0].outpoint')
echo $FROST_UTXO
│ 1
│ 807d29f634525c562c8c784830159eef9dcf6b3d028c06e86978c6181cb36916:0:1
```
#### Generate a fresh receive address in the regular wallet:
```bash
REG_NEW_ADDR=$(bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$REG_EXT_DESC" \
--int-descriptor "$REG_INT_DESC" \
new_address | jq -r '.address')
echo "$REG_NEW_ADDR" # should start with bcrt1…
│ bcrt1p3lpz54pglascakvcv5jz845kkq4cfpdqm5p3ze7fuxzv9cde7m2s42fyu3
```
#### Build the FROST -> Regular PSBT
- Selects the 100,000,000 sat UTXO the quorum just received,
- Constructs a one‑input / one‑output P2TR transaction,
- Pays 50,000,000 sat (0.5 BTC) to the new regular address, puts any remainder in a change output that still belongs to the FROST descriptor,
- Serializes everything as a base‑64 PSBT ready for signing.
```bash
AMOUNT=50000000
UNSIGNED_PSBT=$(bdk-cli \
--network "$NETWORK" \
--datadir "$FROST_DIR" \
wallet \
--client-type rpc \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--database-type sqlite \
--ext-descriptor "$FROST_EXT_DESC" \
--int-descriptor "$FROST_INT_DESC" \
create_tx \
--to ${REG_NEW_ADDR}:${AMOUNT} \
--fee_rate 1.5 \
--enable_rbf \
| jq -r '.psbt')
echo "$UNSIGNED_PSBT" > frost-to-reg.psbt
cat frost-to-reg.psbt
│ cHNidP8BAIkCAAAAARZpsxwYxnhp6AaMAj1rz53vnhUwSHiMLFZcUjT2KX2AAAAAAAD9////AuXv+gIAAAAAIlEgl7/CvG2SldTOfMQLpKWSgLUQtyIlmqLvKuIcgATFkiqA8PoCAAAAACJRII/CKlQo/2GO2ZhlJCPWlrArhIWg3QMRZ8nhhMLhufbVywAAAAABASsA4fUFAAAAACJRIDwYowyHj+brq/CWCVKBDQqBMFB6GxDFGL8HFlBJ/nkLIRY+GLKxevgBgKo8dmoTsnuw39ckrV8WEHxUzzhVex6h6gUAHd22HgEXID4YsrF6+AGAqjx2ahOye7Df1yStXxYQfFTPOFV7HqHqAAEFID4YsrF6+AGAqjx2ahOye7Df1yStXxYQfFTPOFV7HqHqAQYlAMAiID4YsrF6+AGAqjx2ahOye7Df1yStXxYQfFTPOFV7HqHqrCEHPhiysXr4AYCqPHZqE7J7sN/XJK1fFhB8VM84VXseoeolASRA4tTcr6kZllN2LAcRJlMowNT0NZERhuFBf3mQb8QwHd22HgAA
```
#### Extract the Taproot sighash the quorum must sign
Run the tool to extract the sighash from the PSBT.
⚠️ Run this in all participant terminals:
```bash
MSG=`sighash-helper < frost-to-reg.psbt`
echo $MSG # 64‑hex‑char message (the one FROST signs)
│ 5be7bc3d975086e51f1d9adea282b2a2df38a58551ebcdd6511eae308530c955
```
### Run the FROST signing ceremony
#### Stop and restart `frostd` to remove old sessions
```bash
frostd \
--tls-cert localhost+2.pem \
--tls-key localhost+2-key.pem
```
#### Start the ceremony with Alice acting as Coordinator
```bash
SIGNERS="$ALICE_PUBKEY,$BOB_PUBKEY"
printf '%s\n' "$MSG" | frost-client coordinator \
--group "$GROUP_ID" \
-s https://127.0.0.1:2744 \
-S "$SIGNERS" \
-m - \
-o sig.raw \
-c alice.toml
│ Taproot Option A active: verify shares under P, aggregate_with_tweak to Q (key‑path)
│ The message to be signed (hex encoded)
│ Taproot Option A: verifying shares under P, aggregating with tweak to Q (key‑path)
│ Logging in...
│ Creating signing session...
│ Note: Your key is included in --signers. Run 'frost-client participant' with your own config to contribute your commitments and signature share.
│ Waiting for participants to send their commitments...
│ Sending SigningPackage to participants...
│ Waiting for participants to send their SignatureShares...
│ ......
```
#### Add Alice as a participant
Alice also needs to act as a participant:
```bash
frost-client participant \
--group "$GROUP_ID" \
-s https://127.0.0.1:2744 \
-c alice.toml
│ Taproot Option A active: using standard FROST (no rerandomization), P for challenge
│ Taproot participant: computing challenge with Q via sign_with_tweak (no rerandomization)
│ Logging in...
│ Joining signing session...
│ Sending commitments to coordinator...
│ Waiting for coordinator to send signing package...
```
#### Add Bob as the other participant
Bob is the other signer:
```bash
frost-client participant \
--group "$GROUP_ID" \
-s https://127.0.0.1:2744 \
-c bob.toml
│ Taproot Option A active: using standard FROST (no rerandomization), P for challenge
│ Taproot participant: computing challenge with Q via sign_with_tweak (no rerandomization)
│ Logging in...
│ Joining signing session...
│ Sending commitments to coordinator...
│ Waiting for coordinator to send signing package..
```
#### Participants consent to the signing
Alice's terminal:
```bash
│ Signing package received
│ Message to be signed (hex-encoded):
│ b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
│ Do you want to sign it? (y/n)
y
│ Sending signature share to coordinator...
│ Done
```
Bob's terminal:
```bash
│ Signing package received
│ Message to be signed (hex-encoded):
│ b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
│ Do you want to sign it? (y/n)
y
│ Sending signature share to coordinator...
│ Done
```
Coordinator terminal:
```bash
Taproot Option A: verifying shares under P, aggregating with tweak to Q (key‑path)
Raw signature written to sig.raw
```
#### Get the Signature
The coordinator has written out the 64-byte signature file:
```bash
ls -l sig.raw
-rw-r--r-- 1 wolf staff 64 Jul 30 03:33 sig.raw
```
Hex‑encode the raw signature so the helper below can accept it
```bash
SIG_HEX=$(xxd -p sig.raw | tr -d '\n')
echo $SIG_HEX
│ ccac4c56ffadbc17d87fc268790dfceb893548e91e9e74c9293d228bd2a3c40cbe5022027a1cbba138f2d807b6db385ba2d45dedda29b539be89c884023bac4c
```
### Attach and send the signed transaction
#### Attach the FROST signature to the PSBT
```bash
SIGNED_PSBT=$(cat frost-to-reg.psbt | psbt-sig-attach "$SIG_HEX")
echo "$SIGNED_PSBT" > frost-to-reg.signed.psbt
cat frost-to-reg.signed.psbt
| cHNidP8BAIkCAAAAARZpsxwYxnhp6AaMAj1rz53vnhUwSHiMLFZcUjT2KX2AAAAAAAD9////AuXv+gIAAAAAIlEgl7/CvG2SldTOfMQLpKWSgLUQtyIlmqLvKuIcgATFkiqA8PoCAAAAACJRII/CKlQo/2GO2ZhlJCPWlrArhIWg3QMRZ8nhhMLhufbVywAAAAABASsA4fUFAAAAACJRIDwYowyHj+brq/CWCVKBDQqBMFB6GxDFGL8HFlBJ/nkLARNAzKxMVv+tvBfYf8JoeQ3864k1SOkennTJKT0ii9KjxAy+UCICehy7oTjy2Ae22zhbotRd7doptTm+iciEAjusTCEWPhiysXr4AYCqPHZqE7J7sN/XJK1fFhB8VM84VXseoeoFAB3dth4BFyA+GLKxevgBgKo8dmoTsnuw39ckrV8WEHxUzzhVex6h6gABBSA+GLKxevgBgKo8dmoTsnuw39ckrV8WEHxUzzhVex6h6gEGJQDAIiA+GLKxevgBgKo8dmoTsnuw39ckrV8WEHxUzzhVex6h6qwhBz4YsrF6+AGAqjx2ahOye7Df1yStXxYQfFTPOFV7HqHqJQEkQOLU3K+pGZZTdiwHESZTKMDU9DWREYbhQX95kG/EMB3dth4AAA==
```
#### Finalize the PSBT
```bash
FINAL_PSBT=$(bdk-cli \
--network "$NETWORK" \
--datadir "$FROST_DIR" \
wallet \
--client-type rpc \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--database-type sqlite \
--ext-descriptor "$FROST_EXT_DESC" \
--int-descriptor "$FROST_INT_DESC" \
finalize_psbt $(< frost-to-reg.signed.psbt) \
| jq -r '.psbt')
echo $FINAL_PSBT > frost-to-reg.final.psbt
cat frost-to-reg.final.psbt
│ cHNidP8BAIkCAAAAARZpsxwYxnhp6AaMAj1rz53vnhUwSHiMLFZcUjT2KX2AAAAAAAD9////AuXv+gIAAAAAIlEgl7/CvG2SldTOfMQLpKWSgLUQtyIlmqLvKuIcgATFkiqA8PoCAAAAACJRII/CKlQo/2GO2ZhlJCPWlrArhIWg3QMRZ8nhhMLhufbVywAAAAABASsA4fUFAAAAACJRIDwYowyHj+brq/CWCVKBDQqBMFB6GxDFGL8HFlBJ/nkLAQhCAUDMrExW/628F9h/wmh5DfzriTVI6R6edMkpPSKL0qPEDL5QIgJ6HLuhOPLYB7bbOFui1F3t2im1Ob6JyIQCO6xMAAEFID4YsrF6+AGAqjx2ahOye7Df1yStXxYQfFTPOFV7HqHqAQYlAMAiID4YsrF6+AGAqjx2ahOye7Df1yStXxYQfFTPOFV7HqHqrAAA
```
#### Broadcast the finalized transaction
```bash
TXID=$(bdk-cli \
--network "$NETWORK" \
--datadir "$FROST_DIR" \
wallet \
--client-type rpc \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--database-type sqlite \
--ext-descriptor "$FROST_EXT_DESC" \
--int-descriptor "$FROST_INT_DESC" \
broadcast \
--psbt "$FINAL_PSBT" | \
jq -r '.txid')
echo $TXID
│ 65c5017da99c6b775e25ab5195d62bc9e0ab1131e1d45f437db43f6de11183f5
```
#### Confirm the FROST transaction
Now that the FROST transaction has been broadcast, we need to mine a block to confirm it on the regtest blockchain:
```bash
bitcoin-cli -regtest -generate 1
│ {
│ "address": "bcrt1qgpp7x8d2as2n8tefdju674j87acj0z4w9paz3r",
│ "blocks": [
│ "1018c8dd8148e732310fb488e80b881012f77348555c5931285bf5fa766ce6f1"
│ ]
│ }
```
#### Verify the regular wallet received the funds
Now let's sync the regular wallet and verify it received the 50,000,000 satoshis from the FROST transaction:
```bash
bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$REG_EXT_DESC" \
--int-descriptor "$REG_INT_DESC" \
sync
bdk-cli \
--network "$NETWORK" \
--datadir "$REG_DIR" \
wallet \
--client-type rpc \
--database-type sqlite \
--url "$RPC_URL" \
-a "$RPC_AUTH" \
--ext-descriptor "$REG_EXT_DESC" \
--int-descriptor "$REG_INT_DESC" \
balance
│ {}
│ {
│ "satoshi": {
│ "confirmed": 4949999845,
│ "immature": 0,
│ "trusted_pending": 0,
│ "untrusted_pending": 0
│ }
│ }
```
New balance = 4,899,999,845 (old balance) + 50,000,000 (received) = 4,949,999,845
### Summary
The demonstration is now complete! We have successfully:
1. ✅ **Broadcast the FROST transaction** - The multi-signature transaction was created and broadcast to the regtest network
2. ✅ **Confirmed the transaction** - The transaction was mined into a block and now has 1 confirmation
3. ✅ **Verified fund receipt** - The regular wallet's balance increased by exactly 50,000,000 satoshis
The FROST signature scheme has been successfully demonstrated end-to-end, showing how a threshold signature (2-of-3) can be used to spend Bitcoin in a Taproot transaction on the regtest network.