This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) | |
NewerOlder