Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# removes orphaned appledouble files
# by null_radix
DIR="/path/to/dir"
cd $DIR
for i in ./._*
do
FILE=${i:4}
"""
Compute discrete log modulo a prime p
In other words finds a x such that h=g^x in ℤp.
Implements the meet in the middle attack
author: mjbecze <mjbecze@gmail.com>
"""
import gmpy2
from gmpy2 import mpz
.node circle {
fill: #fff;
stroke: steelblue;
stroke-width: 1.5px;
}
.node {
font: 10px sans-serif;
}
@wanderer
wanderer / dumpBlocks.js
Created June 28, 2014 20:43
dumps ethereum cpp block db in json
//npm install rlp
//npm install levelup
//usage
//node ./dumpBlocks.js > blocks.json
var rlp = require('rlp');
var levelup = require('levelup');
var db = levelup('/path/to/home/.ethereum/blocks');
var blocks = [];
Verifying that +mjb is my Bitcoin username. You can send me #bitcoin here: https://onename.io/mjb
//npm install ethereum-lib
//npm install level
var Ethereum = require('ethereum-lib'),
levelup = require('levelup');
var internals = {},
Trie = Ethereum.Trie,
rlp = Ethereum.rlp,
etherUtils = Ethereum.utils,
@wanderer
wanderer / vs.js
Last active August 29, 2015 14:07 — forked from obscuren/vs.js
eth.getKey(function(key) {
eth.getStorageAt("someaddr", "somelocation", function(address) {
eth.compile("thiscode", function(code) {
eth.transact({to: address, from: key, gas: 10000, gasPrice: eth.gasPrice, data:[code]}, function(tx){
console.log(tx)
})
})
})
})
var ecdsa = require('./');
var emptyMsg = new Buffer([0]);
var privKey = "c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4";
var pubKey = ecdsa.createPublicKey(new Buffer(privKey, 'hex'), true);
var sig = ecdsa.signCompact(new Buffer(privKey, 'hex'), emptyMsg);
console.log('recid: ', sig.recoveryId)
t = new Buffer('020947751e3022ecf3016be03ec77ab0ce3c2662b4843898cb068d74f698ccc8ad', 'hex');
var p =ecdsa.decompressPublicKey(t);
console.log(p.toString('hex'));
///040947751e3022ecf3016be03ec77ab0ce3c2662b4843898cb068d74f698ccc8ad75aa17564ae80a20bb044ee7a6d903e8e8df624b089c95d66a0570f051e5a05b
{
"env": {
"node": true
},
"rules": {
"strict": 0,
"no-underscore-dangle": 0,
"quotes": [2, "single"]
},
"globals":{