Skip to content

Instantly share code, notes, and snippets.

@jhoenicke
jhoenicke / remez.c
Created August 2, 2020 14:03
Remez Algorithm to approximate arbitrary functions by low-level polynomials on a fixed interval
#include <math.h>
#include <gmp.h>
#include <stdio.h>
#include <stdlib.h>
#define DEBUG
/*#define MOREDEBUG*/
#define BITS 1000
#define DIGITS 30 //(BITS/3 - 5)
#!/usr/bin/env python3
import hashlib
import binascii
import os
from trezorlib import log
from trezorlib.client import TrezorClient
from trezorlib.transport import get_transport
from trezorlib.tools import parse_path
@jhoenicke
jhoenicke / selfish.py
Created April 7, 2018 15:28
Selfish Mining Simulator
#!/usr/bin/python3
from random import random
# selfish mining simulation
# fraction of hash power owned by selfish miner
alpha = 0.35
# fraction of honest miners that build on selfish miner block in a tie.
@jhoenicke
jhoenicke / break-short.c
Created April 6, 2017 09:31
Program to brute force private keys from public keys using the baby-step giant-step algorithm.
/**********************************************************************
* Copyright (c) 2017, Jochen Hoenicke *
* *
* Compile with: *
* gcc -O2 -I secp256k1/src/ -I secp256k1/ break_short.c -lgmp *
**********************************************************************/
#include "libsecp256k1-config.h"
#include <stdio.h>
@jhoenicke
jhoenicke / sign.py
Last active July 18, 2017 19:32
Signing Example for python_trezor
#!/usr/bin/python
import binascii
import trezorlib.types_pb2 as proto_types
from trezorlib.client import TrezorClient
from trezorlib.tx_api import TxApiBitcoin, TxApiTestnet
from trezorlib.transport_hid import HidTransport
def main():