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
  • 09:11 (UTC -04:00)
View GitHub Profile
@MurageKibicho
MurageKibicho / FMPZ_IndexCalculus.c
Last active October 18, 2025 14:01
Big Integer Index Calculus till RREF using FLINT and LibGMP in C. Needs FLINT 3.4 or greater for fmpz_mod_mat
////Complete walkthrough: https://leetarxiv.substack.com/p/row-reduction-over-finite-fields
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include <time.h>
#include <math.h>
#include <gmp.h>
@MurageKibicho
MurageKibicho / fmpz.c
Created October 18, 2025 06:14
Flint Code to RREF a matrix
#include <flint/fmpz_mod_mat.h>
#include <flint/fmpz_mod.h>
#include <flint/fmpz.h>
#include <stdio.h>
int main() {
fmpz_t n;
fmpz_init_set_ui(n, 2); // Set modulus to 2
fmpz_mod_ctx_t ctx;
@MurageKibicho
MurageKibicho / SinkhornKnopp.c
Created October 17, 2025 09:06
Sinhorn-Knopp Algorithm with total support checking
//Complete LeetArxiv walkthrough: https://leetarxiv.substack.com/p/sinkhorn-knopp-algorithm
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#define INDEX(x, y, cols) ((x) * (cols) + (y))
//clear && gcc SinkhornKnopp.c -lm -o m.o && ./m.o
void PrintSinkhornCode(int sinkhornCode)
@MurageKibicho
MurageKibicho / LUDecomposition.c
Last active October 17, 2025 08:22
Using LU Decomposition in C to find the matrix determinant
//Full walkthrough: https://leetarxiv.substack.com/p/sinkhorn-knopp-algorithm
void PrintMatrix(int rows, int cols, double *matrix)
{
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
double element = matrix[INDEX(i,j, cols)];
printf("%.3f,",element);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <stdint.h>
#include <assert.h>
#include <math.h>
uint32_t RANGE_LOW = 1;
uint32_t RANGE_HIGH = 0xffffffff;
uint32_t RANGE_CURRENT = 0;
@MurageKibicho
MurageKibicho / OpenEnwik.c
Created October 11, 2025 05:58
Memroy mapping Hutter Prize Enwik9
//Full guide : https://leetarxiv.substack.com/p/hutter-prize-beginners-guide-to-writing
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <sys/mman.h>
#include <stdbool.h>
#define INDEX(x, y, cols) ((x) * (cols) + (y))
@MurageKibicho
MurageKibicho / SemaevIndexCalculusStarter.c
Last active October 8, 2025 07:32
Starter code for LeetArxiv Semaev Index Calculus on secp elliptic curve experiment
//Complete walkthrough: https://leetarxiv.substack.com/p/semaev-naive-index-calculus
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include <time.h>
#include <math.h>
//clear && gcc Semaev.c -lm -o m.o && ./m.o
@MurageKibicho
MurageKibicho / Jump.py
Created September 16, 2025 18:54
JumpCycleSteps
import math
def jump_cycle_steps(k, x0, n):
# Theoretical number of steps until repeat
steps_expected = n // math.gcd(k, n)
print(f"Modulus (n): {n}")
print(f"Jump size (k): {k}")
print(f"Start at x0: {x0}")
print(f"GCD(k, n): {math.gcd(k, n)}")
print(f"Expected cycle length: {steps_expected}")
@MurageKibicho
MurageKibicho / BirthdayAtttack0.c
Last active September 16, 2025 15:04
Using Ramanujan's Formula to find the log of a factorial
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gmp.h>
#include <assert.h>
#include <mpfr.h>
//Run: clear && gcc BirthdayAttack.c -lgmp -lm -lmpfr -o g.o && ./g.o
//Complete walkthrough: https://leetarxiv.substack.com/p/birthday-attack
double MPZ_Log(mpz_t x, double logarithmBase)
@MurageKibicho
MurageKibicho / Pohlig-Hellman.py
Created September 11, 2025 06:56
Pohlig Hellman for Discrete Logarithms
#Full guide: https://leetarxiv.substack.com/p/pohlig-hellman-discrete-logarithms
def pohlig_hellman(alpha, beta, p, factors):
n = p - 1 # order of the exponent group
congruences = []
# For each prime factor q^e
for q, e in factors:
# Compute gamma = alpha^(n/q)
gamma = pow(alpha, n // q, p)