Skip to content

feat: Blake3 utility circuit #24

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 10 additions & 10 deletions src/chips/blake3_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,13 +1209,13 @@ mod tests {
match claim[0].as_canonical_u64() {
0u64 => {
// This is our U8Xor claim. We should have chip_idx, A, B, A xor B (where A, B are bytes)
assert!(claim.len() == 4, "[U8Xor] wrong claim format");
assert_eq!(claim.len(), 4, "[U8Xor] wrong claim format");
byte_xor_values_from_claims.push((claim[1], claim[2], claim[3]));
}
1u64 => {
/* This is our U32Xor claim. We should have chip_idx, A, B, A xor B (where A, B are u32) */

assert!(claim.len() == 4, "[U32Xor] wrong claim format");
assert_eq!(claim.len(), 4, "[U32Xor] wrong claim format");
let a_u32 = u32::try_from(claim[1].as_canonical_u64()).unwrap();
let b_u32 = u32::try_from(claim[2].as_canonical_u64()).unwrap();
let xor_u32 = u32::try_from(claim[3].as_canonical_u64()).unwrap();
Expand All @@ -1226,7 +1226,7 @@ mod tests {
2u64 => {
/* This is our U32Add claim. We should have chip_idx, A, B, A + B (where A, B are u32) */

assert!(claim.len() == 4, "[U32Add] wrong claim format");
assert_eq!(claim.len(), 4, "[U32Add] wrong claim format");
let a_u32 = u32::try_from(claim[1].as_canonical_u64()).unwrap();
let b_u32 = u32::try_from(claim[2].as_canonical_u64()).unwrap();
let add_u32 = u32::try_from(claim[3].as_canonical_u64()).unwrap();
Expand All @@ -1236,7 +1236,7 @@ mod tests {
3u64 => {
/* This is our U32RotateRight8 claim. We should have chip_idx, A, A_rot */

assert!(claim.len() == 3, "[U32RightRotate8] wrong claim format");
assert_eq!(claim.len(), 3, "[U32RightRotate8] wrong claim format");
let a_u32 = u32::try_from(claim[1].as_canonical_u64()).unwrap();
let rot_u32 = u32::try_from(claim[2].as_canonical_u64()).unwrap();

Expand All @@ -1245,7 +1245,7 @@ mod tests {
4u64 => {
/* This is our U32RotateRight16 claim. We should have chip_idx, A, A_rot */

assert!(claim.len() == 3, "[U32RightRotate16] wrong claim format");
assert_eq!(claim.len(), 3, "[U32RightRotate16] wrong claim format");
let a_u32 = u32::try_from(claim[1].as_canonical_u64()).unwrap();
let rot_u32 = u32::try_from(claim[2].as_canonical_u64()).unwrap();

Expand All @@ -1254,7 +1254,7 @@ mod tests {
5u64 => {
/* This is our U32RotateRight12 claim. We should have chip_idx, A, A_rot */

assert!(claim.len() == 3, "[U32RightRotate12] wrong claim format");
assert_eq!(claim.len(), 3, "[U32RightRotate12] wrong claim format");
let a_u32 = u32::try_from(claim[1].as_canonical_u64()).unwrap();
let rot_u32 = u32::try_from(claim[2].as_canonical_u64()).unwrap();

Expand All @@ -1263,7 +1263,7 @@ mod tests {
6u64 => {
/* This is our U32RotateRight7 claim. We should have chip_idx, A, A_rot */

assert!(claim.len() == 3, "[U32RightRotate7] wrong claim format");
assert_eq!(claim.len(), 3, "[U32RightRotate7] wrong claim format");
let a_u32 = u32::try_from(claim[1].as_canonical_u64()).unwrap();
let rot_u32 = u32::try_from(claim[2].as_canonical_u64()).unwrap();

Expand All @@ -1273,13 +1273,13 @@ mod tests {
7u64 => {
/* This is our U8PairRangeCheck claim. We should have chip_idx, A, B */

assert!(claim.len() == 3, "[U8Xor] wrong claim format");
assert_eq!(claim.len(), 3, "[U8PairRangeCheck] wrong claim format");
byte_range_check_values_from_claims.push((claim[1], claim[2]));
}

8u64 => {
/* This is our GFunction claim. We should have chip_idx, A, B, C, D, MX_IN, MY_IN, A1, D1, C1, B1 */
assert!(claim.len() == 11, "[GFunction] wrong claim format");
assert_eq!(claim.len(), 11, "[GFunction] wrong claim format");

let a_in = u32::try_from(claim[1].as_canonical_u64()).unwrap();
let b_in = u32::try_from(claim[2].as_canonical_u64()).unwrap();
Expand All @@ -1298,7 +1298,7 @@ mod tests {

9u64 => {
/* This is our StateTransition claim. We should have chip_idx, state_in[32], state_out[16] */
assert!(claim.len() == 49, "[StateTransition] wrong claim format");
assert_eq!(claim.len(), 49, "[StateTransition] wrong claim format");

let state_in: [u32; 32] = array::from_fn(|i| {
u32::try_from(claim[i + 1].as_canonical_u64()).unwrap()
Expand Down
1 change: 1 addition & 0 deletions src/chips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mod blake3_circuit;
mod byte_operations;
mod u32_add;
mod utility;

use crate::builder::symbolic::SymbolicExpression;
use crate::types::Val;
Expand Down
Loading