Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions recursive_verification/contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,33 @@ pub contract ValueNotEqual {
global HONK_PROOF_SIZE: u32 = 492 + 16;

use aztec::{
macros::{functions::{external, initializer}, storage::storage},
macros::{functions::{external, initializer, internal}, storage::storage},
oracle::debug_log::debug_log_format,
protocol_types::{address::AztecAddress, traits::ToField},
state_vars::Map,
state_vars::{Map, PublicImmutable},
};
use bb_proof_verification::verify_ultrahonkzk_proof;
use easy_private_state::EasyPrivateUint;

#[storage]
struct Storage<Context> {
counters: Map<AztecAddress, EasyPrivateUint<Context>, Context>,
vk_hash: PublicImmutable<Field, Context>,
}

#[initializer]
#[external("private")]
fn initialize(headstart: u64, owner: AztecAddress) {
fn initialize(headstart: u64, owner: AztecAddress, vk_hash: Field) {
let counters = storage.counters;
counters.at(owner).add(headstart, owner);

ValueNotEqual::at(context.this_address())._set_vk_hash(vk_hash).enqueue(&mut context);
}

#[internal]
#[external("public")]
fn _set_vk_hash(vk_hash: Field) {
storage.vk_hash.initialize(vk_hash);
}

#[external("private")]
Expand All @@ -32,9 +41,9 @@ pub contract ValueNotEqual {
verification_key: [Field; HONK_VK_SIZE],
proof: [Field; HONK_PROOF_SIZE],
public_inputs: [Field; 1],
vk_hash: Field,
) {
debug_log_format("Incrementing counter for owner {0}", [owner.to_field()]);
let vk_hash = storage.vk_hash.read();
verify_ultrahonkzk_proof(verification_key, proof, public_inputs, vk_hash);
ValueNotEqual::at(context.this_address()).emit_in_public(12345).enqueue(&mut context);
let counters = storage.counters;
Expand Down
Loading
Loading