Author

Topic: OP_CHECKSIG algorithm? (Read 835 times)

sr. member
Activity: 319
Merit: 250
April 23, 2016, 06:44:32 AM
#2
Just so I know I'm on the right path, is this the function that checks that the signature is valid?

secp256k1_ecdsa_sig_verify
sr. member
Activity: 319
Merit: 250
April 22, 2016, 02:45:31 PM
#1
As expressed in Script, the scriptSig is:

PUSHDATA
signature data and SIGHASH_ALL
PUSHDATA
public key data

The scriptPubKey is: OP_DUP
OP_HASH160
PUSHDATA
Bitcoin address (public key hash)
OP_EQUALVERIFY
OP_CHECKSIG

When this code executes, PUSHDATA first pushes the signature to the stack. The next PUSHDATA pushes the public key to the stack. Next, OP_DUP duplicates the public key on the stack. OP_HASH160 computes the 160-bit hash of the public key. PUSHDATA pushes the required Bitcoin address. Then OP_EQUALVERIFY verifies the top two stack values are equal - that the public key hash from the new transaction matches the address in the old address. This proves that the public key is valid. Next, OP_CHECKSIG checks that the signature of the transaction matches the public key and signature on the stack. This proves that the signature is valid.

Sorry, found it.

https://en.bitcoin.it/wiki/OP_CHECKSIG
Jump to: