Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 46ac51e

Browse files
committed
addressed comments in zkbridge and added logical AND to hashes
1 parent 1765011 commit 46ac51e

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

zkllvm/use-cases/zk-bridge/hashes.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ The circuit consists of the following components:
226226
unconfirmed_blocks[i - 1].prev_block_hash,
227227
unconfirmed_blocks[i - 1].data,
228228
);
229-
res = res & is_same(unconfirmed_blocks[i].prev_block_hash, evaluated_block_hash);
229+
res = res && is_same(unconfirmed_blocks[i].prev_block_hash, evaluated_block_hash);
230230
}
231231
res
232232
}

zkllvm/use-cases/zk-bridge/zkbridge.mdx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ Read the following tutorials before proceeding further.
9191

9292
:::info[Rust directives]
9393

94-
The `#[derive(Copy, Clone)]` makes it so that circuit code does not unintentionally take ownership of variables that are supposed to be changed/used later.
94+
The `#[derive(Copy, Clone)]` makes it so functions do not take ownership of the variables belonging to custom structs if these variables are passed by value.
9595

9696
To learn more about the `#[derive(C)]` directive, [**click here**](../../best-practices-limitations/rust-derive).
9797

9898
:::
9999

100+
100101
### Additional functions
101102

102103
<Tabs groupId='language'>
@@ -214,13 +215,31 @@ To learn more about the `#[derive(C)]` directive, [**click here**](../../best-pr
214215
</TabItem>
215216
<TabItem value='rust' label='Rust'>
216217
```rust
217-
#![no_main]
218+
#[circuit]
219+
#[unroll_for_loops]
220+
pub fn verify_protocol_state_proof(
221+
last_confirmed_block_hash: BlockType,
222+
unconfirmed_blocks: [BlockDataType; 2],
223+
) -> bool {
224+
let mut is_correct = is_same(
225+
unconfirmed_blocks[0].prev_block_hash,
226+
last_confirmed_block_hash,
227+
);
228+
is_correct = is_correct && verify_signature(unconfirmed_blocks[0]);
218229

219-
use std::intrinsics::assigner_sha2_256;
230+
for i in 1..2 {
231+
let evaluated_block_hash: BlockType = hash_256(
232+
unconfirmed_blocks[i - 1].prev_block_hash,
233+
unconfirmed_blocks[i - 1].data,
234+
);
220235

221-
use ark_ff::AdditiveGroup;
222-
use ark_pallas::Fq;
223-
use unroll::unroll_for_loops;
236+
is_correct =
237+
is_correct && is_same(unconfirmed_blocks[i].prev_block_hash, evaluated_block_hash);
238+
is_correct = is_correct && verify_signature(unconfirmed_blocks[i]);
239+
}
240+
241+
is_correct
242+
}
224243
```
225244
</TabItem>
226245
</Tabs>
@@ -408,6 +427,7 @@ To learn more about the `#[derive(C)]` directive, [**click here**](../../best-pr
408427
</TabItem>
409428
</Tabs>
410429

430+
411431
## Public input
412432

413433
The public input for the circuit could look as follows:

0 commit comments

Comments
 (0)