Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion cpp/src/aztec/dsl/acir_format/ecdsa_secp256k1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,18 @@ void create_ecdsa_verify_constraints(plonk::TurboComposer& composer, const Ecdsa
stdlib::ecdsa::signature<plonk::TurboComposer> sig{ stdlib::byte_array<plonk::TurboComposer>(&composer, rr),
stdlib::byte_array<plonk::TurboComposer>(&composer, ss) };

auto pub_key = secp256k1_ct::g1_ct(pub_key_x_fq, pub_key_y_fq);
pub_key_x_fq.assert_is_in_field();
pub_key_y_fq.assert_is_in_field();

// TODO: crypto-dev to fix calculation and constraining of the signature result is correct

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since this has nothing to do with with the PR title -- I think this should be brought up as an issue on the original PR and we can resolve it there

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@kevaundray this PR is targeting my branch, so we can merge it in now and get it resolved as part of #198

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok will bring up as an issue.
Originally these comments were just this line:
auto pub_key = secp256k1_ct::g1_ct(pub_key_x_fq, pub_key_y_fq);
Which was giving unused variable errors, so I did these changes for now.

// the above line is currently a placeholder as unused variabels are not allowed in the build
// auto pub_key = secp256k1_ct::g1_ct(pub_key_x_fq, pub_key_y_fq);
// bool_ct signature_result = stdlib::ecdsa::
// verify_signature<plonk::TurboComposer, secp256k1_ct::fq_ct, secp256k1_ct::bigfr_ct,
// secp256k1_ct::g1_bigfr_ct>(
// message, pub_key, sig);

// auto result_bool = composer.add_variable(signature_result.get_value() == true);

composer.assert_equal(false, input.result);
}
Expand Down
20 changes: 6 additions & 14 deletions cpp/src/aztec/dsl/turbo_proofs/turbo_proofs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,13 @@ size_t turbo_init_proving_key(uint8_t const* constraint_system_buf, uint8_t cons
auto crs_factory = std::make_unique<ReferenceStringFactory>();
auto composer = create_circuit(constraint_system, std::move(crs_factory));
auto proving_key = composer.compute_proving_key();

// Computing the size of the serialized key is non trivial. We know it's ~331mb.
// Allocate a buffer large enough to hold it, and abort if we overflow.
// This is to keep memory usage down.
size_t total_buf_len = 350 * 1024 * 1024;
auto raw_buf = (uint8_t*)malloc(total_buf_len);
auto raw_buf_end = raw_buf;
write(raw_buf_end, *proving_key);

auto buffer = to_buffer(*proving_key);
auto raw_buf = (uint8_t*)malloc(buffer.size());
memcpy(raw_buf, (void*)buffer.data(), buffer.size());
*pk_buf = raw_buf;
auto len = static_cast<uint32_t>(raw_buf_end - raw_buf);
if (len > total_buf_len) {
info("Buffer overflow serializing proving key.");
std::abort();
}
return len;

return buffer.size();
}

size_t turbo_init_verification_key(void* pippenger, uint8_t const* g2x, uint8_t const* pk_buf, uint8_t const** vk_buf)
Expand Down