Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Bitcoin Minimalist

Sanket Kanjalkar sanket1729

💭
Bitcoin Minimalist
View GitHub Profile
@sanket1729
sanket1729 / jet_benches.json
Created March 7, 2023 22:03
Benchmarks for jets
View jet_benches.json
{
"Add32": 60.6159814446884,
"AnnexHash": 211.09026343236047,
"AssetAmountHash": 180.8254919736737,
"Bip0340Verify": 45984.13321032714,
"BuildTapbranch": 1435.412867661228,
"BuildTapleafSimplicity": 1015.4756900209926,
"CalculateAsset": 360.06007299543614,
"CalculateConfidentialToken": 350.8989606414178,
"CalculateExplicitToken": 348.558227539948,
@sanket1729
sanket1729 / jets_worst_case_env.md
Last active March 7, 2023 20:22
Worst case environments for jets
View jets_worst_case_env.md

Methodolody:

Run each jet for the selected input and choose the worst case amongst those inputs. For example, when running Add32, we run bench 50 random inputs and select the worst case amongst those

Jets based on Bits

  • Verify, Random inputs,
  • Low32, Random inputs,
  • Eq32, Both numbers equal,
  • Eq256, Both numbers equal,
  • Le32, Random inputs,
@sanket1729
sanket1729 / psbt_sign.txt
Last active August 18, 2022 06:50
psbt test cases
View psbt_sign.txt
#unsigned_psbt,signed_psbt,(pk;sk,)*
70736274ff01005202000000014f1081b4b3f3527113058a48b6fd84d968f212c1c0d334d637f77d294b3289f80100000000010000000148d5f50500000000160014b6e35acec5146ef531a6372137cd45f104f8f8f8da0e995f0001011f00e1f50500000000160014773dfa9e21789bf357c19b7db8a4c7df97d930c6220603ab1ac1872a38a2f196bed5a6047f0da2c8130fe8de49fc4d5dfb201f7611d8e204773dfa9e0000,70736274ff01005202000000014f1081b4b3f3527113058a48b6fd84d968f212c1c0d334d637f77d294b3289f80100000000010000000148d5f50500000000160014b6e35acec5146ef531a6372137cd45f104f8f8f8da0e995f0001011f00e1f50500000000160014773dfa9e21789bf357c19b7db8a4c7df97d930c6220203ab1ac1872a38a2f196bed5a6047f0da2c8130fe8de49fc4d5dfb201f7611d8e24830450221009f58243e91c0272fe8f617bba3d05d4d3f3112ad30bfcb83053a353f38b1cc8102202bbbb144a78090840132ffabb3fc6aa193c1346e29d9444a156e799d605fcd6901220603ab1ac1872a38a2f196bed5a6047f0da2c8130fe8de49fc4d5dfb201f7611d8e204773dfa9e0000,03ab1ac1872a38a2f196bed5a6047f0da2c8130fe8de49fc4d5dfb201f7611d8e2;cMeb8vatuSpDLwokavVgGWFc2gF8xKDRfA
@sanket1729
sanket1729 / seattle-bitcoin.md
Last active June 17, 2022 00:53
Socratic Reading list
View seattle-bitcoin.md
@sanket1729
sanket1729 / create_spend_info.rs
Last active March 26, 2022 10:29
Creating Spend Info from Tree sturcture
View create_spend_info.rs
// Some user struct for trees
enum Tree {
Node(Tree,Tree),
Leaf(Miniscript),
}
impl Tree {
fn update_builder(&self, builder: TaprootBuilder, depth: usize) -> TaprootBuilder {
match self {
@sanket1729
sanket1729 / psbt-musig2.md
Last active June 15, 2022 22:08
Psbt musig2 signing
View psbt-musig2.md

Musig2 signing in Psbt

New fields required:

  • PSBT_IN_MUSIG_PARTICIPANT_PUBLIC_KEYS: (<x_only_pk(agg_pk_to_sign)><x_only_pk(agg_pk)>) -> <[x_only_pk]*>: For example, (a, b) -> [c] where b = Musig2_KeyAgg([c]) and a is a tweaked(BIP32 tweak or x-only tweak or both) key derived from b where the tweaking information is present in PSBT_IN_TAP_BIP32_DERIVATION in case of BIP32 tweak. In case, a is the output key, an additional BIP341 tweak is applied. The tweak information is provided in PSBT_IN_TAP_INTERNAL_KEY or PSBT_IN_TAP_MERKLE_ROOT. The full xpub for the aggregated agg_pk can be provided in PBST_GLOBAL_XPUB field

  • PSBT_IN_TAP_MUSIG2_PUB_NONCE: (<x_only_pk(participant_key), x_only_pk(agg_pk_to_sign), leaf_hash>) -> <pub_nonce> (serialized pub_nonce including R1 and R2).

  • PSBT_IN_TAP_PARTIAL_SIGNATURE: (<x_only_pk(participant_key), x_only_pk(agg_pk_to_sign), leaf_hash>) -> <partial_sig> (serialized partial_sig)

Aggregating pubkeys and tweaking:

@sanket1729
sanket1729 / output_desc.md
Created February 15, 2022 10:59
Classification of output descriptors
View output_desc.md

Output Descriptors

Descriptor Trait/Typeclass:

Table of API on along the rows, and columns showing the descriptor type. Each box represents

  • y = always succeeds
  • n = always fails
  • yn = may succeed

All descriptors sh/wsh/shwsh/tr/bare support miniscript descriptors

View temp.rs
let ms = match desc {
Descriptor::Sh(ref sh) => {
match sh.as_inner(){
ShInner::Wsh(wsh ) => {
match wsh.as_inner() {
WshInner::Ms(ref ms) => ms
}
}
}
}
View thakns_rustc.rs
error[E0308]: mismatched types
--> src/test_random_miniscripts.rs:32:44
|
32 | let ms: Result<_, ()> = ms.translate_pk(
| ^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `FnOnce<(&std::string::String,)>`
found type `FnOnce<(&std::string::String,)>`
View temp.rs
// Miniscript
// Written in 2018 by
// Andrew Poelstra <apoelstra@wpsoftware.net>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication