> For the complete documentation index, see [llms.txt](https://docs.notcentralised.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.notcentralised.com/circuits/hashmincommitment.md).

# HashMinCommitment

The `HashMinCommitment` circuit is designed for generating hashed commitments and ensuring a certain amount is greater than or equal to a specified minimum amount.

### Input Signals

This circuit accepts the following input signals:

1. **amount**: This represents the amount under consideration.
2. **minAmount**: The minimum amount threshold.
3. **oracle\_owner**: Identifier for the owner of the oracle.
4. **oracle\_key**: Key for data retrieval in the oracle.
5. **oracle\_value**: The associated value with the oracle\_key.
6. **unlock\_sender**: Identifier for the sender in the unlock operation.
7. **unlock\_receiver**: Identifier for the receiver in the unlock operation.

```typescript
signal input amount;
signal input minAmount;
signal input oracle_owner;
signal input oracle_key;
signal input oracle_value;
signal input unlock_sender;
signal input unlock_receiver;
```

### Output Signals

This circuit outputs the following signals:

1. **amountHash**: Hash of the input amount.
2. **minAmountHash**: Hash of the minimum amount.
3. **idHash**: A complex hash, generated from all the input signals.

```circom
signal output amountHash;
signal output minAmountHash;
signal output idHash;
```

### Components

The circuit has several components:

* **comp1**: A comparator that checks if the `amount` is greater than or equal to the `minAmount`.

```circom
component comp1 = GreaterEqThan(252);
comp1.in[0] <== amount;
comp1.in[1] <== minAmount;
comp1.out === 1;
```

* **hashAmount**: A `Poseidon` hash function to hash the `amount`.

```circom
component hashAmount = Poseidon(1);
hashAmount.inputs[0] <== amount;
amountHash <== hashAmount.out;
```

* **hashMinAmount**: A `Poseidon` hash function to hash the `minAmount`.

```circom
component hashMinAmount = Poseidon(1);
hashMinAmount.inputs[0] <== minAmount;
minAmountHash <== hashMinAmount.out;
```

* **hashId**: A `Poseidon` hash function to hash all input signals to generate the `idHash`.

```circom
component hashId = Poseidon(6);
hashId.inputs[0] <== amount;
hashId.inputs[1] <== oracle_owner;
hashId.inputs[2] <== oracle_key;
hashId.inputs[3] <== oracle_value;
hashId.inputs[4] <== unlock_sender;
hashId.inputs[5] <== unlock_receiver;
idHash <== hashId.out;
```

### Inclusion of External Circuits

The circuit includes `poseidon` and `comparators` circuits from the `circomlib` library.

```circom
include "../../node_modules/circomlib/circuits/poseidon.circom";
include "../../node_modules/circomlib/circuits/comparators.circom";
```

### Main Component

The main component of this circuit file is the `HashMinCommitment` template.

```circom
component main = HashMinCommitment();
```

The `HashMinCommitment` circuit is used primarily for creating hashed commitments for amounts while enforcing that the amount is greater than or equal to the minimum threshold. The hashed outputs can be used for comparison and verification processes in other parts of your application.


---

# 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://docs.notcentralised.com/circuits/hashmincommitment.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.
