3#include "barretenberg/aztec/aztec_constants.hpp"
23 size_t bytecode_len =
bytecode.size();
25 auto bytecode_field_at = [&](
size_t i) ->
FF {
28 if (bytecode_len - i >= 32) {
29 as_int = from_buffer<uint256_t>(
bytecode, i);
31 std::vector<uint8_t> tail(
bytecode.begin() +
static_cast<ssize_t
>(i),
bytecode.end());
33 as_int = from_buffer<uint256_t>(tail, 0);
37 return FF(as_int >> 8);
40 std::vector<FF> contract_bytecode_fields;
41 auto number_of_fields = (bytecode_len + 30) / 31;
42 contract_bytecode_fields.reserve(number_of_fields);
44 for (uint32_t i = 0; i < bytecode_len; i += 31) {
45 FF bytecode_field = bytecode_field_at(i);
46 contract_bytecode_fields.push_back(bytecode_field);
49 return contract_bytecode_fields;
60 static_assert(DOM_SEP__PUBLIC_BYTECODE <= UINT32_MAX,
"Public bytecode domain separator must fit in 32 bits");
68 inputs.insert(
inputs.end(), bytecode_as_fields.begin(), bytecode_as_fields.end());
74 return poseidon2::hash({ DOM_SEP__CONTRACT_CLASS_ID, artifact_hash, private_fn_root, public_bytecode_commitment });
85 incoming_viewing_key_hash,
96 FF salted_initialization_hash =
poseidon2::hash({ DOM_SEP__SALTED_INITIALIZATION_HASH,
97 contract_instance.
salt,
105 FF h =
poseidon2::hash({ DOM_SEP__CONTRACT_ADDRESS_V2, public_keys_hash, partial_address });
109 "Incoming viewing key is not on the curve when computing contract address");
115 std::vector<FF> calldata_with_sep = { DOM_SEP__PUBLIC_CALLDATA };
118 calldata_with_sep.push_back(
value);
#define BB_ASSERT(expression,...)
static FF hash(const std::vector< FF > &input)
Hashes a vector of field elements.
constexpr bool on_curve() const noexcept
static constexpr affine_element affine_one
std::vector< uint8_t > bytecode
AVM range check gadget for witness generation.
FF compute_public_bytecode_commitment(std::span< const uint8_t > bytecode)
FF hash_public_keys(const PublicKeys &public_keys)
std::vector< FF > encode_bytecode(std::span< const uint8_t > bytecode)
Encodes the bytecode into a vector of field elements. Each field element represents 31 bytes of the b...
FF compute_contract_class_id(const FF &artifact_hash, const FF &private_fn_root, const FF &public_bytecode_commitment)
FF compute_public_bytecode_first_field(size_t bytecode_size)
FF compute_calldata_hash(std::span< const FF > calldata)
FF compute_contract_address(const ContractInstance &contract_instance)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
ContractClassId original_contract_class_id
AffinePoint incoming_viewing_key
FF message_signing_key_hash
FF outgoing_viewing_key_hash