update SECRET_KEY to POL_SK dst

This commit is contained in:
thomaslavaur 2025-03-27 08:03:27 +01:00
parent 3ea1442289
commit 0d98123326
3 changed files with 18 additions and 17 deletions

View File

@ -11,10 +11,10 @@ template LEAD(){
}
// int.from_bytes(hashlib.sha256(b"NOMOS_SECRET_KEY").digest()[:-1], "little") = 344114695764831179145057610008294480248205750382057360672614582644594850870
template NOMOS_SECRET_KEY(){
// int.from_bytes(hashlib.sha256(b"NOMOS_POL_SK").digest()[:-1], "little") = 313763129738690320248895675268201668175331181115752393250540330459318963992
template NOMOS_POL_SK(){
signal output out;
out <== 344114695764831179145057610008294480248205750382057360672614582644594850870;
out <== 313763129738690320248895675268201668175331181115752393250540330459318963992;
}

View File

@ -5,6 +5,7 @@ include "../hash_bn/poseidon2_hash.circom";
include "../ledger/notes.circom";
include "../misc/comparator.circom";
include "../circomlib/circuits/bitify.circom";
include "../misc/constants.circom";
template ticket_calculator(){
@ -15,8 +16,8 @@ template ticket_calculator(){
signal output out;
component hash = Poseidon2_hash(5);
// int.from_bytes(hashlib.sha256(b"LEAD").digest()[:-1], "little") = 137836078329650723736739065075984465408055658421620421917147974048265460598
hash.inp[0] <== 137836078329650723736739065075984465408055658421620421917147974048265460598;
component dst = LEAD();
hash.inp[0] <== dst.out;
hash.inp[1] <== epoch_nonce;
hash.inp[2] <== slot;
hash.inp[3] <== commitment;
@ -31,8 +32,8 @@ template derive_secret_key(){
signal output out;
component hash = Poseidon2_hash(3);
// int.from_bytes(hashlib.sha256(b"NOMOS_SECRET_KEY").digest()[:-1], "little") = 344114695764831179145057610008294480248205750382057360672614582644594850870
hash.inp[0] <== 344114695764831179145057610008294480248205750382057360672614582644594850870;
component dst = NOMOS_POL_SK();
hash.inp[0] <== dst.out;
hash.inp[1] <== starting_slot;
hash.inp[2] <== secrets_root;
@ -46,8 +47,8 @@ template derive_entropy(){
signal output out;
component hash = Poseidon2_hash(4);
// int.from_bytes(hashlib.sha256(b"NOMOS_NONCE_CONTRIB").digest()[:-1], "little") = 193275670388587576544090216996849534520361117581542778964162861667418671481
hash.inp[0] <== 193275670388587576544090216996849534520361117581542778964162861667418671481;
component dst = NOMOS_NONCE_CONTRIB();
hash.inp[0] <== dst.out;
hash.inp[1] <== slot;
hash.inp[2] <== commitment;
hash.inp[3] <== secret_key;
@ -109,11 +110,11 @@ template payment_proof_of_leadership(){
component cm = commitment();
cm.state <== state;
cm.value <== value;
// int.from_bytes(hashlib.sha256(b"NMO").digest()[:-1], "little") = 161796427070100155131822184769584603407573991022311108406630770340454367555
cm.unit <== 161796427070100155131822184769584603407573991022311108406630770340454367555;
component nmo = NMO();
cm.unit <== nmo.out;
cm.nonce <== nonce;
// int.from_bytes(hashlib.sha256(b"PAYMENT").digest()[:-1], "little") = 281646683567839822174419720505039861445414630574005374635737888376398200354
cm.zoneID <== 281646683567839822174419720505039861445414630574005374635737888376398200354;
component payment = PAYMENT();
cm.zoneID <== payment.out;
cm.public_key <== pk.out;

View File

@ -208,9 +208,9 @@ if len(sys.argv) != Integer(4):
print("Usage: <script> <epoch_nonce> <slot_number> <total_stake>")
exit()
epoch_nonce = 10 #int(sys.argv[Integer(1)])
slot_number = 1683167 #int(sys.argv[Integer(2)])
total_stake = 50000 #int(sys.argv[Integer(3)])
epoch_nonce = int(sys.argv[Integer(1)])
slot_number = int(sys.argv[Integer(2)])
total_stake = int(sys.argv[Integer(3)])
if epoch_nonce >= p:
print("epoch nonce must be less than p")
@ -240,7 +240,7 @@ for i in range(25):
secret_root = poseidon2_hash([secret_root,slot_secret_path[i]])
else:
secret_root = poseidon2_hash([slot_secret_path[i],secret_root])
sk = poseidon2_hash([F(344114695764831179145057610008294480248205750382057360672614582644594850870),starting_slot,secret_root])
sk = poseidon2_hash([F(313763129738690320248895675268201668175331181115752393250540330459318963992),starting_slot,secret_root])
pk = poseidon2_hash([F(355994159511987982411097843485998670968942801951585260613801918349630142543),sk])
note_cm = poseidon2_hash([F(181645510297841241569044198526601622686169271532834574969543446901055041748),state,value,unit,note_nonce,pk,F(281646683567839822174419720505039861445414630574005374635737888376398200354)])