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;
68 inputs.insert(
inputs.end(), bytecode_as_fields.begin(), bytecode_as_fields.end());
79 std::vector<FF> public_keys_hash_fields = public_keys.
to_fields();
82 for (
size_t i = 0; i < public_keys_hash_fields.size(); i += 2) {
83 public_key_hash_vec.push_back(public_keys_hash_fields[i]);
84 public_key_hash_vec.push_back(public_keys_hash_fields[i + 1]);
86 public_key_hash_vec.push_back(
FF::zero());
96 contract_instance.
salt,
107 "Incoming viewing key is not on the curve when computing contract address");
116 calldata_with_sep.push_back(
value);
#define BB_ASSERT(expression,...)
std::shared_ptr< Napi::ThreadSafeFunction > bytecode
#define DOM_SEP__SALTED_INITIALIZATION_HASH
#define DOM_SEP__PARTIAL_ADDRESS
#define DOM_SEP__PUBLIC_BYTECODE
#define DOM_SEP__PUBLIC_CALLDATA
#define DOM_SEP__PUBLIC_KEYS_HASH
#define DOM_SEP__CONTRACT_ADDRESS_V1
#define DOM_SEP__CONTRACT_CLASS_ID
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
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
std::vector< FF > to_fields() const
static constexpr field zero()