//test pragma circom 2.1.9; include "../hash_bn/poseidon2_hash.circom"; include "../ledger/notes.circom"; include "../hash_bn/merkle.circom"; include "../misc/comparator.circom"; include "../circomlib/circuits/bitify.circom"; include "../misc/constants.circom"; template ticket_calculator(){ signal input epoch_nonce; signal input slot; signal input note_id; signal input secret_key; signal output out; component hash = Poseidon2_hash(5); component dst = LEAD_V1(); hash.inp[0] <== dst.out; hash.inp[1] <== epoch_nonce; hash.inp[2] <== slot; hash.inp[3] <== note_id; hash.inp[4] <== secret_key; out <== hash.out; } template derive_entropy(){ signal input slot; signal input note_id; signal input secret_key; signal output out; component hash = Poseidon2_hash(4); component dst = NOMOS_NONCE_CONTRIB_V1(); hash.inp[0] <== dst.out; hash.inp[1] <== slot; hash.inp[2] <== note_id; hash.inp[3] <== secret_key; out <== hash.out; } template would_win_leadership(secret_depth){ signal input slot; signal input epoch_nonce; signal input t0; signal input t1; signal input slot_secret; signal input slot_secret_path[secret_depth]; //Part of the note id proof of membership to prove aged signal input aged_nodes[32]; signal input aged_selectors[32]; // must be bits signal input aged_root; //Used to derive the note identifier signal input transaction_hash; signal input output_number; //Part of the secret key signal input starting_slot; // The winning note value signal input value; signal output out; signal output note_identifier; signal output secret_key; // Derivation of the secrets root from the slot secret at position slot - starting_slot // Verify that the substraction wont underflow (starting_slot < slot) component checker = SafeFullLessThan(); checker.a <== starting_slot; checker.b <== slot; // Compute the positions related to slot - starting_slot and make sure slot - starting_slot is a 25 bits number component bits = Num2Bits(secret_depth); bits.in <== slot - starting_slot; // Derive the secrets root component secrets_root = compute_merkle_root(secret_depth); for(var i=0; i