Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2018 03:22
Show Gist options
  • Select an option

  • Save anonymous/72b62f5886fc6d86022151b6efbea20b to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/72b62f5886fc6d86022151b6efbea20b to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Feb 14, 2018.
    18 changes: 18 additions & 0 deletions BailliePSW.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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)
    mstore(add(m,0x40), 0x20)
    mstore(add(m, 0x60), 0x03ffff8000000000000000000000000000000000000000000000000000000000)
    if iszero(call(10000, 5, 0, m, 0x80, m, 0x20)) {revert(0,0)}
    o := mload(m)
    mstore(0x40, add(0x80, m))
    }
    }
    }
    3 changes: 3 additions & 0 deletions Fermat_witness.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    contract Fermat_witness{
    function witness()
    }
    35 changes: 35 additions & 0 deletions FlipEndian.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    contract QEth {
    /*
    * Params: chunk size = 8 bits, checksum size = 16
    * merkle tree depth = 16, hash length = 256
    *
    *
    */
    bytes32 pubkey_hash;

    function verify_chunk(byte v, bytes32 s) internal returns (bytes32 y) {
    for(uint i = 0; i < 255 - uint(v); i++){
    s = sha3(s);
    }
    return s;
    }

    function verify_message(bytes32 message, bytes32[32] sig) internal {
    uint s;
    bytes32 phash;
    for(uint i = 0; i < 32; i++){
    phash = keccak256(pubkey_hash, verify_chunk(message[i], sig[i]));
    if (i < 30){
    s += uint(message[i]);
    }
    }
    assert(256*30 - s == uint(message & 0xFFFF)); // Make sure checksum is valid
    assert(phash == pubkey_hash);
    }

    function send_transaction(bytes32[32] sig, bytes32 next_key, uint g, address a, uint v, bytes data) external {
    verify_message(keccak256(next_key, g, a, v, data), sig);
    a.call.gas(g).value(v)(data);
    pubkey_hash = next_key;
    }
    }