This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.18; | |
contract Cert { | |
mapping (string => bool) private certificateHashes; | |
address contractOwner = msg.sender; | |
function add(string hash) public { | |
require (msg.sender == contractOwner); | |
certificateHashes[hash] = true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CryptoJS = require("crypto-js"); | |
const EC = require('elliptic').ec; | |
const secp256k1 = new EC('secp256k1'); | |
function signData(data, privKey) { | |
let keyPair = secp256k1.keyFromPrivate(privKey); | |
let signature = keyPair.sign(data); | |
return [signature.r.toString(16), signature.s.toString(16)]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pycoin.ecdsa import CurveFp, Point | |
from nummaster.basic import sqrtmod | |
def compress_key_pair(key_pair): | |
return (key_pair.x(), key_pair.y() % 2) | |
def uncompress_key(curve, compressed_key): | |
x, is_odd = compressed_key | |
p, a, b = curve.p(), curve.a(), curve.b() | |
y = sqrtmod(pow(x, 3, p) + a * x + b, p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async function() { | |
let defaultDerivePath = "m/44'/60'/0'/0/0"; | |
let hdnode = require('ethers/wallet/hdnode'); | |
let ss = require('ethers/wallet/secret-storage'); | |
//let words = 'verb position snow palace gift limb citizen alpha stay sphere swear proof'; | |
let words = 'tiger guilt skill adjust worry rival roof bicycle raven mail cherry strong body afford again praise upper wolf dry joke web bargain sea hint'; | |
let entropy = hdnode.mnemonicToEntropy(words); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version":3, | |
"id":"14ed6caf-0b69-4348-85e6-6ea0b15352cd", | |
"address":"9ab14321b263d5c1a7715098a1a31510cb828409", | |
"Crypto":{ | |
"ciphertext":"838cc6626170166b2ec15911e496b603da6c08de8ef188d9f0ef27fd84d0c572", | |
"cipherparams":{ | |
"iv":"f6ed0a488d596de27adf087f9c9e6946" | |
}, | |
"cipher":"aes-128-ctr", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"address": "cf4aa487dece1b7bd0b5c1495222931f02fab1f3", | |
"id": "c24815ed-b06c-481f-bf0c-9747b18aac2d", | |
"version": 3, | |
"Crypto": { | |
"cipher": "aes-128-ctr", | |
"cipherparams": { | |
"iv": "b5e531fc4a67e6665e5e0d4a500ef738" | |
}, | |
"ciphertext": "8174066d494c46be31c59ef7fec1c6815c412e3762da68e76f7df263e6afee55", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There is a simple way to check the last events in GitHub from certain user, including all his "git push" events: | |
https://api.github.com/users/{user}/events | |
Exmaple: https://api.github.com/users/nakov/events | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CryptoJS = require("crypto-js"); | |
const EC = require('elliptic').ec; | |
const secp256k1 = new EC('secp256k1'); | |
function publicKeyToAddress(pubKey) { | |
let address = CryptoJS.RIPEMD160(pubKey).toString(); | |
return address; | |
} | |
function privateKeyToPublicKey(privKey) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g gitbook-cli | |
npm install -g serve | |
call gitbook install | |
call gitbook build . --log=debug --debug | |
start serve _book | |
start "" http://127.0.0.1:5000 | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gitbook.events.bind("page.change", function() { | |
let runCodeLinks = $("p:contains('Run the above code example:') a"); | |
for (let link of runCodeLinks) { | |
if (typeof(link.href) == "string" && link.href.startsWith("https://repl.it/")) { | |
// A repl.it link is found --> check for code box above it | |
let codeBox = $(link).parent().prev(); | |
if (codeBox.is("pre")) { | |
// A code box is found just before the code link --> inject the [Run] button | |
let runButton = $("<a href='#' class='run-code-button' style='float:right'>Run</a>"); | |
let loadingBox = $("<span class='run-code-loading' style='float:right;display:none'>Loading …</span>"); |