Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)
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))
}
}
}
contract Fermat_witness{
function witness()
}
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment