Skip to content

Commit

Permalink
Add methods to cell to retrieve byte representations (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobkaufmann authored Jan 31, 2024
1 parent ae99048 commit 9a1cb0a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bindings/rust/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,20 @@ impl Cell {
Self::from_bytes(&hex_to_bytes(hex_str)?)
}

pub fn to_bytes(&self) -> [u8; BYTES_PER_CELL] {
let mut bytes = [0u8; BYTES_PER_CELL];
for (i, chunk) in self.data.iter().enumerate() {
let start = i * BYTES_PER_FIELD_ELEMENT;
let end = start + BYTES_PER_FIELD_ELEMENT;
bytes[start..end].copy_from_slice(&chunk.bytes[..]);
}
bytes
}

pub fn into_inner(self) -> [Bytes32; FIELD_ELEMENTS_PER_CELL] {
self.data
}

pub fn compute_cells_and_proofs(
blob: &Blob,
kzg_settings: &KZGSettings,
Expand Down

0 comments on commit 9a1cb0a

Please sign in to comment.