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
  • 06:07 (UTC -04:00)
View GitHub Profile
@MurageKibicho
MurageKibicho / Bounded.c
Created September 3, 2025 08:48
BoundedWeakCompositions Sample
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
//clear && gcc Bounded.c -lm -o m.o && ./m.o
uint64_t BinomialCoefficient(int n, int k)
{
if (k < 0 || k > n) return 0;
if (k > n - k) k = n - k;
@MurageKibicho
MurageKibicho / PollardLambda.py
Created September 2, 2025 16:10
PollardKangaroo_EllipticCurve on the secp elliptic curve
#//Full walkthrough: https://leetarxiv.substack.com/p/coding-guide-monte-carlo-methods
import hashlib
import random
import time
class EllipticCurve:
def __init__(self, a, b, p):
self.a = a
self.b = b
self.p = p
@MurageKibicho
MurageKibicho / FP2Generator.c
Last active August 31, 2025 05:31
Find Norm 1 Generator and Field Order for a point in FP2
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include <flint/flint.h>
#include <flint/fmpz.h>
#include <flint/fq.h>
#include <flint/fq_poly.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#define STB_DS_IMPLEMENTATION
#include "stb_ds.h"
//clear && gcc Murage.c -lm -o m.o && ./m.o
typedef struct kibicho_tensor_struct *KibichoTensor;
typedef struct chebyshev_kan_layer_struct *ChebyshevKANLayer;
@MurageKibicho
MurageKibicho / FP_2Scalar.c
Created August 27, 2025 01:55
FP_2ScalarPower
void FP2_Multiply(AlgebraicInteger result, AlgebraicInteger a, AlgebraicInteger b, fmpz_t primeNumber)
{
if(!fmpz_equal(a->D, b->D))
{
flint_printf("FP2_Multiply Error: Different D values\n");
exit(1);
}
fmpz_t temp1;
fmpz_init(temp1);
//result->x
@MurageKibicho
MurageKibicho / PollardRho_EllipticCurve.c
Last active August 17, 2025 20:39
Pollard Rho for Elliptic curve discrete logarithms
//Full walkthrough: https://leetarxiv.substack.com/p/coding-guide-monte-carlo-methods
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include <gmp.h>
//clear && gcc PollardRho_EllipticCurve.c -lm -lgmp -o m.o && ./m.o
@MurageKibicho
MurageKibicho / PollardRho_IntegerDLP.c
Created August 17, 2025 12:31
PollardRho's Algorithm for solving integer discrete logarithm problems
//Full guide: https://leetarxiv.substack.com/p/coding-guide-monte-carlo-methods
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <gmp.h>
//clear && gcc PollardRho_IntegerDLP.c -lm -lgmp -o m.o && ./m.o
void PollardRho_IntegerUpdate(mpz_t setElement, mpz_t exponentAnimal0, mpz_t exponentAnimal1, mpz_t desiredGenerator, mpz_t desiredResult, mpz_t primeNumberMinOne, mpz_t primeNumber, mpz_t temporary)
@MurageKibicho
MurageKibicho / PmatMatrix.c
Created August 14, 2025 09:58
Matrix Multiplication in Pmat32
void TestMatmul()
{
int integerBits = 8;
int fractionBits= 20;
assert(integerBits + fractionBits < 32);assert(integerBits > -1);assert(fractionBits > -1);
/*Create mandatory constants*/
PMat32 ONE_CONSTANT = (1 << fractionBits);
PMat32 MAX_CONSTANT = (1 << (integerBits + fractionBits));
#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