Skip to content

Instantly share code, notes, and snippets.

View khovratovich's full-sized avatar

Dmitry Khovratovich khovratovich

View GitHub Profile
found=False
import random,math
def miller_rabin(n, k):
# Implementation uses the Miller-Rabin Primality Test
# The optimal number of rounds for this test is 40
# See http://stackoverflow.com/questions/6325576/how-many-iterations-of-rabin-miller-should-i-use-for-cryptographic-safe-primes
# for justification
@khovratovich
khovratovich / BranchSender.sol
Created July 21, 2016 08:34
Split contract by Mikhail Vladimirov
// Simple smart contract that allows anyone to send ether from one address to
// another in certain branch of the blockchain only. This contract is supposed
// to be used after hard forks to clearly separate "classic" ether from "new"
// ether.
contract BranchSender {
// Is set to true if and only if we are currently in the "right" branch of
// the blockchain, i.e. the branch this contract allows sending money in.
bool public isRightBranch;
// Instantiate the contract.
pragma solidity ^0.4.25;
/**
*
* ╔╗╔╗╔╗╔══╗╔╗──╔╗──╔══╗╔═══╗──╔╗──╔╗╔═══╗
* ║║║║║║║╔╗║║║──║║──╚╗╔╝║╔══╝──║║──║║║╔══╝
* ║║║║║║║╚╝║║║──║║───║║─║╚══╗──║╚╗╔╝║║╚══╗
* ║║║║║║║╔╗║║║──║║───║║─║╔══╝──║╔╗╔╗║║╔══╝
* ║╚╝╚╝║║║║║║╚═╗║╚═╗╔╝╚╗║╚══╗╔╗║║╚╝║║║╚══╗
* ╚═╝╚═╝╚╝╚╝╚══╝╚══╝╚══╝╚═══╝╚╝╚╝──╚╝╚═══╝
pragma solidity ^0.4.23;
// File: node_modules/zeppelin-solidity/contracts/ownership/Ownable.sol
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
@khovratovich
khovratovich / Crowdsale.sol
Last active October 3, 2017 16:08
WIZ Crowdsale contract
pragma solidity ^0.4.17;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
@khovratovich
khovratovich / Token.sol
Last active October 3, 2017 16:06
WIZ Token Contract
pragma solidity ^0.4.17;
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "argon2.h"
#include "\Dima\Old Projects and Texts\Argon2\phc\src\core.h"
personal.unlockAccount (web3.eth.accounts[0], “****”); // ← REPLACE **** WITH YOUR ACCOUNT PASSWORD
var fromAddr = web3.eth.accounts[0];
var toAddr = web3.eth.accounts[1];
var valueWei = web3.toWei (1.3, 'ether'); // Send 1.3 ETH
var senderABI = web3.eth.contract([{“constant”:false,”inputs”:[{“name”:”recipient”,”type”:”address”}],”name”:”send”,
”outputs”:[],”type”:”function”},{“constant”:true,”inputs”:[],”name”:”isRightBranch”,”outputs”:[{“name”:””,”type”:”bool”}],
@khovratovich
khovratovich / AmIOnTheFork.sol
Created July 21, 2016 08:43
Oracle contract for forks
contract AmIOnTheFork {
bool public forked = false;
address constant darkDAO = 0x304a554a310c7e546dfe434669c62820b7d83490;
// Check the fork condition during creation of the contract.
// This function should be called between block 1920000 and 1921200.
// Approximately between 2016-07-20 12:00:00 UTC and 2016-07-20 17:00:00 UTC.
// After that the status will be locked in.
function update() {
if (block.number >= 1920000 && block.number <= 1921200) {
forked = darkDAO.balance < 3600000 ether;
@khovratovich
khovratovich / HFConditionalTransfer.sol
Created July 21, 2016 08:36
Split contract by Vitalik Buterin
contract HFConditionalTransfer {
function transferIfHF(address to) {
if (address(0xbf4ed7b27f1d666546e30d74d50d173d20bca754).balance > 2000000 ether)
to.send(msg.value);
else
msg.sender.send(msg.value);
}
function transferIfNoHF(address to) {
if (address(0xbf4ed7b27f1d666546e30d74d50d173d20bca754).balance <= 2000000 ether)