diff --git a/circom_circuits/Blend/poq.circom b/circom_circuits/Blend/poq.circom index 2cb4a17..407bfea 100644 --- a/circom_circuits/Blend/poq.circom +++ b/circom_circuits/Blend/poq.circom @@ -5,7 +5,7 @@ include "../hash_bn/poseidon2_hash.circom"; include "../misc/constants.circom"; // defines NOMOS_KDF, SELECTION_RANDOMNESS, PROOF_NULLIFIER include "../misc/comparator.circom"; include "../circomlib/circuits/bitify.circom"; -include "../Mantle/pol.circom"; // defines proof_of_leadership +include "../Mantle/pol_lib.circom"; // defines proof_of_leadership include "../ledger/notes.circom"; /** @@ -134,4 +134,4 @@ template ProofOfQuota(nLevelsPK, nLevelsPol, bitsQuota) { // Instantiate with chosen depths: 20 for core PK tree, 25 for PoL secret slot tree component main { public [ session, core_quota, leader_quota, core_root, pol_ledger_aged, K_part_one, K_part_two ] } - = ProofOfQuota(20, 25, 20); \ No newline at end of file + = ProofOfQuota(20, 25, 20); diff --git a/circom_circuits/Mantle/pol.circom b/circom_circuits/Mantle/pol.circom index 719fe33..2a91396 100644 --- a/circom_circuits/Mantle/pol.circom +++ b/circom_circuits/Mantle/pol.circom @@ -1,250 +1,6 @@ -//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"; +include "pol_lib.circom"; +component main {public [sl,epoch_nonce,t0,t1,ledger_aged,ledger_latest,P_lead_part_one,P_lead_part_two]}= proof_of_leadership(25); -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