Skip to content

Instantly share code, notes, and snippets.

@stribika
stribika / montgomery_ladder.py
Created February 14, 2016 23:13
Basic Montgomery ladder implementation. In the test it works with just numbers, but you can plug in any operation.
#!/usr/bin/python3 -O
from math import floor, log
def montgomery_ladder(x, n, op, select):
k = floor(log(n, 2)) + 1
x1 = x
x2 = op(x, x)
for i in range(k - 2, -1, -1):
bit = 1 if n & (1 << i) else 0

Keybase proof

I hereby claim:

  • I am stribika on github.
  • I am stribika (https://keybase.io/stribika) on keybase.
  • I have a public key whose fingerprint is 3E97 B86C F08C BA60 38D5 4FD8 6700 09C5 8D4D 6CAF

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am stribika on github.
  • I am stribika (https://keybase.io/stribika) on keybase.
  • I have a public key whose fingerprint is 0406 629F F94F 92BF DEE5 FDA7 A11E 98D6 4B0F C61E

To claim this, I am signing this object:

@stribika
stribika / correcthorsebatterystaple
Created March 29, 2015 18:29
Generate easy to remember passwords
#!/usr/bin/python3 -O
from Crypto.Random import get_random_bytes
from math import ceil, log2
from struct import unpack
from sys import argv, exit
if __name__ == "__main__":
with open("/usr/share/dict/cracklib-small") as wordlist:
words = wordlist.readlines()
@stribika
stribika / mmap.cc
Last active August 29, 2015 14:16
Copy a function between processes using RW and RX mappings.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>