Skip to content

Instantly share code, notes, and snippets.

View tjade273's full-sized avatar

Tjaden Hess tjade273

View GitHub Profile
@tjade273
tjade273 / LamportVerify.sol
Created February 9, 2016 15:24 — forked from anonymous/LamportVerify.sol
Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/?gist=
library LamportVerify{
function getBit(bytes32 data, uint256 index) constant returns(uint8) { // gets bit `i` from data
return uint8(uint256(data) / (2**((255-index)))) & 0x01;
}
function verify_sig(bytes32 msgHash, bytes32[512] pubKey, bytes32[256] signature) returns(bool){
for(uint i; i < 256; i++){
bytes32 pub;
@tjade273
tjade273 / HashLadder
Created February 15, 2016 00:56 — forked from anonymous/HashLadder
Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/?gist=
library HashLadder{
function genPubKey(bytes32[2][32] privKey) returns (bytes32[2][32]){
bytes32[2][32] memory pubKey;
for(uint8 i; i< 32; i++){
bytes32 pa = privKey[i][0];
bytes32 pb = privKey[i][1];
for(uint k; k<258; k++){
pa = sha3(pa);
pb = sha3(pb);
@tjade273
tjade273 / HashLadder
Created February 19, 2016 16:51 — forked from anonymous/HashLadder
Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity/?gist=
library HashLadder{
function genPubKey(bytes32[2][32] privKey) returns (bytes32[2][32]){
bytes32[2][32] memory pubKey;
for(uint8 i; i< 32; i++){
bytes32 pa = privKey[i][0];
bytes32 pb = privKey[i][1];
for(uint k; k<258; k++){
pa = sha3(pa);
@tjade273
tjade273 / ProofLib.sol
Created June 20, 2016 19:58 — forked from anonymous/ProofLib.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-latest.js&optimize=undefined&gist=
library ProofLib {
struct Proof {
address defender;
address challenger;
bytes32 lVal;
bytes32 rVal;
uint lIndex;
uint rIndex;
@tjade273
tjade273 / generic_proxy.sol
Created June 20, 2016 20:14 — forked from holiman/generic_proxy.sol
Example of creating a 'generic' proxy in Solidity/EVM Assembly. Further details at http://martin.swende.se/
contract complex{
address add;
uint aa;
uint bb;
function thrower()
{
throw;
}
/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
@tjade273
tjade273 / disasm.js
Last active May 3, 2017 14:06 — forked from anonymous/gist:d3bbdc55159879046345
Ethereum OPCODE disassembler
function disasm(code) {
if (!code)
return code;
var codes = code.match(/(..?)/g);
var dis = "";
for(var i = 1; i < codes.length; i++) {
var opcode = opcodes[codes[i]];
dis += i+". " + codes[i]+": "
if (!opcode) {
@tjade273
tjade273 / FlipEndian.sol
Created January 17, 2018 21:06 — forked from anonymous/FlipEndian.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
pragma solidity ^0.4.19;
contract FlipEndian {
function flip32_1(bytes32 a) public constant returns (bytes32 b){
assembly {
0
and(div(a, 0x100000000000000000000000000000000000000000000000000000000000000), 0xFF)
or
and(div(a, 0x10000000000000000000000000000000000000000000000000000000000), 0xFF00)
or
@tjade273
tjade273 / BailliePSW.sol
Created February 14, 2018 03:22 — forked from anonymous/BailliePSW.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
contract BailliePSW {
function sprp(uint a) pure returns (bool iscomposite) {
}
function modexp() constant returns (bytes32 o){
assembly {
let m := mload(0x40)
mstore(m,1)
mstore(add(m, 0x20),2)
@tjade273
tjade273 / BLS.sol
Created March 8, 2018 18:42 — forked from anonymous/BLS.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.21+commit.dfe3193c.js&optimize=false&gist=
contract BLS {
uint public nonce;
uint[4] public pubkey;
// sig[0:1] is h^-x, sig[2] is the y-component of h
function forward(uint[3] sig, uint gas, address addr, uint value, bytes data) returns (bool) {
bytes32 msg = keccak256(nonce, gas, addr, value, data);
bool success;
assembly {
let m := mload(0x40)