Skip to content

Commit a3b806b

Browse files
authored
Honk verification error messages and cleanup (#391)
1 parent ee2ffca commit a3b806b

File tree

3 files changed

+9
-38
lines changed

3 files changed

+9
-38
lines changed

tools/garaga_rs/src/calldata/full_proof_with_hints/honk.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub struct HonkProof {
226226
impl HonkProof {
227227
pub fn from_bytes(proof_bytes: &[u8], public_inputs_bytes: &[u8]) -> Result<Self, String> {
228228
if proof_bytes.len() != 32 * PROOF_SIZE {
229-
return Err(format!("Invalid input length: {}", proof_bytes.len()));
229+
return Err(format!("Invalid proof bytes length: {}", proof_bytes.len()));
230230
}
231231

232232
let mut values = vec![];
@@ -237,7 +237,7 @@ impl HonkProof {
237237

238238
if public_inputs_bytes.len() % 32 != 0 {
239239
return Err(format!(
240-
"Invalid input length: {}",
240+
"Invalid public input bytes length: {}",
241241
public_inputs_bytes.len()
242242
));
243243
}
@@ -254,22 +254,10 @@ impl HonkProof {
254254
}
255255
pub fn from(values: Vec<BigUint>, public_inputs: Vec<BigUint>) -> Result<Self, String> {
256256
if values.len() != PROOF_SIZE {
257-
return Err(format!("Invalid input length: {}", values.len()));
257+
return Err(format!("Invalid proof length: {}", values.len()));
258258
}
259259

260260
let mut offset = 0;
261-
262-
let count = PAIRING_POINT_OBJECT_LENGTH
263-
+ 8 * 4
264-
+ BATCHED_RELATION_PARTIAL_LENGTH * CONST_PROOF_SIZE_LOG_N
265-
+ NUMBER_OF_ENTITIES
266-
+ (CONST_PROOF_SIZE_LOG_N - 1) * 4
267-
+ CONST_PROOF_SIZE_LOG_N
268-
+ 2 * 4;
269-
if values.len() != count {
270-
return Err(format!("Invalid input length: {}", values.len()));
271-
}
272-
273261
let mut pairing_point_object = vec![];
274262
for i in (offset..).step_by(1).take(PAIRING_POINT_OBJECT_LENGTH) {
275263
pairing_point_object.push(values[i].clone());
@@ -341,7 +329,7 @@ impl HonkProof {
341329
let [shplonk_q, kzg_quotient] = points.try_into().unwrap();
342330
offset += 4 * 2;
343331

344-
assert_eq!(offset, count);
332+
assert_eq!(offset, PROOF_SIZE);
345333

346334
let proof = Self {
347335
public_inputs,

tools/garaga_rs/src/calldata/full_proof_with_hints/zk_honk.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub struct ZKHonkProof {
5454
impl ZKHonkProof {
5555
pub fn from_bytes(proof_bytes: &[u8], public_inputs_bytes: &[u8]) -> Result<Self, String> {
5656
if proof_bytes.len() != 32 * ZK_PROOF_SIZE {
57-
return Err(format!("Invalid input length: {}", proof_bytes.len()));
57+
return Err(format!("Invalid proof bytes length: {}", proof_bytes.len()));
5858
}
5959

6060
let mut values = vec![];
@@ -65,7 +65,7 @@ impl ZKHonkProof {
6565

6666
if public_inputs_bytes.len() % 32 != 0 {
6767
return Err(format!(
68-
"Invalid input length: {}",
68+
"Invalid public input bytes length: {}",
6969
public_inputs_bytes.len()
7070
));
7171
}
@@ -82,27 +82,10 @@ impl ZKHonkProof {
8282
}
8383
pub fn from(values: Vec<BigUint>, public_inputs: Vec<BigUint>) -> Result<Self, String> {
8484
if values.len() != ZK_PROOF_SIZE {
85-
return Err(format!("Invalid input length: {}", values.len()));
85+
return Err(format!("Invalid proof length: {}", values.len()));
8686
}
8787

8888
let mut offset = 0;
89-
90-
let count = PAIRING_POINT_OBJECT_LENGTH
91-
+ 11 * 4
92-
+ 1
93-
+ ZK_BATCHED_RELATION_PARTIAL_LENGTH * CONST_PROOF_SIZE_LOG_N
94-
+ NUMBER_OF_ENTITIES
95-
+ 1
96-
+ 4
97-
+ 1
98-
+ (CONST_PROOF_SIZE_LOG_N - 1) * 4
99-
+ CONST_PROOF_SIZE_LOG_N
100-
+ 4
101-
+ 2 * 4;
102-
if values.len() != count {
103-
return Err(format!("Invalid input length: {}", values.len()));
104-
}
105-
10689
let mut pairing_point_object = vec![];
10790
for i in (offset..).step_by(1).take(PAIRING_POINT_OBJECT_LENGTH) {
10891
pairing_point_object.push(values[i].clone());
@@ -198,7 +181,7 @@ impl ZKHonkProof {
198181
let [shplonk_q, kzg_quotient] = points.try_into().unwrap();
199182
offset += 4 * 2;
200183

201-
assert_eq!(offset, count);
184+
assert_eq!(offset, ZK_PROOF_SIZE);
202185

203186
let proof = Self {
204187
public_inputs,

tools/npm/garaga_ts/src/wasm/pkg/garaga_rs_bg.wasm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)