Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Separate public inputs from proof in acir composer #2618

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5035024
temporary: add methods to split the proof and take in public inputs s…
kevaundray Oct 2, 2023
2b438db
modify c-binds to use those methods
kevaundray Oct 2, 2023
934a578
modify browser test app to account for separate public inputs
kevaundray Oct 2, 2023
75b9dc7
modify bb binary to account for separate public inputs
kevaundray Oct 2, 2023
65acca8
modify bb.js node binary to account for separate public inputs
kevaundray Oct 2, 2023
902520a
exports.json file was regenerated
kevaundray Oct 2, 2023
8dadcfa
regenerate api file -- unfortunately my linter changed lines in the f…
kevaundray Oct 2, 2023
6376452
formatter
kevaundray Oct 2, 2023
06e2ad7
add code to not read the public inputs file if there are no public in…
kevaundray Oct 2, 2023
ab683a1
temporarily switch args
kevaundray Oct 2, 2023
adc2357
put publicInputs in serializeProofIntoFields
kevaundray Oct 2, 2023
4a026aa
modify binary to account for new cbind api
kevaundray Oct 2, 2023
f6af120
always put public inputs vector first
kevaundray Oct 2, 2023
06ea909
regenerate exports.json
kevaundray Oct 2, 2023
93218e7
conditionally read the public inputs
kevaundray Oct 2, 2023
7aa3855
typo
kevaundray Oct 2, 2023
0c6ca7f
yarn
kevaundray Oct 2, 2023
0df922c
put in separate PR
kevaundray Oct 2, 2023
0e3bfa7
cleanup bb
kevaundray Oct 2, 2023
b463a8a
cleanup bb.js binary
kevaundray Oct 2, 2023
23d2067
remove _splitted methods
kevaundray Oct 2, 2023
4461139
modify bb binary; since we removed _splitted methods
kevaundray Oct 2, 2023
c2a6773
Update barretenberg/acir_tests/run_acir_tests_browser.sh
kevaundray Oct 2, 2023
b4233da
formatting fix
kevaundray Oct 2, 2023
362552a
change outwards facing API to not mention proofWithoutPublicInputs
kevaundray Oct 3, 2023
8576164
using proof instead of proof_without_public_inputs in cbinds
kevaundray Oct 3, 2023
51714c8
redo bindings
kevaundray Oct 3, 2023
a811d36
modify binaries
kevaundray Oct 3, 2023
2d07550
linter
kevaundray Oct 3, 2023
0b49345
multi:
kevaundray Oct 3, 2023
b669013
bb: -public_inputs -> _public_inputs
kevaundray Oct 3, 2023
aeea25e
lint
kevaundray Oct 3, 2023
dab3ec3
add get_file_size method
kevaundray Oct 3, 2023
2b60a6c
use get_file_size instead of passing number of public inputs
kevaundray Oct 3, 2023
24d0bc6
do not pass vk to proofAsFields
kevaundray Oct 3, 2023
7f539fe
use methods in container to refactor
kevaundray Oct 3, 2023
c62a6cd
change c-style cast and add back comment
kevaundray Oct 3, 2023
21e67bd
tellg returns 0 for empty file, if there was an error reading it, rea…
kevaundray Oct 3, 2023
4a369ab
inline splitVector and remove concatenate vector
kevaundray Oct 3, 2023
c7b5102
reduce diff
kevaundray Oct 3, 2023
00a19ba
Merge branch 'master' into kw/separate-public-inputs
kevaundray Oct 3, 2023
fc6aefd
better variable name
kevaundray Oct 3, 2023
0cafaa8
Merge remote-tracking branch 'origin/master' into kw/separate-public-…
kevaundray Oct 12, 2023
036d1f3
fix merge
kevaundray Oct 12, 2023
fe50733
deduplicate public witness indices
kevaundray Oct 12, 2023
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
21 changes: 20 additions & 1 deletion barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,26 @@ acir_format::WitnessVector get_witness(std::string const& witness_path)
acir_format::acir_format get_constraint_system(std::string const& bytecode_path)
{
auto bytecode = get_bytecode(bytecode_path);
return acir_format::circuit_buf_to_acir_format(bytecode);
auto constraint_system = acir_format::circuit_buf_to_acir_format(bytecode);

auto remove_duplicates = [](std::vector<uint32_t>& vec) {
std::sort(vec.begin(), vec.end());
auto lastUnique = std::unique(vec.begin(), vec.end());
vec.erase(lastUnique, vec.end());
};

// The deserialized acir can have duplicate public inputs.
//
// This can happen if for example, the input to a function is a public input and
// then this input is returned as a public output.
//
// One solution for this, is to have ACIR introduce the concept of a public output
// which would be different to the public input. A public input would be the public values
// which are inputted to the program and the public output would be the public values
// which are returned when the program terminates.
Comment on lines +64 to +67
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACIR does have this concept. It calls the first public_parameters and the second return_values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should clarify that this would also be exposed as fields, so we can use it in this file

remove_duplicates(constraint_system.public_inputs);

return constraint_system;
}

std::vector<uint8_t> read_public_inputs(std::string const& public_inputs_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ bool AcirComposer::verify_proof(std::vector<uint8_t> const& public_inputs,
vinfo("done.");
}

// Hack. Shouldn't need to do this.
builder_.public_inputs.resize(public_inputs.size() / 32);
auto numPublicInputs = public_inputs.size() / 32;
builder_.public_inputs.resize(numPublicInputs);

if (is_recursive) {
auto verifier = composer.create_verifier(builder_);
Expand Down