Skip to content

Instantly share code, notes, and snippets.

View msinkec's full-sized avatar
🤓

Mihael Šinkec msinkec

🤓
View GitHub Profile
@msinkec
msinkec / example.txt
Last active March 3, 2024 07:11
TSS Example
Deployed contract: 3c0d8b44f8740a0c45162fa6bb6835808b9b04a884853fcb597af1a0812d6345
tx: 010000000145632d81a0f17a59cb3f8584a8049b8b803568bba62f16450c0a74f8448b0d3c0000000000ffffffff0184030000000000001976a91446f320a7e7325a41829e13b016f1dfceee8ab37388ac00000000
sighash preimage: 01000000d544095762018685b1125f75040495deae1a6a78063ca09313aa0f827c6618a43bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e7066504445632d81a0f17a59cb3f8584a8049b8b803568bba62f16450c0a74f8448b0d3c000000001976a914f2a684c7ada5dd4c447ce03f2e50990c0e181f0488ace803000000000000ffffffff4657a850644e1a190c4b06bf681443752eddb949cce4c81751db4c45c61052990000000041000000
sighash f7ab4253b131f70e698051aa621d1ae09665500ef4580d0d2decbc0d4b863671
Sig (r, s): 114836438995585026443311608703469012746226023187493091108812467319065332271518 46571976558762956347626225494771745362039354849912631975526154502213652815393
Sig (hex): 3045022100fde31f027463d4390a9a575f9f5939d602da393c55e8f5b0a31d246d6595c99e022066f6cdfb03abc3b27ab4f88c501f9388ed25602dab53f9d67
@msinkec
msinkec / steg_latex.md
Last active March 1, 2024 11:16
Embedding a Secret Message in a PDF through LaTeX

This gist outlines a method to embed a secret message within a LaTeX document through the use of variable length spaces, ultimately rendered in a PDF. This technique is a form of steganography, allowing information to be hidden in plain sight, with the secret message being undetectable to casual observation.

Generating the LaTeX File with a Secret Message

The first step involves creating a Python script that processes a given text (the content of the LaTeX file) and a secret message. This script converts the secret message into a binary string, where each bit (0 or 1) corresponds to a specific spacing in the LaTeX document. The spaces are not uniform; 0 might correspond to a smaller space, while 1 corresponds to a larger space. This variation in spacing is subtle and typically unnoticed by readers, but it can be used to encode binary data.

Below is a simplified version of the Python script that generates a LaTeX file embedding a secret message:

content = '''Your document content goes here...'''
@msinkec
msinkec / unknownPrivkeySig.ts
Created February 13, 2024 10:50
Create Sig and PubKey with unknown PrivKey
import { bsv } from 'scrypt-ts'
async function main() {
const m = bsv.PrivateKey.fromRandom().bn
const hBuff = bsv.crypto.Hash.sha256(m.toBuffer())
const h = bsv.crypto.BN.fromBuffer(hBuff)
const G = bsv.crypto.Point.getG()
const n = bsv.crypto.Point.getN()
@msinkec
msinkec / ordinals.ts
Created January 19, 2024 08:39
Ordinal w/ custom script
// @ts-ignore
import btc = require('bitcore-lib');
import axios from 'axios';
import { Address, Tap, Tx } from '@cmdcode/tapscript' // Requires node >= 19
async function fetchP2WPKHUtxos(address: btc.Address): Promise<any[]> {
const url = `https://blockstream.info/api/address/${address.toString()}/utxo`;
let res = []
try {
@msinkec
msinkec / genesis_coinbase.md
Last active January 12, 2024 11:56
About the Genesis Block's Coinbase...

About the Genesis Block's Coinbase

The recent deposit of a large sum of BTC to the address associated with the genesis block's coinbase, 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa, has sparked confusion and discussion in the blockchain sphere. To clarify, while the specific coinbase output of the genesis block cannot be spent, subsequent Unspent Transaction Outputs (UTXOs) sent to the same public key (or its hash / address) can be spent, assuming one has access to the corresponding private key.

Technical Explanation

Bitcoin's Genesis Block and Coinbase Transactions

  1. Genesis Block Coinbase Transaction: In Bitcoin, the genesis block is the first block of the blockchain. Notably, the coinbase transaction of this block is hardcoded into the Bitcoin client. This transaction is never added
@msinkec
msinkec / redeemBTCtimeLock.py
Created December 14, 2023 13:17
Redeem time-locked BTC transaction
from bitcoinutils.setup import setup
from bitcoinutils.utils import to_satoshis
from bitcoinutils.transactions import Transaction, TxInput, TxOutput
from bitcoinutils.keys import PrivateKey, P2wshAddress, P2wpkhAddress
from bitcoinutils.script import Script
def main():
# always remember to setup the network
setup('testnet')
@msinkec
msinkec / deployBTCtimeLock.py
Created December 14, 2023 13:15
Deploy time-locked BTC transaction
from bitcoinutils.setup import setup
from bitcoinutils.utils import to_satoshis
from bitcoinutils.transactions import Transaction, TxInput, TxOutput
from bitcoinutils.keys import PrivateKey, P2wshAddress, P2wpkhAddress
from bitcoinutils.script import Script
def main():
# always remember to setup the network
setup('testnet')
@msinkec
msinkec / lockToMint.md
Last active December 16, 2023 03:36
Lock to Mint BSV-20 tokens using sCrypt

Implementing "Lock to Mint" Mechanism using sCrypt for Minting BSV-20 Tokens

Disclaimer: This code is provided as an example only and is not intended for production use. The author of this code and any parties involved in its distribution are not liable for any lost funds or damages arising from the use of this code. Users should conduct their own testing and due diligence before implementing or deploying this code in any environment.


To implement a "lock to mint" mechanism using sCrypt for minting BSV-20 (V2) tokens, the provided source code outlines a smart contract approach that integrates with the BSV-20 V2 standard. This method does not require an extended indexer and is compatible with the standard BSV-20 tokens, unlike the LRC-20 approach.

import { BSV20V2 } from 'scrypt-ord'

Invitation to Bitcoin Developers: Utilize sCrypt for Advanced BitVM Implementations

To the Bitcoin Development Community,

In light of the recent advancements in BTC's computational capabilities introduced by BitVM, we are extending an open invitation to explore the integration of sCrypt as a language for developing BitVM scripts. BitVM represents a significant advancement in Bitcoin's scripting capabilities, enabling Turing-complete contracts within the existing BTC framework.

Technical Overview:

BitVM facilitates off-chain computation, essential for complex contract execution while maintaining Bitcoin's on-chain efficiency. While Assembly (ASM) scripts are so far used to express contracts for BitVM, they present certain limitations in terms of readability and broader accessibility.

@msinkec
msinkec / setup.sh
Last active July 14, 2021 19:34
sCrypt UNIX install script
#!/bin/sh
COMPILER_VERSION=""
GITHUB_OWNER="sCrypt-Inc"
GITHUB_REPO="compiler_dist"
GLOB_INST_DIR="/usr/local/bin"
LOCAL_INST_DIR="$HOME/.local/bin"
BIN_NAME="scryptc"
SKIP_PROMPT=0
DISPLAY_HELP=0