Skip to content

Instantly share code, notes, and snippets.

View pcdinh's full-sized avatar

Pham Cong Dinh pcdinh

View GitHub Profile

2-of-3 Escrow Example with Electrum

This is gmaxwell's 2-of-2 escrow example, adapted to Electrum and to a lesser extent, GFM.

The Scenario

Archey wants to pay Bertha 0.001 BTC for a Twitter Platinum invite, but prevent Bertha from cheating him. Archey selects Iceland to act as

hashrate: 0.1053
hashrate: 0.1053
hashrate: 0.1053
hashrate: 0.1053
hashrate: 0.1053
hashrate: 0.1053
hashrate: 0.1053
hashrate: 0.0526
hashrate: 0.0526
hashrate: 0.0526
@pcdinh
pcdinh / aes.py
Created May 13, 2014 21:51 — forked from gsakkis/aes.py
from binascii import hexlify, unhexlify
from hashlib import md5
from Crypto.Cipher import AES
try:
from M2Crypto import EVP
except ImportError:
EVP = None
def m2_encrypt(plaintext, key, iv, key_as_bytes=False, padding=True):
# This file is autogenerated by the get_windows_info.py script
# Do not edit.
win_tz = {'AUS Central Standard Time': 'Australia/Darwin',
'AUS Eastern Standard Time': 'Australia/Sydney',
'Afghanistan Standard Time': 'Asia/Kabul',
'Alaskan Standard Time': 'America/Anchorage',
'Arab Standard Time': 'Asia/Riyadh',
'Arabian Standard Time': 'Asia/Dubai',
'Arabic Standard Time': 'Asia/Baghdad',
'Argentina Standard Time': 'America/Buenos_Aires',
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
include = *.more.config.ini
debug = true
logoutput=/data1/circus/daemon.log
loglevel=DEBUG
[watcher:api_dev2]
@pcdinh
pcdinh / fs.txt
Last active August 29, 2015 14:06
FileString file sharing
POST /2.0/file
{
"file": {
"id": "<string>",
"location": {
"proto": "file",
"name": "<string>",
"path": "<string>",
"is_dir": false
WITH owner_to_direct_indirect_recipient AS (
SELECT f.FileID,
NULL AS SharedDate,
NULL AS SharingDataKey,
NULL AS Perms,
NULL AS ExpiredDate,
NULL AS IsPrinted,
NULL AS HasWatermark,
NULL AS SharingModifiedDate,
CONVERT(NVARCHAR(36), TODATETIMEOFFSET(fs.SharedDate, '+00:00'), 126) AS SharedDate2,
app.directive('infiniteScroll', [
'$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) {
return {
link: function(scope, elem, attrs) {
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
$window = angular.element($window);
elem.css('overflow-y', 'scroll');
elem.css('overflow-x', 'hidden');
elem.css('height', 'inherit');
scrollDistance = 0;
@pcdinh
pcdinh / xmr-bitcoin
Last active August 29, 2015 14:16
Monero-Bitcoin
(1) It uses a different elliptic curve than Bitcoin for signing (EdDSA, which uses Schnorr signatures on a Twisted Edwards curve).
(2) It uses a different hashing algorithm than Bitcoin for PoW, which is AES heavy and currently performs similarly on GPUs
and CPUs. One of the main downsides to this is that sidechains are currently impossible (validation takes too long), however
as sidechains don't actually exist right now we've been ignoring this. If we want to add sidechain support in the future,
the hashing algorithm can be change to something simple. In the meantime, the algorithm is relatively "egalitarian" in that
no specialized hardware is required.
(3) One time use addresses ("stealth addressing") is mandatory for all transactions. This makes light clients very difficult
to secure or create in general, but it dramatically enhances privacy because it's impossible to ever reuse an address.
(4) All transactions are denominated in base 10, and fractionated by mantissa.
(5) Ring signatures obfuscate spe