-
Notifications
You must be signed in to change notification settings - Fork 54
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
Support SHA256 precompile #213
Comments
Algorithm:We implemented the Block decomposition and Hash computation phases, which we refer to as ShaExtend and ShaCompress, respectively. There are 4 tables. 1. ShaExtendThis table has 48 rows per block. Columns:
Number of columns: Constraints:
To perform and verify For example, given
The constraints for this addition are: let mut pre_carry = P::ZEROS;
for i in 0..N {
let sum = x[i] + y[i] + pre_carry;
// If sum is 1 or 3, the result must be 1.
// If sum is 0 or 2, the result must be 0.
let out_constraint = (sum - P::ONES) * (sum - P::ONES - P::ONES - P::ONES) * out[i] + sum * (sum - P::ONES - P::ONES) * (out[i] - P::ONES);
// Ensuring 2 * carry[i] + result[i] == sum
let carry_constraint = carry[i] + carry[i] + result[i] - sum;
pre_carry = carry[i];
} See SP1's implementation of Degree: 3 2. ShaExtendSpongeHandles the input/output of ShaExtend. This table has 48 rows per block. Columns:
Number of columns: 216 Constraints:
3. ShaCompressThis table has 64 rows per block. Columns:
Number of columns: 1442 Constraints:
4. ShaCompressSpongeThis table has 64 rows per block.
Number of columns: 1420 Constraints:
Degree: 3 PerformanceCompare the performance of Command: Number of Committed Cells (Before Padding):
Proving Time
Sha2-rust: Sha2-syscall: |
Note that the max constraint degree is 3. |
For the benchmark, plz stat how large the cells reduced by precompile sha2. Meanwhile, you also test hash computation with different input size, like 32, 256, 1024, and 65536. |
Hash computation with different input sizes
|
SHA256 starky reference: https://github.com/succinctlabs/starkyx/blob/1644af58bfc7d305c0066597c303a129fec7f427/starkyx/src/machine/hash/sha/sha256/register.rs
The text was updated successfully, but these errors were encountered: