Skip to content

Instantly share code, notes, and snippets.

View RandyMcMillan's full-sized avatar
🛰️
Those who know - do not speak of it.

@RandyMcMillan RandyMcMillan

🛰️
Those who know - do not speak of it.
View GitHub Profile
@RandyMcMillan
RandyMcMillan / shot-htlc.md
Created October 22, 2025 11:33 — forked from moonsettler/shot-htlc.md
SHOT - Schnorr HTLC Obfuscation Technique

SHOT - Schnorr HTLC Obfuscation Technique

Taproot internal key aggregation

  • P = p·G taproot internal public key
  • p = a·b taproot internal private key

Alice and Bob reveal each other their pubkey for the session, and then both can generate the same address.

  • A = a·G Alice (buyer of UTXO)
@RandyMcMillan
RandyMcMillan / faux_bdhke.rs
Last active October 22, 2025 04:08 — forked from rust-play/playground.rs
faux_bdhke.rs
//// src/main.rs
use std::collections::HashMap;
// --- PLACEHOLDER TYPES (Replacing ECC Types) ---
// In a real implementation, these would be Elliptic Curve Points or Scalars.
type MintPrivateKey = u64; // k
type MintPublicKey = u64; // K = k * G
type UserSecret = u64; // x
type RandomPoint = u64; // Y = hash_to_curve(x)
@RandyMcMillan
RandyMcMillan / simple_ec.rs
Created October 18, 2025 16:24 — forked from rust-play/playground.rs
simple_ec.rs
//// The prime modulus for the finite field GF(17)
const P: i64 = 17;
// Curve parameters: y^2 = x^3 + A*x + B (mod P)
const A: i64 = 2;
const B: i64 = 3;
/// Represents a point on the elliptic curve.
/// The point is (x, y). The identity point (Point at Infinity) is represented
/// by (0, 0) since the point (0, 0) is not on this curve (0^2 != 0^3 + 2*0 + 3 mod 17).
@RandyMcMillan
RandyMcMillan / viete_pi_hex.rs
Last active October 18, 2025 13:17 — forked from rust-play/playground.rs
viete_pi_hex.rs
use std::f64::consts::PI;
/// Calculates an approximation of Pi using Viète's formula.
///
/// The formula is based on an infinite product of terms involving nested square roots.
/// This function approximates the product up to a given number of iterations.
///
/// # Arguments
///
/// * `iterations` - The number of terms to include in the product. More iterations
@RandyMcMillan
RandyMcMillan / golden_ratio.rs
Last active October 15, 2025 12:00 — forked from rust-play/playground.rs
golden_ratio.rs
fn main() {
// The Golden Ratio is (1 + sqrt(5)) / 2
let five = 5.0f64;
// --- Floating-Point Types (Accurate Representation) ---
// f64: Double-precision floating point (default and most precise)
let phi_f64: f64 = (1.0 + five.sqrt()) / 2.0;
// f32: Single-precision floating point (less precision)
let phi_f32: f32 = (1.0f32 + (5.0f32).sqrt()) / 2.0f32;
@RandyMcMillan
RandyMcMillan / faux_hmac_with_test.rs
Last active October 14, 2025 12:56 — forked from rust-play/playground.rs
faux_hmac_with_test.rs
//#![no_std]
extern crate alloc;
use alloc::vec::Vec;
/// Placeholder for the real SHA-256 function.
/// It only uses the length of the data to generate a predictable output.
fn sha256_placeholder(data: &[u8]) -> [u8; 32] {
let mut hash = [0u8; 32];
let len_bytes = (data.len() as u32).to_le_bytes();
hash[0..4].copy_from_slice(&len_bytes);
@RandyMcMillan
RandyMcMillan / faux_hmac.rs
Last active October 14, 2025 12:45 — forked from rust-play/playground.rs
faux_hmac.rs
//#![no_std]
fn sha256_placeholder(data: &[u8]) -> [u8; 32] {
let mut hash = [0u8; 32];
let len_bytes = (data.len() as u32).to_le_bytes();
hash[0..4].copy_from_slice(&len_bytes);
hash
}
const SHA256_BLOCK_SIZE: usize = 64;
@RandyMcMillan
RandyMcMillan / bitcoin_attack.rs
Last active October 13, 2025 14:48 — forked from rust-play/playground.rs
bitcoin_attack.rs
//use std::f64;
/// Calculates the factorial of a non-negative integer 'n'.
/// Returns the result as a floating-point number (f64).
fn factorial(n: u32) -> f64 {
if n == 0 {
1.0
} else {
// Calculates the product of integers from 1 up to n.
(1..=n).map(|i| i as f64).product()
@RandyMcMillan
RandyMcMillan / lamda_2.rs
Created October 13, 2025 14:35 — forked from rust-play/playground.rs
lamda_2.rs
///// Calculates the factorial of a non-negative integer n.
fn factorial(n: u32) -> f64 {
if n == 0 {
1.0
} else {
(1..=n).map(|i| i as f64).product()
}
}
/// Implements the given mathematical expression.
@RandyMcMillan
RandyMcMillan / lamda.rs
Last active October 13, 2025 13:45 — forked from rust-play/playground.rs
lamda.rs
/// Calculates the factorial of a non-negative integer n.
/// Since the input z is the upper limit of the sum, and k goes up to z,
/// we can assume k is small enough that the factorial fits in u64.
/// However, for the division in the formula to work with f64,
/// we'll return the result as an f64.
fn factorial(n: u32) -> f64 {
if n == 0 {
1.0
} else {
(1..=n).map(|i| i as f64).product()