Skip to content

Commit

Permalink
fix: rework pub inputs thing
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Nov 4, 2023
1 parent df8f77d commit 6b94996
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 19 deletions.
6 changes: 0 additions & 6 deletions barretenberg/acir_tests/flows/sol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ set -eu
export PROOF="$(pwd)/proof"
export PROOF_AS_FIELDS="$(pwd)/proof_fields.json"

# Get the number of public inputs in the circuit
gates=$($BIN gates -v 2>&1 | tr -d '\0')
NUM_PUBLIC_INPUTS=$(echo "$gates" | awk '/public inputs: [0-9]+/ {print $3}')
echo "Number of public inputs: $NUM_PUBLIC_INPUTS"

# Create a proof, write the solidity contract, write the proof as fields in order to extract the public inputs
$BIN prove -o proof
$BIN write_vk -o vk
Expand All @@ -20,7 +15,6 @@ export KEY_PATH="$(pwd)/Key.sol"
export VERIFIER_PATH=$(realpath "../../sol-test/Verifier.sol")
export TEST_PATH=$(realpath "../../sol-test/Test.sol")
export BASE_PATH=$(realpath "../../../sol/src/ultra/BaseUltraVerifier.sol")
export NUM_PUBLIC_INPUTS=$NUM_PUBLIC_INPUTS

# Use solcjs to compile the generated key contract with the template verifier and test contract
# index.js will start an anvil, on a random port
Expand Down
10 changes: 5 additions & 5 deletions barretenberg/acir_tests/sol-test/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ const deploy = async (signer) => {
*
* @param {number} numPublicInputs
* @param {Array<String>} proofAsFields
* @returns {Array<String>}
* @returns {Array<Tuple<Array<String>,number>}
*/
const readPublicInputs = (numPublicInputs, proofAsFields) => {
const readPublicInputs = (proofAsFields) => {
const publicInputs = [];
const numPublicInputs = proofAsFields.length - 93;
for (let i = 0; i < numPublicInputs; i++) {
publicInputs.push(proofAsFields[i]);
}
return publicInputs;
return [numPublicInputs, publicInputs];
}

// start anvil
Expand All @@ -142,8 +143,7 @@ const killAnvil = () => {
try {
const proofAsFieldsPath = getEnvVar("PROOF_AS_FIELDS");
const proofAsFields = readFileSync(proofAsFieldsPath);
const numPublicInputs = +getEnvVar("NUM_PUBLIC_INPUTS");
const publicInputs = readPublicInputs(numPublicInputs, JSON.parse(proofAsFields.toString()));
const [numPublicInputs, publicInputs] = readPublicInputs(JSON.parse(proofAsFields.toString()));

const proofPath = getEnvVar("PROOF");
const proof = readFileSync(proofPath);
Expand Down
1 change: 0 additions & 1 deletion barretenberg/build-system
Submodule build-system deleted from a109f3
2 changes: 0 additions & 2 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,9 @@ void gateCount(const std::string& bytecodePath)
{
auto constraint_system = get_constraint_system(bytecodePath);
auto acir_composer = init(constraint_system);
auto num_public_inputs = acir_composer.get_num_public_inputs();
auto gate_count = acir_composer.get_total_circuit_size();

writeUint64AsRawBytesToStdout(static_cast<uint64_t>(gate_count));
vinfo("public inputs: ", num_public_inputs);
vinfo("gate count: ", gate_count);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ void AcirComposer::create_circuit(acir_format::acir_format& constraint_system)
vinfo("building circuit...");
builder_ = acir_format::create_circuit(constraint_system, size_hint_);
exact_circuit_size_ = builder_.get_num_gates();
num_public_inputs_ = builder_.get_num_public_inputs();
total_circuit_size_ = builder_.get_total_circuit_size();
circuit_subgroup_size_ = builder_.get_circuit_subgroup_size(total_circuit_size_);
size_hint_ = circuit_subgroup_size_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class AcirComposer {
bool verify_proof(std::vector<uint8_t> const& proof, bool is_recursive);

std::string get_solidity_verifier();
size_t get_num_public_inputs() { return num_public_inputs_; };
size_t get_exact_circuit_size() { return exact_circuit_size_; };
size_t get_total_circuit_size() { return total_circuit_size_; };
size_t get_circuit_subgroup_size() { return circuit_subgroup_size_; };
Expand All @@ -41,7 +40,6 @@ class AcirComposer {
acir_format::Builder builder_;
size_t size_hint_;
size_t exact_circuit_size_;
size_t num_public_inputs_;
size_t total_circuit_size_;
size_t circuit_subgroup_size_;
std::shared_ptr<proof_system::plonk::proving_key> proving_key_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,6 @@ template <typename FF> class UltraCircuitBuilder_ : public CircuitBuilderBase<ar
return std::max(minimum_circuit_size, num_filled_gates) + NUM_RESERVED_GATES;
}

[[nodiscard]] size_t get_num_public_inputs() const { return this->public_inputs.size(); }

/**x
* @brief Print the number and composition of gates in the circuit
*
Expand Down

0 comments on commit 6b94996

Please sign in to comment.