I have been learning more about bitcoin and programming at the same time all the while having some fun with both. On bitcoin front I have been exploring the Digital Signature Algorithms and mainly focusing on elliptic curves, on programming front focusing on Inversion of Control and it has been letting me do stuff like this.
Since bitcoin is 10 years old today I chose 10 different bitcoin implementations and posted the results here.
There are 2 different Digital Signature Algorithms (ECDSA and ECSDSA) using 5 different curves hence 10 different coins. The algorithms being Elliptic Curve DSA that bitcoin is using and Elliptic Curve based Schnorr DSA. The list of them with additional information can be seen in the following table:
* Schnorr algorithms are based on the original 1991 paper in Journal of Cryptology not the sipa’s unofficial BIP. The reason is that the later has a Jacobi Symbol and I wasn't sure if I was calculating it correctly and I have no unit tests although my verify returns true.
To make it related to this occasion (the 10th bitcoin birthday) I chose the following “Easter egg” which can be found in the very first bitcoin block as a seed to find the first private key using a simple SHA512 hash.
The Times 03/Jan/2009 Chancellor on brink of second bailout for banks
To reduce the size of the key for each coin a simple
% curve.N was performed.
prvbtc521: ctCJLpKQRGeEy1vfwURYJCwwP7AGkyo9V75f8K7DVTSdLaJ4cfMatnQUdZg6Dp3RyrBKm2HjrbsgzR1NmPEikMFB2Qxx6QSDr
prvbtc: cTf2PDXMK6fbZUAC4GV8N8wewnzurabVeXJ2JqvpZbMvcxDjZGyz
prvbtc192: ci9qEELh7Fba2YUP8HLAtaEwRuossREiMfXamMPNj
prvbtc384: Cs5Yoy2n2y7kVcwotu1kGfrhqnSjqhuMubCXQMggGS7q23HsnnNEAz5YYTCXy95AaK4YdW5C3Z
Here is the transaction with bitcoin (I'll broadcast the rest in the alternate universes!)
https://www.blocktrail.com/tBTC/tx/7feef9bf65de07a391658e57a61ff9f3ba3b7dd8fce8f28fea38d0267cad89fcI have not used any libraries, everything is my own implementation so it means it is not optimized and it may contain bugs. But it is interesting to say that the time signing operation takes is increasing with the curve size but with a whopping rise with last two ones which I believe is partly because of the a and b values of random curves compared to Koblitz curve. As for Schnorr the time is reduced about 5% because it doesn't have the multiplicative inverse modulo n. Of course Schnorr becomes more interesting when it involves verifying many signatures at the same time.
Transaction sizes for each curve, just for fun:
* Schnorr transaction sizes are the same with 1-2 byte difference.
Here is how bitcoin would look like with Schnorr (note that I believe Schnorr signatures will be implemented through SegWit with a new witversion but I am just guessing since I had no time reading the roadmap yet so I simply change the signature algorithm with Schnorr here):
hex:
01000000015a2647bfc3a43aa2104c8da0d9d71c8954826a6dd6f8e42df9cda6f96fb2e331000000006c493046022100bf560f18bddd23959b2600dbbfc8acdc8de8f747e01cd357f1dd2c1d5be9e875022100f932d8b2bf204b1b0a44a774099a0c670b44dcaccad489e124610d423984e5550121034a60644fb34922cfaef5648ab96593a2597d57d2aafaa698333995499c4fb113ffffffff01e2a69b00000000001976a914ecb20c627ad0e84456952666ed6c1d0c7eb9bc9388ac00000000
Serialized:
{
"Version": 1,
"TxInCount": 1,
"TxInList": [
{
"Outpoint": {
"TxId": "31e3b26ff9a6cdf92de4f8d66d6a8254891cd7d9a08d4c10a23aa4c3bf47265a",
"TxHash": "5a2647bfc3a43aa2104c8da0d9d71c8954826a6dd6f8e42df9cda6f96fb2e331",
"Index": 0
},
"ScriptSigLength": 108,
"ScriptSig": "493046022100bf560f18bddd23959b2600dbbfc8acdc8de8f747e01cd357f1dd2c1d5be9e875022100f932d8b2bf204b1b0a44a774099a0c670b44dcaccad489e124610d423984e5550121034a60644fb34922cfaef5648ab96593a2597d57d2aafaa698333995499c4fb113",
"Sequence": 4294967295
}
],
"TxOutCount": 1,
"TxOutList": [
{
"Amount": 10200802,
"PkScriptLength": 25,
"PkScript": "76a914ecb20c627ad0e84456952666ed6c1d0c7eb9bc9388ac"
}
],
"LockTime": 0,
"Flag": 0,
"WitnessList": null
}
Happy 10th birthday, bitcoin.