ChainSafe / ChainSafe/ProtoBanshee

Attestations circuit: constraint attestation data variables

Open
#64 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

To allow exporting or adding equality constraints for fields of the `AttestationData`:
```rust
pub struct AttestationData {
pub slot: u64, // not used currently, might be used to check that attestations are for unique slots
pub index: usize, // == id of the committee in validators table
pub beacon_block_root: [u8; 32], // not used currently
pub source: Checkpoint, // not used currently, might be used to connect previous proof recursively
pub target: Checkpoint,
// target.epoch == target_epoch in ValidatorsCircuit
// target.root == state_root in StateCircuit
}
```

### Note:
- By specifying the `is_rlc` boolean in [`HashInputChunk`](https://github.com/ChainSafe/banshee-zk/blob/cc0991fd640d8402902de760508b7b4b185484af/zkcasper-circuits/src/witness/hashing.rs#L131) you can make Sha256Circuit to either calculate RLC encoding for input bytes or value (both on per chunk basis)
- The `implementations` of `From` determine `is_rlc` value automatically such `is_rlc: bytes >= 32`
- Based on `is_rlc` `SHA256Table.input_chunks` would either be [RLC or value](https://github.com/ChainSafe/banshee-zk/blob/cc0991fd640d8402902de760508b7b4b185484af/zkcasper-circuits/src/sha256_circuit.rs#L973) and Sha256Circuit would select [corresponding](https://github.com/ChainSafe/banshee-zk/blob/cc0991fd640d8402902de760508b7b4b185484af/zkcasper-circuits/src/sha256_circuit.rs#L579-L587) gates
- The final value/RLC of `input_chunks` can be found in the row with `is_enabled == 1`

### Scope
- Include `input_chunks` into [`AssignedHashResult`](https://github.com/ChainSafe/banshee-zk/blob/cc0991fd640d8402902de760508b7b4b185484af/zkcasper-circuits/src/gadget/crypto/sha256.rs#L41) by importing it's final value in halo2lib `AssignedValue` form in [`Sha256Chip`](https://github.com/ChainSafe/banshee-zk/blob/cc0991fd640d8402902de760508b7b4b185484af/zkcasper-circuits/src/gadget/crypto/sha256.rs#L48)
- See example of such importing [here](https://github.com/ChainSafe/banshee-zk/blob/cc0991fd640d8402902de760508b7b4b185484af/zkcasper-circuits/src/sha256_circuit.rs#L991-L992) and [here](https://github.com/ChainSafe/banshee-zk/blob/cc0991fd640d8402902de760508b7b4b185484af/zkcasper-circuits/src/gadget/crypto/sha256.rs#L145-L146) - this example demonstrates import of `Sha256Table.input_rlc`
- After value/rlc is present in `AssignedHashResult` you can use these values to perform equality checks
- To be able to do permutation checks in halo2lib (using `region.constraint_equal`) you would likely need to include `AssignedCell` along with `AssignedValue`.
- For the purpose of this task, only add constraints on inputs that are used in other circuits (see comment).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.