Skip to content

Instantly share code, notes, and snippets.

@Goatghosts
Goatghosts / get_lamda.py
Last active October 1, 2023 15:14
I was playing with the constants related to the implementation of endomorphism on the secp256k1 curve, and through strange manipulations, I was able to derive LAMBDA and LAMBDA^2 from B1 and B2. I am not familiar with the original document, so this was a bit of a discovery for me. But overall, there's probably nothing useful here.
import copy
import random
P = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
a = 0x0000000000000000000000000000000000000000000000000000000000000000
b = 0x0000000000000000000000000000000000000000000000000000000000000007
PLUS_G = (
55066263022277343669578718895168534326250603453777594175500187360389116729240,
32670510020758816978083085130507043184471273380659243275938904335757337482424,
@Goatghosts
Goatghosts / endomorphism_multiplication.py
Last active September 28, 2023 18:38
secp256k1 endomorphism multiplication
# Параметры кривой secp256k1
import copy
import math
import random
P = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
a = 0x0000000000000000000000000000000000000000000000000000000000000000
b = 0x0000000000000000000000000000000000000000000000000000000000000007
PLUS_G = (
@Goatghosts
Goatghosts / shitfinder.py
Created May 7, 2023 22:24
May? Time to look for shitcoins. Edit your own filters. I don't give a shit.
import requests
import json
from bs4 import BeautifulSoup
def parse(pages):
output = []
offset = 1
for _ in range(pages):
link = f"https://api.coinmarketcap.com/dexer/v3/platformpage/pair-pages?platform-id=1&dexer-id=1069&" \
@Goatghosts
Goatghosts / simple_pygame_physics.py
Last active April 28, 2023 17:05
A la ragdoll test on pygame using pymunk
import pygame
import sys
import pymunk
import pymunk.pygame_util
pygame.init()
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 600
FRAMERATE = 60
@Goatghosts
Goatghosts / int_to_bin.py
Created April 20, 2023 17:00
We turn the integer variable into a binary format, add a bit in front, remove a bit in the back, and convert back to an integer variable.
def int_to_binary_with_fixed_length(n, length):
binary_repr = format(n, f"0{length}b")
return binary_repr
def modify_binary(binary_repr):
new_binary_repr = "1" + binary_repr[:-1]
return new_binary_repr
@Goatghosts
Goatghosts / chatGPT_secp256k1.py
Last active March 26, 2023 20:15
Я попросил chatGPT написать код для получения публичного ключа из приватного ключа. Она написала. Вот и все, в принципе.
# Параметры кривой secp256k1
p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
a = 0x0000000000000000000000000000000000000000000000000000000000000000
b = 0x0000000000000000000000000000000000000000000000000000000000000007
Gx = int(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)
Gy = int(0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
def is_on_secp256k1(x, y):
@Goatghosts
Goatghosts / get_nonce_from_pkey.py
Last active November 27, 2022 23:16
Many people know how to get a private key from a nonce. But I did not find information on how to get a nonce from a private key. If someone also does not know how to search, then here is a ready-made solution. And here is what I took as a basis: https://asecuritysite.com/ecdsa/ecd3
import ecdsa
import random
import libnum
import hashlib
G = ecdsa.SECP256k1.generator
ORDER = G.order()