Skip to content

Commit

Permalink
fix(halo2_proofs): fix wrong use of kSha256StateLength
Browse files Browse the repository at this point in the history
  • Loading branch information
dongchangYoo committed Mar 25, 2024
1 parent 4f71fab commit 2856259
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions halo2_proofs/src/bn254_sha256_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ void Sha256Writer::update(rust::Slice<const uint8_t> data) {
data.size());
}

void Sha256Writer::finalize(std::array<uint8_t, kSha256DigestLength>& result) {
void Sha256Writer::finalize(std::array<uint8_t, kSha256DigestLength> &result) {
uint8_t data[kSha256DigestLength];
size_t data_size;
tachyon_halo2_bn254_transcript_writer_finalize(writer_, data, &data_size);
memcpy(result.data(), data, data_size);
}

rust::Vec<uint8_t> Sha256Writer::state() const {
constexpr size_t kStateSize = sizeof(kSha256StateLength);
rust::Vec<uint8_t> ret;
// NOTE(chokobole): |rust::Vec<uint8_t>| doesn't have |resize()|.
ret.reserve(kStateSize);
for (size_t i = 0; i < kStateSize; ++i) {
ret.reserve(kSha256StateLength);
for (size_t i = 0; i < kSha256StateLength; ++i) {
ret.push_back(0);
}
size_t state_size;
Expand All @@ -42,4 +41,4 @@ std::unique_ptr<Sha256Writer> new_sha256_writer() {
return std::make_unique<Sha256Writer>();
}

} // namespace tachyon::halo2_api::bn254
} // namespace tachyon::halo2_api::bn254

0 comments on commit 2856259

Please sign in to comment.