derive the unit using the new unit_arg

This commit is contained in:
thomaslavaur 2025-04-14 11:21:06 +02:00
parent ec0eef618d
commit 83d4a7dbee
4 changed files with 10 additions and 9 deletions

View File

@ -212,7 +212,7 @@ maxInputs = int(sys.argv[Integer(1)])
maxOutputs = int(sys.argv[Integer(2)])
value_in = [F(randrange(0,10000,1) )for i in range(maxInputs) ]
unit = F(19676183153323264216568033390884511718872104179761154996527087027500271872825)
unit = F(10779557959052216631390333682740231728667240537997953966056427002575892499162)
state_in = [F(randrange(0,p,1)) for i in range(maxInputs) ]
zone_in = [F(randrange(0,p,1)) for i in range(maxInputs) ]
note_nonce_in = [F(randrange(0,p,1)) for i in range(maxInputs)]
@ -244,8 +244,7 @@ is_a_output_note[0] = F(1)
with open("input.json", "w") as file:
file.write('{\n\t"minting_covenant" :\t\t\t\t"'+str(0)+'",')
file.write('\n\t"burning_covenant" :\t\t\t\t"'+str(0)+'",')
file.write('{\n\t"unit_arg_cm" :\t\t\t\t"'+str(0)+'",')
file.write('\n\t"state_in" :\t\t\t\t\t[')
for i in range(maxInputs):
file.write('"')

View File

@ -23,4 +23,4 @@ template proof_of_unshielded_note_ownership(maxInput){
dummy <== attached_data * attached_data;
}
component main {public [attached_data]}= proof_of_unshielded_note_ownership(1);
component main {public [attached_data]}= proof_of_unshielded_note_ownership(5);

View File

@ -6,8 +6,7 @@ include "../misc/constants.circom";
template shielded_transaction(maxInputs, maxOutputs){
signal input minting_covenant; // Used to derive the unit and make sure the token use a no-op spending covenant.
signal input burning_covenant;
signal input unit_arg_cm; // Used to derive the unit and make sure the token use a no-op spending covenant.
//consummed notes
// notes themselves
@ -40,9 +39,10 @@ template shielded_transaction(maxInputs, maxOutputs){
//Derive the unit
component derive_unit = derive_unit();
derive_unit.minting_covenant <== minting_covenant;
derive_unit.minting_covenant <== 0;
derive_unit.spending_covenant <== 0; // 0 encodes the fact that it's a no-op transfer covenant
derive_unit.burning_covenant <== burning_covenant;
derive_unit.burning_covenant <== 0;
derive_unit.unit_arg_cm <== unit_arg_cm;
unit <== derive_unit.out;

View File

@ -57,14 +57,16 @@ template derive_unit(){
signal input minting_covenant;
signal input spending_covenant;
signal input burning_covenant;
signal input unit_arg_cm;
signal output out;
component hash = Poseidon2_hash(4);
component hash = Poseidon2_hash(5);
component dst = NOMOS_UNIT();
hash.inp[0] <== dst.out;
hash.inp[1] <== minting_covenant;
hash.inp[2] <== spending_covenant;
hash.inp[3] <== burning_covenant;
hash.inp[4] <== unit_arg_cm;
out <== hash.out;
}