Skip to content

Instantly share code, notes, and snippets.

View sanket1729's full-sized avatar
💭
Bitcoin Minimalist

Sanket Kanjalkar sanket1729

💭
Bitcoin Minimalist
View GitHub Profile
@sanket1729
sanket1729 / notes.txt
Created September 7, 2023 15:10
bdk wallet for PO_VAULT
rust-bitcoin:
- OP_VAULT: Add opcode support, support for creating basic VAULT scripts (can also be done in rust-miniscript)
- OP_CTV: Add opcode support, support creating transaction hash
rust-miniscript:
- Vault descriptor construction:
- Recovery descriptor construction:
bdk:
- sycning descriptors. (vault and recovery).
@sanket1729
sanket1729 / weights.json
Last active August 3, 2023 21:55
New jet weights
{
"Add16": 78.1200463950235,
"Add32": 81.328125,
"Add64": 82.70625,
"Add8": 58.98373315072345,
"All16": 45.49776333874612,
"All32": 67.3492669616389,
"All64": 66.5235294117647,
"All8": 58.224245667598524,
"And16": 84.74355405586726,
class Solution:
def minimizeArrayValue(self, nums: List[int]) -> int:
total_sum = 0
ans = 0
for i, v in enumerate(nums):
capacity = ans * (i + 1)
total_sum += v
# Can we accomodate last value within current answer
if total_sum > capacity:
# Restribute equally.
@sanket1729
sanket1729 / jet_benches.json
Created March 7, 2023 22:03
Benchmarks for jets
{
"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

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
#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
@sanket1729
sanket1729 / create_spend_info.rs
Last active March 26, 2022 10:29
Creating Spend Info from Tree sturcture
// 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

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

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