This repository was archived by the owner on Apr 18, 2025. It is now read-only.
forked from privacy-scaling-explorations/zkevm-circuits
-
Notifications
You must be signed in to change notification settings - Fork 392
Copy: fix conditions #616
Merged
Merged
Copy: fix conditions #616
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
69fbc92
memory_opt_counters: replace incorrect non_pad_non_mask with is_continue
a6e299e
memory_opt_counters: constraints on front_mask
de86658
Merge branch 'memory_opt' into memory_opt_continue
DreamWuGit 2d1cfe2
memory_opt_continue: remove redundant conditation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1536,13 +1536,14 @@ impl CopyTable { | |
let mut rlc_acc_read = Value::known(F::zero()); | ||
let mut rlc_acc_write = Value::known(F::zero()); | ||
|
||
let full_length = copy_event.copy_bytes.bytes.len(); | ||
|
||
let mut real_length_left = copy_event | ||
.copy_bytes | ||
.bytes | ||
.iter() | ||
.filter(|&step| !step.2) | ||
.count(); | ||
let mut word_index; | ||
|
||
let read_steps = copy_event.copy_bytes.bytes.iter(); | ||
let copy_steps = if let Some(ref write_steps) = copy_event.copy_bytes.aux_bytes { | ||
|
@@ -1598,7 +1599,7 @@ impl CopyTable { | |
// is_first | ||
let is_first = Value::known(if step_idx == 0 { F::one() } else { F::zero() }); | ||
// is last | ||
let is_last = if step_idx == copy_event.copy_bytes.bytes.len() * 2 - 1 { | ||
let is_last = if step_idx == full_length * 2 - 1 { | ||
Value::known(F::one()) | ||
} else { | ||
Value::known(F::zero()) | ||
|
@@ -1653,12 +1654,11 @@ impl CopyTable { | |
}; | ||
|
||
// bytes_left (final padding word length ) | ||
let bytes_left = | ||
u64::try_from(copy_event.copy_bytes.bytes.len() * 2 - step_idx).unwrap() / 2; | ||
let bytes_left = u64::try_from(full_length * 2 - step_idx).unwrap() / 2; | ||
// value | ||
let value = Value::known(F::from(copy_step.value as u64)); | ||
|
||
word_index = (step_idx as u64 / 2) % 32; | ||
let word_index = (step_idx as u64 / 2) % 32; | ||
|
||
// value_acc | ||
if is_read_step && !copy_step.mask { | ||
|
@@ -1681,16 +1681,19 @@ impl CopyTable { | |
F::from(addr) | ||
}; | ||
|
||
let addr_end = if is_read_step { | ||
copy_event.src_addr_end | ||
} else { | ||
copy_event.dst_addr + full_length as u64 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won’t be verified but here only for regularity. |
||
}; | ||
|
||
assignments.push(( | ||
tag, | ||
[ | ||
(is_first, "is_first"), | ||
(id, "id"), | ||
(Value::known(addr), "addr"), | ||
( | ||
Value::known(F::from(copy_event.src_addr_end)), | ||
"src_addr_end", | ||
), | ||
(Value::known(F::from(addr_end)), "src_addr_end"), | ||
(Value::known(F::from(bytes_left)), "bytes_left"), | ||
( | ||
Value::known(F::from(real_length_left as u64)), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does
API limitations
mean ?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Halo2 library has the concept of blinding rows, and it checks that no constraints are enabled on blinding rows. However, that is incorrect in our case and that is a soundness bug. To fix separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for blinding rows , q_enable will be false such that constraint not checking on those rows. why think it is a problem ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because then nothing is checked and the blinding rows could contain an incorrect event or a part of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blinding rows filled with random data, essentially no need to constrain it. it is not specific with copy circuit. all other circuit can have blinding rows with any data.