My main function takes 2 public inputs and returns a public array of length 2 .
During verify(), How to enter the return values in publicInputs[]?
Currently I am entering them using a bytes32 array of length 4 . But it says it expects only 3 .
fn main(
recipient: pub Field, // Recipient of funds
priv_key: Field, // Private key of note
note_root: pub Field, // Merkle membership proof
index: Field, // Index of note in merkle tree
note_hash_path: [Field; 3], // Merkle path of note
secret: Field, // Private key
) -> pub [Field; 2] {
// Derive public key from private key to show ownership
let pubkey = derive_public_key(priv_key);
// Compute commitment for note
let note_commitment = create_commitment(pubkey[0], pubkey[1], secret);
// std::println(note_commitment);
// Compute nullifier for note
let nullifier = check_nullifier(note_commitment, index, priv_key);
std::println(nullifier);
// Check that the input note commitment is in the root
let is_member = test_merkle_membership(note_root, note_commitment, index, note_hash_path);
// std::println(is_member);
// Constraint check
constrain is_member == 1;
// Cannot have unused variables, return the recipient as public output of the circuit
[nullifier, recipient]
}
Seems to be that noir recognize it as only 3 different values [recipient, note_root, nullifier]. @kevaundray, as I recall noir is normally yelling at you for returning inputs, should this not be the case when in lists? Seems like it should be either:
Don’t allow in and out
Allow both so there are 4 public outputs.
Right not it seems to land a bit in the middle where it is not clear what is really going on when building.