2025-03-26 11:46:34 +01:00
|
|
|
//test
|
|
|
|
|
pragma circom 2.1.9;
|
|
|
|
|
|
2025-03-26 14:44:56 +01:00
|
|
|
include "../hash_bn/poseidon2_hash.circom";
|
2025-03-26 11:46:34 +01:00
|
|
|
include "merkle.circom";
|
2025-03-26 14:44:56 +01:00
|
|
|
include "../misc/constants.circom";
|
2025-03-26 11:46:34 +01:00
|
|
|
|
|
|
|
|
// The unit of the note is supposed to be NMO
|
|
|
|
|
template commitment(){
|
|
|
|
|
signal input state;
|
|
|
|
|
signal input value;
|
|
|
|
|
signal input unit;
|
|
|
|
|
signal input nonce;
|
|
|
|
|
signal input zoneID;
|
|
|
|
|
signal input public_key;
|
|
|
|
|
signal output out;
|
|
|
|
|
|
|
|
|
|
component hash = Poseidon2_hash(7);
|
2025-03-26 14:44:56 +01:00
|
|
|
component dst = NOMOS_NOTE_CM();
|
|
|
|
|
hash.inp[0] <== dst.out;
|
2025-03-26 11:46:34 +01:00
|
|
|
hash.inp[1] <== state;
|
|
|
|
|
hash.inp[2] <== value;
|
|
|
|
|
hash.inp[3] <== unit;
|
|
|
|
|
hash.inp[4] <== nonce;
|
|
|
|
|
hash.inp[5] <== public_key;
|
|
|
|
|
hash.inp[6] <== zoneID;
|
|
|
|
|
|
|
|
|
|
out <== hash.out;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-29 11:32:56 +02:00
|
|
|
// We don't use it anymore
|
2025-03-26 11:46:34 +01:00
|
|
|
template nullifier(){
|
|
|
|
|
signal input commitment;
|
|
|
|
|
signal input secret_key;
|
|
|
|
|
signal output out;
|
|
|
|
|
|
|
|
|
|
component hash = Poseidon2_hash(3);
|
2025-03-26 14:44:56 +01:00
|
|
|
component dst = NOMOS_NOTE_NF();
|
|
|
|
|
hash.inp[0] <== dst.out;
|
2025-03-26 11:46:34 +01:00
|
|
|
hash.inp[1] <== commitment;
|
|
|
|
|
hash.inp[2] <== secret_key;
|
|
|
|
|
|
|
|
|
|
out <== hash.out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template derive_public_key(){
|
|
|
|
|
signal input secret_key;
|
|
|
|
|
signal output out;
|
|
|
|
|
|
|
|
|
|
component hash = Poseidon2_hash(2);
|
2025-03-26 14:44:56 +01:00
|
|
|
component dst = NOMOS_KDF();
|
|
|
|
|
hash.inp[0] <== dst.out;
|
2025-03-26 11:46:34 +01:00
|
|
|
hash.inp[1] <== secret_key;
|
|
|
|
|
out <== hash.out;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-04 11:39:09 +02:00
|
|
|
template derive_unit(){
|
|
|
|
|
signal input minting_covenant;
|
2025-04-04 15:40:39 +02:00
|
|
|
signal input spending_covenant;
|
2025-04-04 11:39:09 +02:00
|
|
|
signal input burning_covenant;
|
2025-04-14 11:21:06 +02:00
|
|
|
signal input unit_arg_cm;
|
2025-04-04 11:39:09 +02:00
|
|
|
signal output out;
|
|
|
|
|
|
2025-04-14 11:21:06 +02:00
|
|
|
component hash = Poseidon2_hash(5);
|
2025-04-04 11:39:09 +02:00
|
|
|
component dst = NOMOS_UNIT();
|
|
|
|
|
hash.inp[0] <== dst.out;
|
|
|
|
|
hash.inp[1] <== minting_covenant;
|
2025-04-04 15:40:39 +02:00
|
|
|
hash.inp[2] <== spending_covenant;
|
2025-04-04 11:39:09 +02:00
|
|
|
hash.inp[3] <== burning_covenant;
|
2025-04-14 11:21:06 +02:00
|
|
|
hash.inp[4] <== unit_arg_cm;
|
2025-04-04 11:39:09 +02:00
|
|
|
out <== hash.out;
|
|
|
|
|
}
|
|
|
|
|
|