# Hash verify between JS and noir-lang circuit

**URL:** <https://forum.aztec.network/t/hash-verify-between-js-and-noir-lang-circuit/2522>\
**Category:** Noir\
**Created:** [November 7, 2023, 4:06pm UTC](https://forum.aztec.network/t/hash-verify-between-js-and-noir-lang-circuit/2522 "2023-11-07T16:06:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shuffle](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.aztec.network/shuffle/32/1734_2.png) [@shuffle](https://forum.aztec.network/u/shuffle)\
**Post date:** [November 7, 2023, 4:06pm UTC](https://forum.aztec.network/t/hash-verify-between-js-and-noir-lang-circuit/2522/1 "2023-11-07T16:06:33Z")

</div>

Hello Aztec community,  
I have several questions 😀  
Here’s a function to check whether a value is in the hash’s integrity:

```auto
fn main(hash: pub Field, a: Field, b: Field, c: Field, d: Field) {
    let hashPoseidon = std::hash::poseidon::bn254::hash_4([a, b, c, d]);
    std::println(hashPoseidon);
    assert(hash == hashPoseidon);
}

```

Am I using the most efficient hash function? (Compared to pedersen)  
This function works very well with nargo test, prove, verify, but it’s only when I generate a proof with JS.  
Sometimes i have this message:

> “Error: the string “Error calling `foreign_call_callback`: Unknown” was thrown, throw an Error”

And sometimes I am told that the constraints are not respected.  
What should I send? a hexadecimal string? a bigInt? an uint8Array?

I have an older version of JS-project that uses:  
`"@noir-lang/acvm_js": "git+https://git@github.com/noir-lang/acvm-simulator-wasm.git#b9d9ca9dfc5140839f23998d9466307215607c42"`

What do you recommend? I’m stuck

Thank in advance.

---

<div class="post-metadata">

**Author:** ![shuffle](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.aztec.network/shuffle/32/1734_2.png) [@shuffle](https://forum.aztec.network/u/shuffle)\
**Post date:** [November 8, 2023, 1:54pm UTC](https://forum.aztec.network/t/hash-verify-between-js-and-noir-lang-circuit/2522/2 "2023-11-08T13:54:58Z")

</div>

I found a solution for certain problems:  
the error: `foreign_call_callback`  
come from a circuit compile with a `std::println` inside. 😅  
With my hardhat JS project, I send a BigInt for the Poseidon hash, and it fulfills all the constraints for the proof generation.

I still don’t have an answer about the efficiency of hash functions. 🙃

---

<div class="post-metadata">

**Author:** ![Savio](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.aztec.network/savio/32/21_2.png) [@Savio](https://forum.aztec.network/u/Savio)\
**Post date:** [November 22, 2023, 8:54pm UTC](https://forum.aztec.network/t/hash-verify-between-js-and-noir-lang-circuit/2522/3 "2023-11-22T20:54:29Z")

</div>

Hi there! Sorry for the late reply.

To find out which design approach is more efficient in general, you can run the [`nargo info`](https://noir-lang.org/nargo/commands#nargo-info) command to gather the constraint count of your code.

The lower the number, the faster it proves.

In case you’re still running into any problems with JS, the latest recommended workflow is described [here](https://noir-lang.org/noir_js/getting_started/tiny_noir_app).

If that’s already what you are using, it’d be very helpful if you could file a bug report with code + steps to reproduce the problem you’re facing on the [Noir GitHub](https://github.com/noir-lang/noir/issues) 🙏

Thank you and hope you enjoy Noir!
