Let's say Peer A sends a transaction to contract.How peer B and peer C will be able to see this.Does they require to do encryption.If so then how?Does each and every peers should have the public key of every account?
2 Answers
The data of the transactions is visible for all nodes, this is needed so they can execute the contracts. Therefore, no encryption is needed to send a transaction.
See also:
-
Whenever a transaction is made, its only signed by the private key. This is required to verify the authenticity of the sender (to prevent fraudulent entries). Is it the correct concept ? If so then how the signing process happens.Can I have a little deep explanation on it. Commented Jun 22, 2017 at 6:02
-
@BudhadityaDutta, you are right, transactions are signed with the private key, but only the corresponding public key is needed to verify the signature (see Asymetric Cryptography Signatures for more about this). A contract can only perform transactions following its own coded rules. Therefore no signature is needed for a contract transaction. For instance, if a contract says that after receiving an address as parameter of its gift method, it gives 1 ether to that address if it has enough funding, the peers can verify that the contract have enough funds and then send the ether to the address.– atfornesCommented Jun 22, 2017 at 10:04
You asked:
... how the signing process happens. Can I have a little deep explanation on it.
If you want the deep explanation, then see Appendix F of the Yellow Paper, where the transaction signing and verification process is described in detail.
In short, a transaction you send is more-or-less in plain text; it is not encrypted. However, it is accompanied by a signature over the transaction data. This signature is created from the transaction data and your private key.
When a node receives your transaction, it can process the signature using a technique called ECDSARECOVER
. The output of this is your public key, and your account address is generated directly from your public key (it's not a secret). If the address generated from the recovered public key matches the "from" address in your transaction, then we know that the whole transaction was signed with a correct private key for your account.
Contracts don't have private keys, and therefore they can't send transactions. Instead there are other mechanisms for contracts to call each other or send value internally within the EVM.