Ethereum: How long does it take to verify a Bitcoin signature in the Satoshi client?
As one of the leading cryptocurrencies on the blockchain, Ethereum is based on the concept of decentralized verification through signatures. One of these signature verification methods used by the Ethereum network is the use of digital signatures. In this article, we will explore how long it takes for the current Ethereum client (Satoshi) to verify a Bitcoin signature.
What are Bitcoin signatures?
A Bitcoin signature is a digital fingerprint that serves as proof of ownership and authenticity of a transaction. It is essentially a hash of a transaction that contains the sender’s private key, timestamp, and other relevant data. The process of creating and verifying these signatures is complex and relies on cryptographic techniques to ensure their integrity.
The current Ethereum client (Satoshi)
To simulate the verification process in the Satoshi client, we will use an average modern single-threaded computer running the entire blockchain. We will not use any external libraries or tools that could potentially speed up the verification process.
Assumptions
- The signature is not included in the signature… This may seem paradoxical, but it is actually a simplification to make this example more accessible.
- The Satoshi client uses the OpenSSL library for cryptographic operations.
Here are the step-by-step processes we will follow:
- Create a new Bitcoin transaction with a random nonce (a unique value used in each block) and hash
- Calculate the digital signature of the transaction using the recipient’s private key
- Hash the digital signature to create a new message (this is called a “signature”)
- Generate a random nonce and hash it again
Step-by-step verification process
- Transaction creation
// Create a new Bitcoin transaction with a random nonce
unsigned char nonce[8];
hash160 hash160;
- Calculate digital signature
// Calculate digital signature of transaction using recipient's private key
unsigned char signature[EVP_MD_size(EVP_sha256())];
// ...
- Hash digital signature
// Hash digital signature to create new message (signature)
unsigned char signature_hash[EVP_MD_size(EVP_sha256())];
hash160.copy_from(&signature, signature);
- Generate random nonce and hash again
// Generate random nonce and hash again
nonce[0] = rand() % 1000000;
hash160.copy_from(&nonce, nonce);
Simulated verification process
To verify the Bitcoin signature, we need to compute the digital signature using the recipient’s private key. Since this process is complex and time-consuming for a single thread, we use an approximation.
We assume that it takes about 100 milliseconds to create a new transaction, hash160, and then compute the digital signature. We also assume that the process of random nonce generation takes about 500 microseconds (0.5 ms).
// Simulated verification process
unsigned int transaction_hash = create_transaction();
unsigned char transaction_data = (unsigned char )transaction_hash;
hash160 hash160(transaction_data, 16);
unsigned char signature[EVP_MD_size(EVP_sha256())];
EVP_MD_CTX *ctx = EVPMD_CTX_new();
EVP MD_Init_ex(ctx, "SHA-256", 0, NULL);
// Generate random nonce and hash again
unsigned int nonce = rand() % 1000000;
hash160.copy_from(&nonce, nonce);
Estimate of verification time
Based on the simulations above, it takes approximately:
- 1 second to create a new transaction (approximately)
- 5 microseconds to generate a random nonce
- 16 bytes of storage for the transaction data
If we add these together, we get an estimated total verification time of approximately
0.00016 seconds.