> For the complete documentation index, see [llms.txt](https://cll-devrel.gitbook.io/bootcamp-2024/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cll-devrel.gitbook.io/bootcamp-2024/1.-blockchain-and-wallet-fundamentals/cryptography.md).

# Cryptography

* Cryptography is the study of the principles and techniques by which information can be transformed from its original form to a form that is not human readable
* Information can be known only to its recipient (holder of the "secret key")
* Difficult to read by an unauthorized person
* Only the recipient of the message can read the information easily

### Hash Function

> A hash function is any [function](https://en.wikipedia.org/wiki/Function_\(mathematics\)) that can be used to map [data](https://en.wikipedia.org/wiki/Data_\(computing\)) of arbitrary size to fixed-size values, though there are some hash functions that support variable length output. The values returned by a hash function are called *hash values*, *hash codes*, *hash digests*, *digests*, or simply *hashes*. The values are usually used to index a fixed-size table called a [*hash table*](https://en.wikipedia.org/wiki/Hash_table). Use of a hash function to index a hash table is called *hashing* or *scatter storage addressing*.

{% embed url="<https://en.wikipedia.org/wiki/Hash_function>" %}
Hash Function Definition
{% endembed %}

### Merkle Tree

> In [cryptography](https://en.wikipedia.org/wiki/Cryptography) and [computer science](https://en.wikipedia.org/wiki/Computer_science), a hash tree or Merkle tree is a [tree](https://en.wikipedia.org/wiki/Tree_\(data_structure\)) data structure in which every "leaf" [node](https://en.wikipedia.org/wiki/Tree_\(data_structure\)#Terminology) (a node with no "child" nodes)  is labelled with the [cryptographic hash](https://en.wikipedia.org/wiki/Cryptographic_hash_function) of a data block.  Every other node that is *not* a leaf is labelled with the cryptographic hash of the labels of its child nodes. A hash tree allows efficient and secure verification of the contents of a large [data structure](https://en.wikipedia.org/wiki/Data_structure). A hash tree is a generalization of a [hash list](https://en.wikipedia.org/wiki/Hash_list) and a [hash chain](https://en.wikipedia.org/wiki/Hash_chain).

{% embed url="<https://en.wikipedia.org/wiki/Merkle_tree>" %}
Merkle Tree Definition
{% endembed %}

> Merkle trees are used to "summarize" and store all the transactions in a block, producing an overall digital fingerprint of the entire set of transactions, providing a very efficient process to verify whether a transaction is included in a block.
>
> * According to Andreas M. Antonopoulos, in "The Bitcoin Protocol"

### Public key and Private Key in Blockchain

Public Key Cryptography provides a mechanism to secure and validate information between two parties securely and safely. The public key is linked to a corresponding private key. A public key is a publicly available cryptographic artifact that allows users to encrypt information that only you would then be able to decrypt. \
\
Example workflow: Pat has a message they want to send you. Pat can use your public key to encrypt the message. That message can now only be decrypted with the corresponding private key that the public key was linked to.&#x20;

#### Cryptography:

* Anyone can encrypt a message using the recipient's public key
* Only the private key owner can decrypt messages encrypted with the corresponding public key

#### Authentication:

* Only the private key owner can sign/authorize transactions (digital signature)
* The public key confirms the sender's identity, verifying that the private key holder sent the message

{% hint style="info" %}
WARNING: NEVER GIVE YOUR PRIVATE KEY AWAY. USERS CAN DECRYPT YOUR MESSAGES AND SIGN TRANSACTIONS IN YOUR NAME
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cll-devrel.gitbook.io/bootcamp-2024/1.-blockchain-and-wallet-fundamentals/cryptography.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
