Skip to content

opentimestamps/convert2ots

Repository files navigation

convert2ots Build Status

Convert bitcoin timestamp proof ( like Chainpoint v2 ) to OpenTimestamps proof.

Installation

You need node and npm installed then proceed

git clone https://github.com/eternitywall/convert2ots
cd convert2ots
npm install

Example

Chainpoint valid receipt from https://github.com/chainpoint/chainpoint-validate-js and save to receipt.json

{
 "@context": "https://w3id.org/chainpoint/v2",
 "type": "ChainpointSHA256v2",
 "targetHash": "bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2",
 "merkleRoot": "51296468ea48ddbcc546abb85b935c73058fd8acdb0b953da6aa1ae966581a7a",
 "proof": [
   {
     "left": "bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2"
   },
   {
     "left": "cb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf"
   },
   {
     "right": "cb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf"
   }
 ],
 "anchors": [
   {
     "type": "BTCOpReturn",
     "sourceId": "f3be82fe1b5d8f18e009cb9a491781289d2e01678311fe2b2e4e84381aafadee"
   }
 ]
}

Run conversion tool to generate receipt.ots

$ node index.js --chainpoint examples/chainpoint.json --output receipt.ots

The default behaviour check and use the local Bitcoin node. If it is not available or connection failure, the lite-verification process use multi insight block explorer instead local Bitcoin node. To force to use lite-verification specify --nobitcoin option.

$ node index.js --chainpoint examples/chainpoint.json --output receipt.ots --nobitcoin

OpenTimestamp proof info receipt.ots

