Bind a Mina MerkleMap witness to the requested key
An o1js MerkleMap witness reconstructs both a root and a key. A zkApp checking only the root can accept membership of a different account in the same map.
Test two equal-valued leaves
Place Alice and Bob at different keys with the same allowance value. Request Alice's allowance but supply Bob's witness. The computed root is correct because Bob's leaf belongs to the trusted map. Constrain the reconstructed key to Alice's application-derived key as well, using identical key derivation in the prover and circuit.
const [root, key] = witness.computeRootAndKey(value);
root.assertEquals(trustedRoot);
key.assertEquals(requestedKey);
Anchor the root to trusted state
A caller-provided root and matching path can describe an entirely fabricated map. Bind trustedRoot to the authenticated contract state or an explicitly verified public input. Together the constraints identify the desired value at the desired key for a particular snapshot of the map.