Skip to content

Instantly share code, notes, and snippets.

View jonajosejg's full-sized avatar

Jonathan Gonzalez jonajosejg

View GitHub Profile
@jonajosejg
jonajosejg / blk001.raw
Last active October 31, 2023 21:49
Sidechain genesis raw hex string
01000000 - version
0000000000000000000000000000000000000000000000000000000000000000 - prevblock
8a6be158deb38d5cc20aa8612ac303bb7ae59520d3b22213df5e88434f36b18e - merkleblock
2d87ce6000000000000000000000000000000000000000000000000000000000 - withdrawalBundle
0000000000000000000000000000000000000000000000000000000000000000 - mainchainBlock
00000000 - timestamp
ffff7f20 - bits
02000000 - nonce
01 - number of tx
01000000 - version
@jonajosejg
jonajosejg / sidechain.js
Created May 26, 2023 14:54
sidechain template
/*!
* sidechain.js - a sidechain template for bitcoin
* Copyright (C) 2023, Jonathan Gonzalies (MIT License).
* https://github.com/rojii/sidechain
*/
'use strict';
const assert = require('bsert');
const layout = require('./blockchain/layout');
'use strict';
const assert = require('bsert');
const EventEmitter = require('events');
const WEB3 = require('web3-eth');
const {endpoint} = require('./constants');
/**
'use strict';
const assert = require('assert');
const bcoin = require('bcoin');
const MTX = bcoin.MTX;
const Keyring = bcoin.wallet.WalletKey;
const Outpoint = bcoin.Outpoint;
const Script = bcoin.Script;
const Coin = bcoin.Coin;
@jonajosejg
jonajosejg / yo.txt
Created July 27, 2022 09:39
she called me name and just said hello all day ba daaaa, california esta lleno de maricones purse son maricones
0x42C6A98F84fec35d50c0188989817d5A535bB214
/* eslint-env mocha */
'use strict';
const {NodeClient, WalletClient} = require('../lib/client');
const assert = require('bsert');
const consensus = require('../lib/protocol/consensus');
const FullNode = require('../lib/node/fullnode');
const Network = require('../lib/protocol/network');
const Mnemonic = require('../lib/hd/mnemonic');
@jonajosejg
jonajosejg / epsilon.js
Last active January 7, 2020 03:36
alnilam variable for use with delta functions
var alnilam = Number.EPSILON * illai * 0.4503599627370496
var e = Number.EPSILON * 2 ** 52;
@jonajosejg
jonajosejg / covert_ecdh.md
Created January 2, 2020 12:08 — forked from chjj/covert_ecdh.md
Covert ECDH over secp256k1

Covert ECDH over secp256k1

If ECDH is used to establish a shared session secret for an encrypted connection, two elliptic curve points need to be transmitted (one in each direction) before encryption starts. In order to avoid being identifiable as a (specific) ECDH negotiation, ideally those two points are sent in a way that is indistinguishable from random.

This problem is easily addressed by using curves that support Elligator-style encodings: functions that encode a (subset of) elliptic curve points as sequences of bytes with no observable bias: (almost) every byte sequence corresponds to exactly one point, and the others correspond to none.

Unfortunately, no Elligator-style encoding is known for secp256k1.

var pop8tab = [256]uint8{
0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x03, 0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04,
0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05,
0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05,
0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06,
0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05,
0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06,
0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06,
0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07,
0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05,
[
["Format is: [[wit..., amount]?, scriptSig, scriptPubKey, flags, expected_scripterror, ... comments]"],
["It is evaluated as if there was a crediting coinbase transaction with two 0"],
["pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,"],
["followed by a spending transaction which spends this output as only input (and"],
["correct prevout hash), using the given scriptSig. All nLockTimes are 0, all"],
["nSequences are max."],
["", "DEPTH 0 EQUAL", "P2SH,STRICTENC", "OK", "Test the test: we should have an empty stack after scriptSig evaluation"],
[" ", "DEPTH 0 EQUAL", "P2SH,STRICTENC", "OK", "and multiple spaces should not change that."],