Skip to content

Instantly share code, notes, and snippets.

Avatar

Xiaohui Liu xhliu

View GitHub Profile
@zhangweis
zhangweis / token.scrypt
Last active Mar 11, 2021
Add current merkle root to records and allow signature only on record. This can better support cold key storage.
View token.scrypt
import "util.scrypt";
contract Token {
public function transfer(bytes txPreimage, bytes fromRecord, bytes fromMerklePath, Sig senderSig,
bytes toRecord, bytes toMerklePath, bytes insertPoint, bytes insertPointMerklePath,
int amount, int utxoAmount) {
require(amount>0);
require(utxoAmount>=0);
// this ensures the preimage is for the current tx
require(Tx.checkPreimage(txPreimage));
@KtorZ
KtorZ / style.yaml
Last active Jan 10, 2021
Drop-in Github workflow for Haskell projects using stack.
View style.yaml
name: Code Style
on:
pull_request:
branches: [ "master" ]
push:
branches: [ "master" ]
tags: [ "*.*.*" ]
jobs:
@dino-
dino- / string-conversions.hs
Last active Apr 16, 2021
A handy illustration of converting between String, Text and ByteString in Haskell
View string-conversions.hs
#! /usr/bin/env stack
-- stack --resolver lts-12.14 script
{-# LANGUAGE OverloadedStrings #-}
{-
This is a handy illustration of converting between five of the commonly-used
string types in Haskell (String, ByteString, lazy ByteString, Text and lazy
Text).
@shilch
shilch / merkle.c
Last active Jan 22, 2019
Bitcoin merkle tree C implementation
View merkle.c
#include "merkle.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
void merkle_init(merkle_ctx* ctx){
ctx->size = 0;
ctx->mutated = false;
}
View satoshi.py
import ecdsa
import ecdsa.ellipticcurve as EC
curve = ecdsa.SECP256k1
x = int('11db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5c', 16)
y = int('b2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3', 16)
point = EC.Point(curve.curve, x, y)
pubkey = ecdsa.VerifyingKey.from_public_point(point, curve)
hash1 = 90774958364900180671716888080665726921328827653065727390791155349203800699667
@awemany
awemany / ZCF.md
Last active Apr 20, 2021
Solving the 0-conf problem using forfeits
View ZCF.md

Solving the 0-conf problem using forfeits

by /u/awemany

Overview

The problem of ensuring good security for unconfirmed transactions in Bitcoin is repeatedly discussed in the community. Right now these so-called 0-conf transactions are usually expected to be of low risk in the case of small amounts and face-to-face interaction of merchant and customer.

View oracle_smart_contract_p2sh.md

The P2SH script:

OP_HASH160 
0x14 
<hash160 of alice's secret>	
OP_EQUAL 
OP_TOALTSTACK 
OP_HASH160 
0x14 
@namnm
namnm / mining-pool-comparison.md
Created Oct 10, 2017
Mining pool comparison
View mining-pool-comparison.md
@chriseth
chriseth / snarktest.solidity
Last active Apr 29, 2021
zkSNARKs test code
View snarktest.solidity
// This file is MIT Licensed.
//
// Copyright 2017 Christian Reitwiessner
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O
@ryboe
ryboe / .travis.yml
Last active Feb 20, 2021
Example .travis.yml for Golang
View .travis.yml
# use the latest ubuntu environment (18.04) available on travis
dist: bionic
language: go
# You don't need to test on very old versions of the Go compiler. It's the user's
# responsibility to keep their compiler up to date.
go:
- 1.16.x