Skip to content

Instantly share code, notes, and snippets.

View kcalvinalvin's full-sized avatar

Calvin Kim kcalvinalvin

View GitHub Profile
@kcalvinalvin
kcalvinalvin / utreexo-validation-v0.4.1.md
Created May 19, 2025 05:13
Verifying a block as an utreexo compact state node for v0.4.1

Verifying a bitcoin block as an utreexo compact state node

A utreexo compact state node doesn't have all the data required for verifying a bitcoin block just with the block. It also requires a utreexo proof.

The method described here is only valid for utreexod v0.4.1. The next version will have a different P2P messaging flow.

For v0.4.1, to get the necessary utreexo data, one must ask for a MSG_UTREEXO_BLOCK when constructing the getdata. Since we also want segwit blocks as well, we use the

@kcalvinalvin
kcalvinalvin / utreexo-algorithms.md
Last active May 16, 2025 08:04
Utreexo algorithms

Add

Utreexo accumulator is a collection of proper merkle trees. All the merkle trees have 2 children or none.

Below is an example of adding 7 leaves to the tree. You can run the code I used to generate this at https://go.dev/play/p/um5263SDk59

This is an accumulator with 1 leaf. It has 1 root, which is also a leaf.

@kcalvinalvin
kcalvinalvin / sanity_test.go
Created August 29, 2022 06:41
Test function to verify that the code is incorrect
package patriciaaccumulator
import (
"encoding/hex"
"fmt"
"os"
"path/filepath"
"testing"
)
@kcalvinalvin
kcalvinalvin / reproduce-results.patch
Last active August 29, 2022 06:32
Patch to reproduce the results of the blog
diff --git a/bridgenode/genproofs.go b/bridgenode/genproofs.go
index 36f1117..cca31b8 100644
--- a/bridgenode/genproofs.go
+++ b/bridgenode/genproofs.go
@@ -110,6 +110,7 @@ func BuildProofs(
logrus.SetOutput(logfile)
logrus.SetLevel(logrus.InfoLevel)
for ; height != knownTipHeight && !stop; height++ {
+ fmt.Println("on block", height)