Skip to content

Instantly share code, notes, and snippets.

Remco Bloemen Recmo

View GitHub Profile
@Recmo
Recmo / ShardToken.sol
Created Jan 30, 2019
ShardToken: Actor Model through Cousin Proofs
View ShardToken.sol
contract ShardToken {
address OWNER;
address ROOT;
uint256[] ANCESTRY_PROOF;
address owner;
uint256 next_nonce;
uint256 balance;
@Recmo
Recmo / MerkleVerifier.sol
Created Jan 29, 2019
Merkle multi-queries
View MerkleVerifier.sol
contract MerkleVerifier {
function hash_leaf(uint256 value)
internal pure
returns (bytes32 hash)
{
return bytes32(value);
}
function hash_node(bytes32 left, bytes32 right)
@Recmo
Recmo / lending.sol
Created Nov 21, 2018
Lending contracts having state invariants depending on call stack.
View lending.sol
// Simple lending contract demostrating complex call-stack
// dependant state invariants.
// @author Remco Bloemen <remco@0xproject.com>
pragma solidity ^0.4.25;
// Simple non-reentrant version. (Or actually, the innermost call is responsible for paying back everyone.)
contract Lending1 {
constructor () public payable {
@Recmo
Recmo / muldiv.sol
Last active Nov 21, 2018
Multiply-and-divide with no overflow
View muldiv.sol
/*
Copyright 2018 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
View BloomNuke.sol
contract BloomNuke {
function nuke() {
assembly {
log4(0, 0, 0, 1, 2, 3)
log4(0, 0, 4, 5, 6, 7)
log4(0, 0, 8, 10, 11, 12)
log4(0, 0, 13, 14, 15, 16)
log4(0, 0, 17, 18, 19, 20)
log4(0, 0, 21, 22, 23, 24)
log4(0, 0, 25, 27, 28, 29)
View StructuredHashes.sol
pragma solidity 0.4.20;
contract StructuredHashes {
struct Order {
address maker;
address taker;
address makerToken;
address takerToken;
address feeRecipient;
@Recmo
Recmo / TestKeccak.sol
Last active Mar 1, 2018
Experiments to understand Solidity's hashing of structured data.
View TestKeccak.sol
pragma solidity 0.4.20;
// pragma experimental ABIEncoderV2; // Does not affect outcome
contract Test {
function test1() public pure returns (bool) {
bytes32 hash1 = keccak256("abc", "def");
bytes32 hash2 = keccak256("abcd", "ef");
return hash1 == hash2; // Returns true
}
@Recmo
Recmo / wasm.js
Last active Jun 1, 2017
WebAssembly compile and run example
View wasm.js
/* global WebAssembly */
import wast2wasm from 'wast2wasm';
// Run with: babel-node --expose-wasm ./wasm.js
const wast = `(module
(func $fac (param i32) (result i32)
get_local 0
i32.eqz
if i32
@Recmo
Recmo / NeukeySerial.py
Last active May 9, 2017
Serial number generator for Neukey's using Damm's algorithm.
View NeukeySerial.py
#!/usr/bin/env python3
from os import urandom
# Damm's weakly totally antisymetric quasigroup of order 10
# https://en.wikipedia.org/wiki/Damm_algorithm
Damm = [
[0, 3, 1, 7, 5, 9, 8, 6, 4, 2],
[7, 0, 9, 2, 1, 5, 4, 8, 6, 3],
[4, 2, 0, 6, 8, 7, 1, 3, 5, 9],
[1, 7, 5, 0, 9, 8, 3, 4, 2, 6],
View Owned.sol
contract Owned {
address public owner;
function Owned() {
owner = msg.sender;
}
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
You can’t perform that action at this time.