Merge pull request #94 from logos-co/Circom

fixed the generation of test that was miscalculating t0 and t1
This commit is contained in:
thomaslavaur 2025-09-08 11:44:53 +02:00 committed by GitHub
commit 93990b04b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 12 deletions

View File

@ -237,10 +237,13 @@ for i in range(20):
# 2) PoL inputs (broadened from pol script)
epoch_nonce = F(randrange(0, p,1))
slot_number = F(randrange(0, 2**32,1))
total_stake = F(5000)
total_stake = int(5000)
t0 = F(0x27b6fe27507ca57ca369280400c79b5d2f58ff94d87cb0fbfc8294eb69eb1ea)
t1 = F(0x104bfd09ebdd0a57772289d0973489b62662a4dc6f09da8b4af3c5cfb1dcdd)
t0_constant = F(0x27b6fe27507ca57ca369280400c79b5d2f58ff94d87cb0fbfc8294eb69eb1ea)
t1_constant = F(0x104bfd09ebdd0a57772289d0973489b62662a4dc6f09da8b4af3c5cfb1dcdd)
t0 = F(int(t0_constant) // total_stake)
t1 = F(p- (int(t1_constant) // total_stake**2))
value = F(total_stake / 100)
threshold = (t0 + t1 * value) * value
@ -284,8 +287,8 @@ for i in range(32):
index = randrange(0, Ql if core_or_leader else Qc,1)
# 4) Onetime key
K_one = F(randrange(0,p,1))
K_two = F(randrange(0,p,1))
K_one = F(123456)
K_two = F(654321)
# 5) Assemble JSON
inp = {
@ -316,9 +319,9 @@ inp = {
}
if core_or_leader == 0:
inp["pol_ledger_aged"] = randrange(0,p,1)
inp["pol_ledger_aged"] = str(randrange(0,p,1))
else:
inp["core_root"] = randrange(0,p,1)
inp["core_root"] = str(randrange(0,p,1))
import json

View File

@ -133,5 +133,5 @@ 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 ] }
component main { public [ session, core_quota, leader_quota, core_root, K_part_one, K_part_two, pol_epoch_nonce, pol_t0, pol_t1, pol_ledger_aged ] }
= ProofOfQuota(20, 25, 20);

View File

@ -219,8 +219,13 @@ if total_stake >= p:
print("total stake must be less than p")
exit()
t0 = F(0x27b6fe27507ca57ca369280400c79b5d2f58ff94d87cb0fbfc8294eb69eb1ea)
t1 = F(0x104bfd09ebdd0a57772289d0973489b62662a4dc6f09da8b4af3c5cfb1dcdd)
t0_constant = F(0x27b6fe27507ca57ca369280400c79b5d2f58ff94d87cb0fbfc8294eb69eb1ea)
t1_constant = F(0x104bfd09ebdd0a57772289d0973489b62662a4dc6f09da8b4af3c5cfb1dcdd)
t0 = F(int(t0_constant) // total_stake)
t1 = F(p- (int(t1_constant) // total_stake**2))
print(t0)
value = F(total_stake / 100)

View File

@ -2,5 +2,4 @@ pragma circom 2.1.9;
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);
component main {public [sl,epoch_nonce,t0,t1,ledger_aged,ledger_latest,P_lead_part_one,P_lead_part_two]}= proof_of_leadership(25);