Skip to content

Instantly share code, notes, and snippets.

View ykm11's full-sized avatar
🐧
On vacation

Haruka Hirata ykm11

🐧
On vacation
  • Tokyo, Japan
View GitHub Profile
@ykm11
ykm11 / mpf_vector_bench.cpp
Last active February 23, 2024 05:55
mpf_t init benchmark
#include <iostream>
#include <gmpxx.h>
#include <cstdint>
#include <chrono>
#include <vector>
#include <stdlib.h>
#define PREC 64*4
#define PREC_LIMB_SIZE 4
@ykm11
ykm11 / comparing_powers.py
Last active January 5, 2023 18:23
Power functions for numpy.array with only positive-number exponent
import timeit
import numpy as np
from mypower import mypower
def fff(array, d):
y2 = array**d # this calls np.power
return y2
def ggg(array, d):
y2 = np.power(array, d)
@ykm11
ykm11 / measure_power.py
Created January 1, 2023 15:07
Comparing numpy.power
import timeit
import numpy as np
def mypower(y):
y2 = y*y
y3 = y*y2
y4 = y2*y2
y5 = y2*y3
y6 = y3*y3
return y2, y3, y4, y5, y6
@ykm11
ykm11 / pow521.cpp
Last active April 8, 2020 09:18
メルセンヌ素数2^{521}-1の逆元計算の速度比較
#include <iostream>
#include <time.h>
#include <gmpxx.h>
#define SIZE 9
static inline void mod(mp_limb_t *z, const mp_limb_t *XY, const mp_limb_t *p, mp_limb_t *t, mp_limb_t *s) {
// (T + (T mod R)*N) / R
@ykm11
ykm11 / mulMod521.cpp
Last active April 2, 2020 07:39
メルセンヌ素数2^{521}-1を法とする場合の乗算の実行時間比較
#include <iostream>
#include <time.h>
#include <gmpxx.h>
#define SIZE 9
void mod2(mp_limb_t *z, const mp_limb_t *XY, const mp_limb_t *p, mp_limb_t *q) {
mpn_tdiv_qr(q, z, 0, (const mp_limb_t *)XY, SIZE*2, (const mp_limb_t*)p, SIZE);
}
@ykm11
ykm11 / mpn_test.cpp
Created March 11, 2020 05:50
mpnのテスト
#include<iostream>
#include<gmpxx.h>
#include <time.h>
static const int N = 100000;
static void set_mpz_t(mpz_t& z, const uint64_t* p, int n) {
int s = n;
while (s > 0) {
@ykm11
ykm11 / mpn_test.cpp
Last active March 11, 2020 06:07
mpnのテスト
#include<iostream>
#include<gmpxx.h>
#include <time.h>
static const int N = 100000;
static void set_mpz_t(mpz_t& z, const uint64_t* p, int n) {
int s = n;
while (s > 0) {
@ykm11
ykm11 / pass_pow.go
Last active June 3, 2019 10:57
I hate PoW on CTF
package main
import (
"fmt"
"os"
"hash"
"strings"
"crypto/MD5"
"crypto/SHA1"
"crypto/SHA256"
@ykm11
ykm11 / chacha20.cpp
Last active June 11, 2019 05:55
chacha20 by c-language
#include<stdio.h>
void num_to_bytes(unsigned long long num, unsigned char bytes[]) {
for(int i = 0; i < 4; i++) {
bytes[i] = (num >> (i*8)) & 0xFF;
}
}
unsigned long long bytes_to_num(unsigned char bytes[]) {
unsigned long long num = 0;
@ykm11
ykm11 / harezkazeCTF2019_smypk_solve.go
Last active May 19, 2019 10:06
HarekazeCTF2019 show_me_your_private_key
package main
import (
"fmt"
. "./ecUtils"
. "./mathUtils"
)
// https://github.com/ykm11/goCurve