Skip to content

Instantly share code, notes, and snippets.

View MurageKibicho's full-sized avatar
🛼
Working from home

Murage Kibicho MurageKibicho

🛼
Working from home
  • Yale University
  • New Haven, Connnecticut
  • 00:39 (UTC -04:00)
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
// Helper to get/set elements in a 1D matrix (row-major)
#define MAT(m, row, col, numCols) ((m)[(row)*(numCols)+(col)])
// Swap two rows in a 1D array
void swapRows(int *matrix, int row1, int row2, int numCols) {
for (int col = 0; col < numCols; col++) {
int temp = MAT(matrix, row1, col, numCols);
@MurageKibicho
MurageKibicho / Lenstra.c
Created August 7, 2025 08:53
Lenstra's Solving pell equations with index calculus example code
//Full guide : https://leetarxiv.substack.com/p/solving-pell-equations-with-index
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include <math.h>
#include <gmp.h>
#define STB_DS_IMPLEMENTATION
@MurageKibicho
MurageKibicho / Solve.c
Created August 6, 2025 17:44
Index calculus to solve matrix in reduced row echelon form
//Full guide: https://leetarxiv.substack.com/p/row-reduction-over-finite-fields
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// Function to compute modular inverse using Fermat's Little Theorem
long modinv(long a, long p)
{
long result = 1;
long power = p - 2;
@MurageKibicho
MurageKibicho / PrivateKey.c
Last active July 27, 2025 10:13
Scalar multiplication in elliptic curves in C
//Full guide: https://leetarxiv.substack.com/p/hacking-dormant-bitcoin-wallets-c
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include <gmp.h>
#include <secp256k1.h>
#include <openssl/sha.h>
@MurageKibicho
MurageKibicho / PrivateKey.c
Last active July 26, 2025 18:05
Bitcoin Elliptic Curve Generate Private Key in C Starter code
//Full guide here:https://leetarxiv.substack.com/p/hacking-dormant-bitcoin-wallets-c
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <gmp.h>
#include <secp256k1.h>
#include <openssl/sha.h>
#include <openssl/ripemd.h>
@MurageKibicho
MurageKibicho / PrivateKey.c
Created July 25, 2025 11:46
Hacking a dormant bitcoin wallet involves finding the wallet’s private key. Owning a bitcoin is equivalent to knowing a wallet’s private key. The process can be summarized as: A private key generates a public key. The public key is hashed by SHA256 + RIPEMD. The hash is encoded in Base58. The encoded Base58 string is the wallet address. We wrote…
//Complete guide : https://leetarxiv.substack.com/p/hacking-dormant-bitcoin-wallets-c
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <secp256k1.h>
#include <openssl/sha.h>
#include <openssl/ripemd.h>
//Run: clear && gcc PrivateKey.c -lsecp256k1 -lcrypto -o m.o && ./m.o
@MurageKibicho
MurageKibicho / PMat32.c
Last active July 24, 2025 01:23
Unsigned PMat32.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#define INDEX(x, y, cols) ((x) * (cols) + (y))
//We use unsigned integers
//Using signed integers is misaligned with our goal (Positive only integers)
@MurageKibicho
MurageKibicho / PMat32.c
Created July 23, 2025 14:57
PMat32 Checkpoint: Conversions
//Second Checkpoint in: https://leetarxiv.substack.com/p/positive-only-binary-pmat32
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#define INDEX(x, y, cols) ((x) * (cols) + (y))
typedef uint32_t PMat32;
@MurageKibicho
MurageKibicho / PMat32.c
Created July 23, 2025 13:07
Starter code for PMat32 Implementation Guide
//Full guide : https://leetarxiv.substack.com/p/positive-only-binary-pmat32
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#define INDEX(x, y, cols) ((x) * (cols) + (y))
//Run : clear && gcc PMat.c -lm -o m.o && ./m.o
@MurageKibicho
MurageKibicho / FirstPrimeFactor.c
Created July 22, 2025 01:19
Find the first prime factor of n
int FirstPrimeFactor(int n)
{
if(n == 0 || n == 1)
{
return n; // 0 and 1 have no prime factors
}
if(n < 0)
{
n = -n; // Work with absolute value
}