$ ots -v info receipt.ots 
File sha256 hash: bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2
Timestamp:
prepend bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2 == bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2
sha256 == cb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf
prepend cb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf == cb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49fafcb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf
sha256 == da0ed1fecac504ea4f76d241a45032fa97b9eb692614419a04c9a9c32e39df2d
append cb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf == da0ed1fecac504ea4f76d241a45032fa97b9eb692614419a04c9a9c32e39df2dcb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf
sha256 == 51296468ea48ddbcc546abb85b935c73058fd8acdb0b953da6aa1ae966581a7a
prepend 01000000015cd30d6bc9b8e7a92d97e011b356b09cf7306a331c8ad63605dee4776c144c9d010000006b48304502210096811a70446463269e5d258267777f1b1e8ffe9c1965866bfd1a6c0250777c9c022049b5004a006e181fc92314ede95f3761a86831c5f99937465d99de6d14388b870121035b690114679d44d75b75aa170e34596c94c778f589bcb9063b0e4e293fcacd1dffffffff020000000000000000226a20 == 01000000015cd30d6bc9b8e7a92d97e011b356b09cf7306a331c8ad63605dee4776c144c9d010000006b48304502210096811a70446463269e5d258267777f1b1e8ffe9c1965866bfd1a6c0250777c9c022049b5004a006e181fc92314ede95f3761a86831c5f99937465d99de6d14388b870121035b690114679d44d75b75aa170e34596c94c778f589bcb9063b0e4e293fcacd1dffffffff020000000000000000226a2051296468ea48ddbcc546abb85b935c73058fd8acdb0b953da6aa1ae966581a7a
append cd996e00000000001976a9147003cc5915f6c23fd512b38daeeecfdde7a587e988ac00000000 == 01000000015cd30d6bc9b8e7a92d97e011b356b09cf7306a331c8ad63605dee4776c144c9d010000006b48304502210096811a70446463269e5d258267777f1b1e8ffe9c1965866bfd1a6c0250777c9c022049b5004a006e181fc92314ede95f3761a86831c5f99937465d99de6d14388b870121035b690114679d44d75b75aa170e34596c94c778f589bcb9063b0e4e293fcacd1dffffffff020000000000000000226a2051296468ea48ddbcc546abb85b935c73058fd8acdb0b953da6aa1ae966581a7acd996e00000000001976a9147003cc5915f6c23fd512b38daeeecfdde7a587e988ac00000000
# Bitcoin transaction id f3be82fe1b5d8f18e009cb9a491781289d2e01678311fe2b2e4e84381aafadee
sha256 == 7e85881c5c334f089cd1e41060c838ffe8b0849e655b6c7c98b5eeadfa0c6b59
sha256 == eeadaf1a38844e2e2bfe118367012e9d288117499acb09e0188f5d1bfe82bef3
prepend 9f0b3ab380760f32613d1757c35ebf55e8fdaf9f2c2cbe3c56aa00fe5f743eb0 == 9f0b3ab380760f32613d1757c35ebf55e8fdaf9f2c2cbe3c56aa00fe5f743eb0eeadaf1a38844e2e2bfe118367012e9d288117499acb09e0188f5d1bfe82bef3
sha256 == b133fa1f2964dbe7851cd055f570829beba1e814eeacda25142f35e3055aeb01
sha256 == cb0a8f0d93e03df267412f6d553776143752a0144ca56a63653e05342326ac4c
prepend 82edea6ac21093305e010b9bb57816964cbe1865a70d5ff1e48719d4928b08f8 == 82edea6ac21093305e010b9bb57816964cbe1865a70d5ff1e48719d4928b08f8cb0a8f0d93e03df267412f6d553776143752a0144ca56a63653e05342326ac4c
sha256 == c29d93743ac016e6867bf1297ec87dc79cd389eceed196cde2365a3c31b73ad0
sha256 == 7af7c192ca8fdafb3454f7ba61b56266c6160a8116d2634cab8bb5be4bf594ae
prepend 65b3153ec014e07340762af60947e795a46e96f4383e326fd553a3d03a4fbb57 == 65b3153ec014e07340762af60947e795a46e96f4383e326fd553a3d03a4fbb577af7c192ca8fdafb3454f7ba61b56266c6160a8116d2634cab8bb5be4bf594ae
sha256 == c573eac1d18e72ed48ab636218d6c84a3f6796aac38ad4aa84a5d0e63b7d07fd
sha256 == f326c4c587898206deb5b1af5bbba5386c54eb082ce3dcdae5a67dbc0784a26b
append ca7a9cdfbf53b561f97cf8cfcd28441fdd891304d27ec0316077574b9a22dbdb == f326c4c587898206deb5b1af5bbba5386c54eb082ce3dcdae5a67dbc0784a26bca7a9cdfbf53b561f97cf8cfcd28441fdd891304d27ec0316077574b9a22dbdb
sha256 == ccd0cc13068bbc85a002b8dfce418d067c9a31e432e66517b7fd60e38c9d1971
sha256 == e900677d049aa26d249a4deecdb8a28f7cc85de1a867bcfa77f2ee45c491739f
prepend 97e12d7ad3afcb3f7f1e8f0992755a24c434becb4e044685069cd645fa26bd27 == 97e12d7ad3afcb3f7f1e8f0992755a24c434becb4e044685069cd645fa26bd27e900677d049aa26d249a4deecdb8a28f7cc85de1a867bcfa77f2ee45c491739f
sha256 == d4505ae9d09444d7ff1edd877a69bbd0e2466b4f940b79d6792b1c7e66e1beb0
sha256 == b6577b0fdf6fe2785ee23808045a1d515791b703841fb218d9ca033cd308aa32
append b559e1be99b73799e43d8c3f806cafe0a15261a219c197b49ab5a28149d34cc3 == b6577b0fdf6fe2785ee23808045a1d515791b703841fb218d9ca033cd308aa32b559e1be99b73799e43d8c3f806cafe0a15261a219c197b49ab5a28149d34cc3
sha256 == 6ee04cb403e97077d60168363170e9ffafb2c659a75afb7715da11f218ff9e04
sha256 == 568ea372efea13acd13a4bcfa8d82e2263c101b582f38d7608d571863faec38a
prepend da7d4268e745b85973740b40ffb71178e7dc34cccd0e87da5d9ac6a92bbf50b1 == da7d4268e745b85973740b40ffb71178e7dc34cccd0e87da5d9ac6a92bbf50b1568ea372efea13acd13a4bcfa8d82e2263c101b582f38d7608d571863faec38a
sha256 == bc34d3f2e50e838a58edd3a87655d1fd9f6759299ca85389784a52470b4c17fd
sha256 == ef6ac9b21ae8c5e39af379dfa177f15109a6be8a0ceae76e447466159e1d1333
append 38c206d73c5cd3d1188d6b5c1000d6d0c6dbad12f272b131cd0670855730edbc == ef6ac9b21ae8c5e39af379dfa177f15109a6be8a0ceae76e447466159e1d133338c206d73c5cd3d1188d6b5c1000d6d0c6dbad12f272b131cd0670855730edbc
sha256 == 7e8c847ef264cdbcf930af0906493fdf2d9fc38ecf9931805ac331ef09661916
sha256 == c5dd47a854aef30a4ddd6e0d36d21d5b8b7352eb4d4627737e6caca448b86072
append 8b08935599f2385da266d416aaaf0ba463c7b7f9e3f64af0a1a969a262a8abb5 == c5dd47a854aef30a4ddd6e0d36d21d5b8b7352eb4d4627737e6caca448b860728b08935599f2385da266d416aaaf0ba463c7b7f9e3f64af0a1a969a262a8abb5
sha256 == 9db4d09b00644eb03569168cd975c011acdfc8258ddd06f11ace5c6672258e6f
sha256 == 6f5e4df2685a6487c0666f79a0ad7a69702fa766b579487bc03f9862578f53b1
append 5653963194dfae298f7f1bb4fd71c82d8616a29654fd59b861dce16e1d25bf35 == 6f5e4df2685a6487c0666f79a0ad7a69702fa766b579487bc03f9862578f53b15653963194dfae298f7f1bb4fd71c82d8616a29654fd59b861dce16e1d25bf35
sha256 == 09e7521746de37fad116fde839e7924f77d1b13b679b3bb925dc89b6c2755c99
sha256 == 6fae019dce8a88c1c3264ceda7d146427d03fa01df475deaa1f8964d209f3f50
append 6fae019dce8a88c1c3264ceda7d146427d03fa01df475deaa1f8964d209f3f50 == 6fae019dce8a88c1c3264ceda7d146427d03fa01df475deaa1f8964d209f3f506fae019dce8a88c1c3264ceda7d146427d03fa01df475deaa1f8964d209f3f50
sha256 == afaf6f4014978d74d7289032991ccfad831e8eb3b18546337d38671386e5a59e
sha256 == eb2efd8ecc493a4e04dbc6cf43833cfea5b6379f9070c0e66c855d4c44c07c27
prepend bc7ffe58232456f8575de252f84feb723aac3bc1a701a90132cab08bf0d446c0 == bc7ffe58232456f8575de252f84feb723aac3bc1a701a90132cab08bf0d446c0eb2efd8ecc493a4e04dbc6cf43833cfea5b6379f9070c0e66c855d4c44c07c27
sha256 == f82d963ca42f3f3977c15c1a0a6c17d2fa3a7ebb765daf1ad9382812f1c2ab91
sha256 == 2770c1906bd858cc7757853a2ccfcaf650e748b7f0d428b9d093e3ed684e2b38
verify BitcoinBlockHeaderAttestation(421439)
# Bitcoin block merkle root 382b4e68ede393d0b928d4f0b748e750f6cacf2c3a855777cc58d86b90c17027

