Skip to content

Instantly share code, notes, and snippets.

View xhliu's full-sized avatar

xhliu xhliu

View GitHub Profile
@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...'''
@revofusion
revofusion / rune.ts
Created September 27, 2023 01:13
Rune Scripts: PrefixVarint and Base 26 (A=1) Name
/**
Convert between rune symbols and values using Base 26 (A=1)
Similar rust implementation at https://github.com/ordinals/ord/blob/f3cae5400fdebf31bfd494a02c846a90ea12310d/src/sat.rs#L63
*/
class Rune {
constructor(public value: number) { }
public get name(): string {
let x = this.value;
@RobinLinus
RobinLinus / bitcoin-txs.md
Created June 8, 2023 21:50
Raw Bitcoin transactions hand-parsed for educational purposes

Raw Bitcoin Transactions

P2PK

https://blockstream.info/block/00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee

Raw

https://blockstream.info/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16

0100000001c997a5e56e104102fa209c6a852dd90660a20b2d9c352423edce25857fcd3704000000004847304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901ffffffff0200ca9a3b00000000434104ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa28414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6cd84cac00286bee0000000043410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3ac00000000

Parsed

@synfonaut
synfonaut / bitcoinsv.md
Last active August 1, 2023 15:22
Bitcoin SV Stable Protocol Restoration

Bitcoin SV Stable Protocol Restoration

These are the pending changes to Bitcoin SV's stable protocol — many of these were changed/removed by BTC/BCH and are being restored carefully or in ways that fix the original issues. Other changes are primarily scaling parameters or optimizations.

Remove dust limit & 0-satoshi utxos

Once upon a time some BTC developers, mindful of their parental responsibilities to all participants in the Bitcoin network, introduced a protective mechanism called the Dust limit

This limit will be removed entirely by the end of the year allowing even 0 value outputs.

@zhangweis
zhangweis / token.scrypt
Last active March 9, 2024 08:42
Add current merkle root to records and allow signature only on record. This can better support cold key storage.
import "util.scrypt";
contract Token {
public function transfer(bytes txPreimage, bytes fromRecord, bytes fromMerklePath, Sig senderSig,
bytes toRecord, bytes toMerklePath, bytes insertPoint, bytes insertPointMerklePath,
int amount, int utxoAmount) {
require(amount>0);
require(utxoAmount>=0);
// this ensures the preimage is for the current tx
require(Tx.checkPreimage(txPreimage));
@KtorZ
KtorZ / style.yaml
Last active October 21, 2022 15:38
Drop-in Github workflow for Haskell projects using stack.
name: Code Style
on:
pull_request:
branches: [ "master" ]
push:
branches: [ "master" ]
tags: [ "*.*.*" ]
jobs:
@dino-
dino- / string-conversions.hs
Last active April 6, 2024 16:32
A handy illustration of converting between String, Text and ByteString in Haskell
#! /usr/bin/env stack
-- stack --resolver lts-18.8 script
{-# LANGUAGE OverloadedStrings #-}
{-
This is a handy illustration of converting between five of the commonly-used
string types in Haskell (String, ByteString, lazy ByteString, Text and lazy
Text).
@shilch
shilch / merkle.c
Last active March 14, 2022 22:03
Streaming merkle tree construction with minimal memory implemented in C
#include "merkle.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
void merkle_init(merkle_ctx* ctx){
ctx->size = 0;
ctx->mutated = false;
}
import ecdsa
import ecdsa.ellipticcurve as EC
curve = ecdsa.SECP256k1
x = int('11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c', 16)
y = int('b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3', 16)
point = EC.Point(curve.curve, x, y)
pubkey = ecdsa.VerifyingKey.from_public_point(point, curve)
hash1 = 90774958364900180671716888080665726921328827653065727390791155349203800699667
@awemany
awemany / ZCF.md
Last active January 10, 2023 15:00
Solving the 0-conf problem using forfeits

Solving the 0-conf problem using forfeits

by /u/awemany

Overview

The problem of ensuring good security for unconfirmed transactions in Bitcoin is repeatedly discussed in the community. Right now these so-called 0-conf transactions are usually expected to be of low risk in the case of small amounts and face-to-face interaction of merchant and customer.