Skip to content

Instantly share code, notes, and snippets.


Xiaohui Liu xhliu

View GitHub Profile
xhliu / escrow_zkp.js
Last active May 15, 2021
escrow w/ zkp
View escrow_zkp.js
// require node 10 and Rust to run
var ve = require('dlog-verifiable-enc').ve;
var assert = require('assert');
var { bsv, toHex, buildContractClass, Ripemd160, signTx, PubKey, Sig } = require('scryptlib');
const G = bsv.crypto.Point.getG()
const N = bsv.crypto.Point.getN()
const BN = bsv.crypto.BN
const { inputIndex, inputSatoshis, newTx, loadDesc } = require('./helper');
xhliu / deriveAddress.js
Last active Apr 28, 2021
A simple demo for derived bitcoin addresses
View deriveAddress.js
// Copyright (c) 2020 Xiaohui Liu.
// Use of this source code is governed by a MIT-style license.
// This is an implementation of
// For more info, also see Episode 4 of Bitcoin Class with Satoshi: Extended Address
const bsv = require('bsv');
const BN = bsv.crypto.BN
const Hash = bsv.crypto.Hash
const G = bsv.crypto.Point.getG()
const N = bsv.crypto.Point.getN()
xhliu / scriptEval.js
Last active Dec 2, 2019
Sample code to evaluate bitcoin script using Bitcoin SV Library (bsv)
View scriptEval.js
let bsv = require('bsv')
const slockStr = "OP_2 OP_EQUAL"
const slock = bsv.Script.fromASM(slockStr)
console.log("\nLocking script loaded\n")
const sunlockStr = "OP_2"
const sunlock = bsv.Script.fromASM(sunlockStr)
console.log("\nUnlocking script loaded\n")