OpenTimestamp proof info receipt.ots on web visualizer

https://opentimestamps.org/info.html?ots=004f70656e54696d657374616d7073000050726f6f6600bf89e2e884e892940108bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2f120bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef208f120cb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf08f020cb0dbbedb5ec5363e39be9fc43f56f321e1572cfcf304d26fc67cb6ea2e49faf08f1a50101000000015cd30d6bc9b8e7a92d97e011b356b09cf7306a331c8ad63605dee4776c144c9d010000006b48304502210096811a70446463269e5d258267777f1b1e8ffe9c1965866bfd1a6c0250777c9c022049b5004a006e181fc92314ede95f3761a86831c5f99937465d99de6d14388b870121035b690114679d44d75b75aa170e34596c94c778f589bcb9063b0e4e293fcacd1dffffffff020000000000000000226a20f026cd996e00000000001976a9147003cc5915f6c23fd512b38daeeecfdde7a587e988ac000000000808f1209f0b3ab380760f32613d1757c35ebf55e8fdaf9f2c2cbe3c56aa00fe5f743eb00808f12082edea6ac21093305e010b9bb57816964cbe1865a70d5ff1e48719d4928b08f80808f12065b3153ec014e07340762af60947e795a46e96f4383e326fd553a3d03a4fbb570808f020ca7a9cdfbf53b561f97cf8cfcd28441fdd891304d27ec0316077574b9a22dbdb0808f12097e12d7ad3afcb3f7f1e8f0992755a24c434becb4e044685069cd645fa26bd270808f020b559e1be99b73799e43d8c3f806cafe0a15261a219c197b49ab5a28149d34cc30808f120da7d4268e745b85973740b40ffb71178e7dc34cccd0e87da5d9ac6a92bbf50b10808f02038c206d73c5cd3d1188d6b5c1000d6d0c6dbad12f272b131cd0670855730edbc0808f0208b08935599f2385da266d416aaaf0ba463c7b7f9e3f64af0a1a969a262a8abb50808f0205653963194dfae298f7f1bb4fd71c82d8616a29654fd59b861dce16e1d25bf350808f0206fae019dce8a88c1c3264ceda7d146427d03fa01df475deaa1f8964d209f3f500808f120bc7ffe58232456f8575de252f84feb723aac3bc1a701a90132cab08bf0d446c00808000588960d73d7190103bfdc19

Verify with OpenTimestamps compatible client

Install OpenTimestamps Python client

Then:

$ ots verify -d bdf8c9bdf076d6aff0292a1c9448691d2ae283f2ce41b045355e2c8cb8e85ef2 receipt.ots
Success! Bitcoin attests data existed as of Tue Jul 19 19:26:57 2016 CEST

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published