Skip to content

Commit

Permalink
Add a noop tx for account circuit. (#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
suyash67 authored Nov 28, 2022
1 parent 37adf5c commit d8d2921
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/aztec/rollup/proofs/account/compute_circuit_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,49 @@ namespace rollup {
namespace proofs {
namespace account {

using namespace plonk::stdlib::merkle_tree;

/**
* @brief Create an account noop transaction that sets the members in account_tx to be random/zero values.
* Note that the noop account tx satisfies the circuit logic, and hence can be used to create "dummy" account proofs
* that pass verification.
*
* @warning This must not be used in any production code!
*/
inline account_tx noop_tx()
{
grumpkin::fr priv_key = grumpkin::fr::random_element();
grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key;

grumpkin::fr new_priv_key = grumpkin::fr::random_element();
grumpkin::g1::affine_element new_pub_key = grumpkin::g1::one * new_priv_key;

auto gibberish_path = fr_hash_path(DATA_TREE_DEPTH, std::make_pair(fr::random_element(), fr::random_element()));

account_tx tx = {};
tx.merkle_root = fr::random_element();
tx.account_public_key = pub_key;
tx.new_account_public_key = pub_key;
tx.new_signing_pub_key_1 = new_pub_key;
tx.new_signing_pub_key_2 = new_pub_key;
tx.alias_hash = (uint256_t(fr::random_element()) & 0xffffffff);
tx.create = true;
tx.migrate = false;
tx.account_note_index = 0;
tx.signing_pub_key = pub_key;
tx.account_note_path = gibberish_path;
tx.sign({ priv_key, pub_key });
return tx;
}

using circuit_data = proofs::circuit_data;

inline circuit_data get_circuit_data(std::shared_ptr<waffle::ReferenceStringFactory> const& srs, bool mock = false)
{
std::cerr << "Getting account circuit data..." << std::endl;

auto build_circuit = [&](Composer& composer) {
account_tx tx;
account_tx tx(noop_tx());
tx.account_note_path.resize(DATA_TREE_DEPTH);
account_circuit(composer, tx);
};
Expand Down

0 comments on commit d8d2921

Please sign in to comment.