Skip to content

Instantly share code, notes, and snippets.

View RCasatta's full-sized avatar
🦎

Riccardo Casatta RCasatta

🦎
View GitHub Profile
@RCasatta
RCasatta / gist:4bef9ce4d95df9435b30a2194d82d705
Created March 27, 2018 08:46
Reproducible test for java opentimestamps lib serialization error
@Test
public void testException() throws Exception {
String digest = "c858838f62f908c922f9cd734e49c8fa6ee9a3b8a77093ac0969cba429249412";
byte[] digestByte = DatatypeConverter.parseHexBinary(digest);
Timestamp root= new Timestamp(digestByte);
String cata = "8BCFyeyt8QrzbwD7hc19Q6qyCPEguegXhF+Mvxbp/oHWCvX0gzpesI04rfV/cjXbvxDva2oI8SCO80/pScKWh2fGvNW5Gbjuf5j+Wa17AOoSrfZ7jCOFCwjxBFq5QzrwCCmEIs1jUPlD/wCD3+MNLvkMjiMiaHR0cHM6Ly9idGMuY2FsZW5kYXIuY2F0YWxsYXh5LmNvbQjxIN2HOOPNo6ibx5pEUshCgNQO+2WQ+3uy8HCcjJV8WmPoCPAgQ9TGTeAfsKVS5+bqQ1C9772QT9t0N4EWDXj1IAWlq74I8SCp20ylUoZafC03vehOB8YYj6nF9suGxisoP8a84npxQQjxIObarGShfxGy1oeDgER/1eRn+Nw5ChqX4fCZ8qbM9ZN3CPEgNkzIG/vskOaMl+6dxbCtl3/BDgjKB0kA+5xH1452lJwI8SDVRsFsHsMfnO7izZqDXV++swAxwqc+tx5Vsq4p7o0sSAjxIKnihRE3c3THLZCuA+rXal1NWISs0dA21hR9JF2IWSktCPAg0aDyCEb2yNHaAlkjqUQ5IjEWCNglmCFp1/Yxiyw2GfEI8CAIo0GR1CesJ42uD+x0pfGDvNAlg3Bq2oBjhP68oFGFnAjxIGofEmB9xJ6UzP+gm+Kn7svCR0yK9A4pwDzT6bwzJXkOCPFxAQAAAAGhLAL67vrH6gPmi5x2RyB4yNSNDsVp4idtjo3B0CtjFQAAAAAXFg
extern crate futures;
extern crate tokio;
use futures::{Future, Async, Poll};
use std::thread;
use futures::sync::oneshot::Receiver;
use std::time;
use tokio::executor::current_thread;
pub struct FutureSender {
@RCasatta
RCasatta / Main.java
Created October 27, 2017 09:57
Recursive sha256
package com.eternitywall;
import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
public class Main {
const fs = require('fs');
function saveOts(otsFilename, buffer) {
fs.exists(otsFilename, fileExist => {
if (fileExist) {
console.log('The timestamp proof \'' + otsFilename + '\' already exists');
} else {
fs.writeFile(otsFilename, buffer, 'binary', err => {
if (err) {
return console.log(err);
@RCasatta
RCasatta / seed2keys.py
Last active May 23, 2021 09:08 — forked from kumrzz/seed2keys.py
Creates public and private keys from Electrum 2.0 seed
#!/usr/bin/env python
''' Run from "electrum/lib" directory.
ThomaxV started a discussion on https://bitcointalk.org/index.php?topic=274182.msg2939599#msg2939599
about changing the HD derivation logic in electrum 2. The below post:
http://bitcoin.stackexchange.com/questions/37013/how-to-import-a-hd-wallet-from-an-extended-private-key
confirms that the format is actually m/c/i (and not m/44'/0'/a'/c/i)
so I have altered https://gist.github.com/romanz/4b32782bfc0ff4984713 accordingly:
tested to work with keys/addresses exported from electrum 2.7.0
note Electrum has a "gap limit" of 20, so loop @ level "c" to get the next 20 addresses
'''
Compiling bitcoin v0.3.10
error: `$r:expr` may be followed by `copy`, which is not allowed for `expr` fragments
--> /Users/casatta/.cargo/registry/src/github.com-1ecc6299db9ec823/bitcoin-0.3.10/src/blockdata/script.rs:1690:16
|
1690 | $(copy $c:expr);*
| ^^^^
error: `$r:expr` may be followed by `swap`, which is not allowed for `expr` fragments
--> /Users/casatta/.cargo/registry/src/github.com-1ecc6299db9ec823/bitcoin-0.3.10/src/blockdata/script.rs:1691:16
|
$ ./ots -v info examples/hello-world.txt.ots
File sha256 hash: 03ba204e50d126e4674c005e04d82e84c21366780af1f43bd54a37816b6ab340
Timestamp:
ripemd160 == 1df8859e60bc679503d16dcb870e6ce91a57e9df
prepend 0100000001e482f9d32ecc3ba657b69d898010857b54457a90497982ff56f97c4ec58e6f98010000006b483045022100b253add1d1cf90844338a475a04ff13fc9e7bd242b07762dea07f5608b2de367022000b268ca9c3342b3769cdd062891317cdcef87aac310b6855e9d93898ebbe8ec0121020d8e4d107d2b339b0050efdd4b4a09245aa056048f125396374ea6a2ab0709c6ffffffff026533e605000000001976a9140bf057d40fbba6744862515f5b55a2310de5772f88aca0860100000000001976a914 == 0100000001e482f9d32ecc3ba657b69d898010857b54457a90497982ff56f97c4ec58e6f98010000006b483045022100b253add1d1cf90844338a475a04ff13fc9e7bd242b07762dea07f5608b2de367022000b268ca9c3342b3769cdd062891317cdcef87aac310b6855e9d93898ebbe8ec0121020d8e4d107d2b339b0050efdd4b4a09245aa056048f125396374ea6a2ab0709c6ffffffff026533e605000000001976a9140bf057d40fbba6744862515f5b55a2310de5772f88aca0860100000000001976a9141df8859e60bc679503
SHA256 digest of some data.
Starting digest: 8bd5a5f07b4451c29756df5eb51d194fb5b20c7e89812d877bbad30d871c582f
execute Append(b63d8f213d047298b8ab4595acd8e5d0)
result 8bd5a5f07b4451c29756df5eb51d194fb5b20c7e89812d877bbad30d871c582fb63d8f213d047298b8ab4595acd8e5d0
execute SHA256()
result 9f42984ccdb96addb79884e714cc6b6b059c68f2ac3a2e07c5198c22d904de14
execute Prepend(ae59d2c0d2f5efa97df8f3cca7e85845880c102237f1a6a1b0b4c6a5ab77f494)
result ae59d2c0d2f5efa97df8f3cca7e85845880c102237f1a6a1b0b4c6a5ab77f4949f42984ccdb96addb79884e714cc6b6b059c68f2ac3a2e07c5198c22d904de14
execute SHA256()
result 0bca1ed1718c71929130a639f0a7b82eeb91a8fa45b16510c9ee15fec4a0bf15
@RCasatta
RCasatta / different-blockchains.txt.ots.info
Created March 5, 2017 19:10
The following is the output of the command: `ots info examples/different-blockchains.txt.ots` showing the content of an OpenTimestamps receipt committed on both Bitcoin and Ethereum blockchains
File sha256 hash: 62c8b090faa21ee5f2e75399d4909e1e27a00ade7dca8f219c6fd34f54de3494
Timestamp:
append c237d4ddbf2f14816956503d0d5a766b
sha256
-> append 4e1e40b3ca59836ba67eefe04bbab6d4
sha256
prepend 58b93f93
append 2035d407feee535c
verify PendingAttestation('https://eth.ots.eternitywall.com')
sha256