Skip to content

Instantly share code, notes, and snippets.

@nlitsme
nlitsme / curve_example.py
Last active April 9, 2024 16:48
example of bitcoin curve calculations in python
from __future__ import print_function, division
"""
Example of how calculations on the secp256k1 curve work.
secp256k1 is the name of the elliptic curve used by bitcoin
see http://bitcoin.stackexchange.com/questions/25382
"""
## the prime modules used in the elliptic curve coordinate calculations
p = 2**256 - 2**32 - 977
@chrismiles
chrismiles / random_funcs.c
Created June 6, 2011 07:05
Random number on iOS
/* Return a random integer number between low and high inclusive */
int randomInt(int low, int high)
{
return (arc4random() % (high-low+1)) + low;
}
/* Return a random BOOL value */
BOOL randomBool()
{
return (BOOL)randomInt(0, 1);