swiftness_commitment/vector/
types.rs

1use super::config::Config;
2use alloc::vec::Vec;
3use serde::{Deserialize, Serialize};
4use serde_with::serde_as;
5use starknet_crypto::Felt;
6
7// Commitment for a vector of field elements.
8#[serde_as]
9#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10pub struct Commitment {
11    pub config: Config,
12    #[cfg_attr(
13        feature = "std",
14        serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex")
15    )]
16    pub commitment_hash: Felt,
17}
18
19// A query to the vector commitment.
20#[serde_as]
21#[derive(Debug, PartialEq, Serialize, Deserialize)]
22pub struct Query {
23    #[cfg_attr(
24        feature = "std",
25        serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex")
26    )]
27    pub index: Felt,
28    #[cfg_attr(
29        feature = "std",
30        serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex")
31    )]
32    pub value: Felt,
33}
34
35// A query to the vector commitment that contains also the depth of the query in the Merkle tree.
36#[serde_as]
37#[derive(Debug, PartialEq, Serialize, Deserialize)]
38pub struct QueryWithDepth {
39    #[cfg_attr(
40        feature = "std",
41        serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex")
42    )]
43    pub index: Felt,
44    #[cfg_attr(
45        feature = "std",
46        serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex")
47    )]
48    pub value: Felt,
49    #[cfg_attr(
50        feature = "std",
51        serde_as(as = "starknet_core::serde::unsigned_field_element::UfeHex")
52    )]
53    pub depth: Felt,
54}
55
56// Witness for a decommitment over queries.
57#[serde_as]
58#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
59pub struct Witness {
60    // The authentication values: all the siblings of the subtree generated by the queried indices,
61    // bottom layer up, left to right.
62    #[cfg_attr(
63        feature = "std",
64        serde_as(as = "Vec<starknet_core::serde::unsigned_field_element::UfeHex>")
65    )]
66    pub authentications: Vec<Felt>,
67}