Skip to content

Instantly share code, notes, and snippets.

@teddav
teddav / small_subgroup_attack.sage
Last active November 14, 2025 17:08
elliptic curve small subgroup attack
p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab
F = GF(p)
# E = EllipticCurve(F, [0,0,0,0,4]) # y^2 = x^3 + 4
E = EllipticCurve(F, (0, 4))
G = E(0x17F1D3A73197D7942695638C4FA9AC0FC3688C4F9774B905A14E3A3F171BAC586C55E83FF97A1AEFFB3AF00ADB22C6BB,
0x08B3F481E3AAA0F1A09E30ED741D8AE4FCF5E095D5D00AF600DB18CB2C04B3EDD03CC744A2888AE40CAA232946C5E7E1)
r = 0x73EDA753299D7D483339D80809A1D80553BDA402FFFE5BFEFFFFFFFF00000001
cofactor = 0x396c8c005555e1568c00aaab0000aaab
print("cofactor:", factor(cofactor))
@teddav
teddav / AngleExplainsYul.sol
Last active August 2, 2025 09:45
Tutorial for writing a basic contract in Yul (assembly). See https://teddav.github.io/yul
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.15;
contract AngleExplains {
uint private secretNumber;
mapping(address => uint) public guesses;
bytes32 public secretWord;
@teddav
teddav / better-nodejs-require-paths.md
Created August 3, 2018 14:18 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions