# DEMO: FROST Signing Using bdk-cli
Please see the [additional notes](https://hackmd.io/@bc-community/H1MfEMdvel) document for further explanation.
## 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`, and `trusted-dealer`.
- This demo only uses `trusted-dealer`, `coordinator`, and `participant`.
```bash
cargo install --path frost-client
ls -l `which frost-client`
ls -l `which coordinator`
ls -l `which participant`
│ -rwxr-xr-x 1 wolf staff 11487368 Jul 23 23:04 /Users/wolf/.cargo/bin/frost-client
│ -rwxr-xr-x 1 wolf staff 7275296 Jul 23 23:04 /Users/wolf/.cargo/bin/coordinator
│ -rwxr-xr-x 1 wolf staff 6893128 Jul 23 23:04 /Users/wolf/.cargo/bin/participant
```
All should have the same timestamp.
### Set Up Bitcoin Core on Regtest
```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
```
Start node. Remove `-daemon` to run in the foreground:
```bash
bitcoind -daemon
```
The daemon is now listening on 127.0.0.1:18443.
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": "bcrt1qdu3ul3sn5jnjkd9w8fesvd44ttp6nw6m7f49nz",
│ "blocks": [
│ "46b049c234615f15802869fd18e83a4952675b8ffb2ffa5bf4bcd17db8e404b2",
│ "53cd6be05b9f4345dc1e87675724c9d06c062b01c7841a7f7357c552746b664d",
│ "271d629db3565bfa86ea692f38658ae7d88aec1999b369f2d9d90a579852338c",
| ...
│ ]
│ }
```
### Build 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 ..
```
### Build the PSBT signature attachment 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 ..
```
## Demo Steps
### 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 – no scheme
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"
```
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.
### Set up the regular wallet
#### 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([e6e99e4b/86h/1h/0h]tprv8ZgxMBicQKsPdgEtboZzk7ng5miG5xeavu356nC2uz17i5yshHDjqETH2Z7szsV2yeNHTgqR79Y7sG3VTRGE73Hkyf4QnGnhDRwWPcmTzmy/0/*)
│ tr([e6e99e4b/86h/1h/0h]tprv8ZgxMBicQKsPdgEtboZzk7ng5miG5xeavu356nC2uz17i5yshHDjqETH2Z7szsV2yeNHTgqR79Y7sG3VTRGE73Hkyf4QnGnhDRwWPcmTzmy/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…
│ bcrt1pcl0hfx0fx477aluwnqtquzh7lk9zeg9k8ehrmcvv77mqm6gpz52q9ct3nv
```
#### Mine a block straight into that address
```bash
bitcoin-cli -regtest generatetoaddress 1 "$REG_ADDR"
│ [
│ "727e4c795ca6257d9b23c5c115ce0b356ca7f6b70fd9c1b0d8a3682898d61d72"
│ ]
```
#### Mine 100 more blocks to mature the block reward
```bash
bitcoin-cli -regtest -generate 100
│ {
│ "address": "bcrt1q24k5zr20yl5gypk4qxq6eygueapdkk7s4e85nm",
│ "blocks": [
│ "4982662951f532709abe2fdbb824bc9386fced6489346cfc21d1fb3c9c7c98dc",
│ "3550e187e71018cd0fc93653d6b84659e7071c79efc29e2c1a6088d2e54923a9",
│ "111fc56aa82c53d3ba08e49f585d2a5bc4d6d1b28b1dec4020a5743fe85395ff",
│ ...
│ ]
│ }
```
#### 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 a FROST wallet
#### Generate the FROST key material
```bash
trusted-dealer -t 2 -n 3 -C secp256k1-tr
│ Generating 3 shares with threshold 2...
│ Public key package written to public-key-package.json
│ Key package for participant 0000000000000000000000000000000000000000000000000000000000000001 written to key-package-1.json
│ Key package for participant 0000000000000000000000000000000000000000000000000000000000000002 written to key-package-2.json
│ Key package for participant 0000000000000000000000000000000000000000000000000000000000000003 written to key-package-3.json
```
#### Extract the FROST quorum verifying key and compose the watch‑only descriptors
```bash
FROST_AGG_KEY=$(jq -r '.verifying_key' public-key-package.json)
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
│ 0234a8469ccafbb338e6b49e010437ad97fb807e207450f2e363d117f33a848a7e
│ tr(0234a8469ccafbb338e6b49e010437ad97fb807e207450f2e363d117f33a848a7e)
│ tr(0234a8469ccafbb338e6b49e010437ad97fb807e207450f2e363d117f33a848a7e,pk(0234a8469ccafbb338e6b49e010437ad97fb807e207450f2e363d117f33a848a7e))
```
#### Create the FROST wallet dir 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…
│ bcrt1pjgqmag7t2hhsrftnhkvtvv2jjj0gvv6jxr9ey8udz96hqj5tam4sfgna9p
```
### 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"
│ 4e4b7b01304dbd3f572ad010f8c523229debf0758181ab4d3a924085457a9fa8
```
#### Mine a block to confirm the transaction
```bash
bitcoin-cli -regtest -generate 1
│ {
│ "address": "bcrt1q7z57tk3p69x4vqrqwyfmltqva92ekv38shknzm",
│ "blocks": [
│ "4b95a781723924f054178b3a096e58c6239ba7e50764d2b94abd01d58bcb15ff"
│ ]
│ }
```
#### 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
│ }
│ }
```
### 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
│ 4e4b7b01304dbd3f572ad010f8c523229debf0758181ab4d3a924085457a9fa8:1
```
### Build the one‑input / one‑output PSBT the quorum will sign
#### 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…
│ bcrt1pd0k9zz60edjz4ghzw5c6e6ku99uq94mtufdwehhpz9erldc8g4hsd53kpn
```
#### Create the Frost-to-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
│ cHNidP8BAIkCAAAAAaifekWFQJI6TauBgXXw650iI8X4ENAqVz+9TTABe0tOAQAAAAD9////AoDw+gIAAAAAIlEga+xRC0/LZCqi4nUxrOrcKXgC12viWuze4RFyP7cHRW/l7/oCAAAAACJRIN+yTIN+efwitUkIc4GHxE9ZZGAjE27GZb8FnB/kuEM21QAAAAABASsA4fUFAAAAACJRIJIBvqPLVe8BpXO9mLYxUpSehjNSMMuSH40RdXBKi+7rIRY0qEacyvuzOOa0ngEEN62X+4B+IHRQ8uNj0RfzOoSKfgUA8CBnUwEXIDSoRpzK+7M45rSeAQQ3rZf7gH4gdFDy42PRF/M6hIp+AAABBSA0qEacyvuzOOa0ngEEN62X+4B+IHRQ8uNj0RfzOoSKfgEGJQDAIiA0qEacyvuzOOa0ngEEN62X+4B+IHRQ8uNj0RfzOoSKfqwhBzSoRpzK+7M45rSeAQQ3rZf7gH4gdFDy42PRF/M6hIp+JQGk1hVryb7zVrhP4p6DBMbt1rLjCaHEI8+tfb77lFAoMfAgZ1MA
```
#### Extract the Taproot sighash the quorum must sign
Run the tool to extract the sighash from the PSBT.
```bash
sighash-helper < frost-to-reg.psbt > sighash.hex
cat sighash.hex # 64‑hex‑char message (the one FROST signs)
│ 5be7bc3d975086e51f1d9adea282b2a2df38a58551ebcdd6511eae308530c955
```
`sighash-helper` prints the digest as hex for readability, so convert it back to binary before starting the FROST ceremony:
```bash
xxd -r -p sighash.hex sighash.bin
ls -l sighash.bin # 32‑byte binary file
-rw-r--r-- 1 wolf staff 32 Jul 30 03:31 sighash.bin
```
### Run the FROST ceremony
#### Coordinator Terminal
```bash
coordinator -n 2 -m sighash.bin -s sig.raw -C secp256k1-tr
│ Reading public key package from public-key-package.json
│ Reading message from sighash.bin...
│ Processing randomizer []
│ Waiting for participants to send their commitments...
```
#### Round 1: Participants send their commitments, coordinator sends signing package
##### Participant 1 Terminal
```bash
participant -k key-package-1.json -C secp256k1-tr
│ Reading key package from key-package-1.json
│ Connected to server at [1.R.0] 127.0.0.1:443
```
##### Participant 2 Terminal
```bash
participant -k key-package-2.json -C secp256k1-tr
│ Reading key package from key-package-2.json
│ Connected to server at [1.R.0] 127.0.0.1:443
```
##### Coordinator Terminal
```bash
│ Client connected
│ Received: {"IdentifiedCommitments":{"identifier":"0000000000000000000000000000000000000000000000000000000000000001","commitments":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"hiding":"0260ca8879ebde732c231e6da99ab43dc5bdeb5a1af4617678b337f263de4ca555","binding":"029a1cf127ba79d4a823768eeb112b6f50a68cfb877248d701fb45692668280eaf"}}}
│ Client connected
│ Received: {"IdentifiedCommitments":{"identifier":"0000000000000000000000000000000000000000000000000000000000000002","commitments":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"hiding":"035b5b0f23d7e936bc70190daa1b7bd33d49d00c8fa8f1041dd1a271ca8e28d5cc","binding":"03485a927d812fc5e92bed28e072ef7e68a0c6e54ab5660454b04239ca2a16a2e6"}}}
│ ✅ SigningPackage will use tweaked key Q (pub_key_package left on P)
│ Internal key (P): 34a8469ccafbb338e6b49e010437ad97fb807e207450f2e363d117f33a848a7e
│ Tweaked key (Q): 9201bea3cb55ef01a573bd98b63152949e86335230cb921f8d1175704a8beeeb
│ 📦 SigningPackage created for Taproot with:
│ Internal key (P): 34a8469ccafbb338e6b49e010437ad97fb807e207450f2e363d117f33a848a7e
│ Tweaked key (Q): 9201bea3cb55ef01a573bd98b63152949e86335230cb921f8d1175704a8beeeb
│ Challenge computation will use Q via secp256k1-tr ciphersuite
│ Warning: Public key package key doesn't match computed tweaked key
│ Package key: 34a8469ccafbb338e6b49e010437ad97fb807e207450f2e363d117f33a848a7e
│ Computed tweaked key: 9201bea3cb55ef01a573bd98b63152949e86335230cb921f8d1175704a8beeeb
│ Applied BIP-341 Taproot tweak for secp256k1-tr signing
│ Internal key (x-only): 34a8469ccafbb338e6b49e010437ad97fb807e207450f2e363d117f33a848a7e
│ Tweak scalar: ef1a0028d46c8c91c5c9ecbb01072d52d4059e98a11dfc7c842230facd866dea
│ Tweaked key (x-only): 9201bea3cb55ef01a573bd98b63152949e86335230cb921f8d1175704a8beeeb
│ Sending SigningPackage to participants...
│ Waiting for participants to send their SignatureShares...
```
#### Round 2: Participants partially sign the messagem, coordinator finalizes the signature
##### Participant 1 Terminal
```bash
│ Received: {"SigningPackageAndRandomizer":{"signing_package":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"signing_commitments":{"0000000000000000000000000000000000000000000000000000000000000001":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"hiding":"0260ca8879ebde732c231e6da99ab43dc5bdeb5a1af4617678b337f263de4ca555","binding":"029a1cf127ba79d4a823768eeb112b6f50a68cfb877248d701fb45692668280eaf"},"0000000000000000000000000000000000000000000000000000000000000002":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"hiding":"035b5b0f23d7e936bc70190daa1b7bd33d49d00c8fa8f1041dd1a271ca8e28d5cc","binding":"03485a927d812fc5e92bed28e072ef7e68a0c6e54ab5660454b04239ca2a16a2e6"}},"message":"5be7bc3d975086e51f1d9adea282b2a2df38a58551ebcdd6511eae308530c955"},"randomizer":"ef1a0028d46c8c91c5c9ecbb01072d52d4059e98a11dfc7c842230facd866dea"}}
│ Message to be signed (hex-encoded):
│ 5be7bc3d975086e51f1d9adea282b2a2df38a58551ebcdd6511eae308530c955
│ Do you want to sign it? (y/n)
y
| Done
```
##### Participant 2 Terminal
```bash
│ Received: {"SigningPackageAndRandomizer":{"signing_package":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"signing_commitments":{"0000000000000000000000000000000000000000000000000000000000000001":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"hiding":"0260ca8879ebde732c231e6da99ab43dc5bdeb5a1af4617678b337f263de4ca555","binding":"029a1cf127ba79d4a823768eeb112b6f50a68cfb877248d701fb45692668280eaf"},"0000000000000000000000000000000000000000000000000000000000000002":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"hiding":"035b5b0f23d7e936bc70190daa1b7bd33d49d00c8fa8f1041dd1a271ca8e28d5cc","binding":"03485a927d812fc5e92bed28e072ef7e68a0c6e54ab5660454b04239ca2a16a2e6"}},"message":"5be7bc3d975086e51f1d9adea282b2a2df38a58551ebcdd6511eae308530c955"},"randomizer":"ef1a0028d46c8c91c5c9ecbb01072d52d4059e98a11dfc7c842230facd866dea"}}
│ Message to be signed (hex-encoded):
│ 5be7bc3d975086e51f1d9adea282b2a2df38a58551ebcdd6511eae308530c955
│ Do you want to sign it? (y/n)
y
| Done
```
##### Coordinator Terminal
```bash
│ Received: {"SignatureShare":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"share":"70a2109e569a94e3776240c89bf1a9bccd2bc7db000ec53beec3261f6de4004c"}}
│ Client disconnected
│ Received: {"SignatureShare":{"header":{"version":0,"ciphersuite":"FROST-secp256k1-SHA256-TR-v1"},"share":"ec63fd1bf7d3154d3b02c845891058bba15f92324ab4de8de97dda979dc4c5fc"}}
│ Client disconnected
│ Raw signature written to sig.raw
```
##### Demo Terminal
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
│ feb06dceaab09413b6130b0afd170886bb18c6815740ac0e31c3111be3cf1d6d5d060dba4e6daa30b265090e25020279b3dc7d269b7b038e186ea22a3b728507
```
### 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
| cHNidP8BAIkCAAAAAaifekWFQJI6TauBgXXw650iI8X4ENAqVz+9TTABe0tOAQAAAAD9////AoDw+gIAAAAAIlEga+xRC0/LZCqi4nUxrOrcKXgC12viWuze4RFyP7cHRW/l7/oCAAAAACJRIN+yTIN+efwitUkIc4GHxE9ZZGAjE27GZb8FnB/kuEM21QAAAAABASsA4fUFAAAAACJRIJIBvqPLVe8BpXO9mLYxUpSehjNSMMuSH40RdXBKi+7rARNA/rBtzqqwlBO2EwsK/RcIhrsYxoFXQKwOMcMRG+PPHW1dBg26Tm2qMLJlCQ4lAgJ5s9x9Jpt7A44YbqIqO3KFByEWNKhGnMr7szjmtJ4BBDetl/uAfiB0UPLjY9EX8zqEin4FAPAgZ1MBFyA0qEacyvuzOOa0ngEEN62X+4B+IHRQ8uNj0RfzOoSKfgAAAQUgNKhGnMr7szjmtJ4BBDetl/uAfiB0UPLjY9EX8zqEin4BBiUAwCIgNKhGnMr7szjmtJ4BBDetl/uAfiB0UPLjY9EX8zqEin6sIQc0qEacyvuzOOa0ngEEN62X+4B+IHRQ8uNj0RfzOoSKfiUBpNYVa8m+81a4T+KegwTG7day4wmhxCPPrX2++5RQKDHwIGdTAA==
```
### 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
│ cHNidP8BAIkCAAAAAaifekWFQJI6TauBgXXw650iI8X4ENAqVz+9TTABe0tOAQAAAAD9////AoDw+gIAAAAAIlEga+xRC0/LZCqi4nUxrOrcKXgC12viWuze4RFyP7cHRW/l7/oCAAAAACJRIN+yTIN+efwitUkIc4GHxE9ZZGAjE27GZb8FnB/kuEM21QAAAAABASsA4fUFAAAAACJRIJIBvqPLVe8BpXO9mLYxUpSehjNSMMuSH40RdXBKi+7rAQhCAUD+sG3OqrCUE7YTCwr9FwiGuxjGgVdArA4xwxEb488dbV0GDbpObaowsmUJDiUCAnmz3H0mm3sDjhhuoio7coUHAAABBSA0qEacyvuzOOa0ngEEN62X+4B+IHRQ8uNj0RfzOoSKfgEGJQDAIiA0qEacyvuzOOa0ngEEN62X+4B+IHRQ8uNj0RfzOoSKfqwA
```
### Broadcast the final 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
│ 8ec5421b7c87fa8e6b6627e217a509b638dfda833bf505144566ae3a7c0a159b
```
### Confirm the FROST transaction on regtest
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": "bcrt1qpnrls23gdgua7c2qaraeeve3nd22mq9td8ypnk",
│ "blocks": [
│ "17c84d695086817977caf4f26432d7063f254785b92a2dc5badc1129f110f018"
│ ]
│ }
```
### 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.