1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0

//! Types that capture serialized bullet proof challenges and proofs

#![allow(missing_docs)] // Don't actually know what many of the types fields are for yet

use crate::{common::*, *};
use mina_serialization_types_macros::AutoFrom;
use serde::{Deserialize, Serialize};
use versioned::*;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct BulletproofChallenge {
    pub prechallenge: BulletproofPreChallengeV1,
}

pub type BulletproofChallengeV1 = Versioned<BulletproofChallenge, 1>;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, AutoFrom)]
#[auto_from(BulletproofChallenge)]
pub struct BulletproofChallengeJson {
    pub prechallenge: BulletproofPreChallengeJson,
}

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct BulletproofChallenges(pub Vec<BulletproofChallengeTuple18V1>);

pub type BulletproofChallengesV1 = Versioned<BulletproofChallenges, 1>;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, AutoFrom)]
#[auto_from(BulletproofChallenges)]
pub struct BulletproofChallengesJson(pub Vec<BulletproofChallengeTuple18Json>);

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct ProofStateBulletproofChallenges(
    pub BulletproofChallengeTuple17V1,
    pub BulletproofChallengeTuple17V1,
    pub (),
);

pub type ProofStateBulletproofChallengesV1 = Versioned<ProofStateBulletproofChallenges, 1>;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, AutoFrom)]
#[auto_from(ProofStateBulletproofChallenges)]
pub struct ProofStateBulletproofChallengesJson(
    pub BulletproofChallengeTuple17Json,
    pub BulletproofChallengeTuple17Json,
    #[serde(skip)] pub (),
);

// TODO - see if this can be rewritten with const generics over an array
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct BulletproofChallengeTuple17(
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub (),
);

pub type BulletproofChallengeTuple17V1 =
    Versioned<Versioned<Versioned<BulletproofChallengeTuple17, 1>, 1>, 1>;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, AutoFrom)]
#[auto_from(BulletproofChallengeTuple17)]
pub struct BulletproofChallengeTuple17Json(
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    #[serde(skip)] pub (),
);

// TODO - see if this can be rewritten with const generics over an array
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct BulletproofChallengeTuple18(
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub BulletproofChallengeV1,
    pub (),
);

pub type BulletproofChallengeTuple18V1 = Versioned<Versioned<BulletproofChallengeTuple18, 1>, 1>;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, AutoFrom)]
#[auto_from(BulletproofChallengeTuple18)]
pub struct BulletproofChallengeTuple18Json(
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    pub BulletproofChallengeJson,
    #[serde(skip)] pub (),
);

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub enum BulletproofPreChallenge {
    ScalarChallenge(ScalarChallengeVector2V1),
}

pub type BulletproofPreChallengeV1 = Versioned<BulletproofPreChallenge, 1>;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
enum BulletproofPreChallengeJsonProxy {
    #[serde(rename = "Scalar_challenge")]
    ScalarChallenge(ScalarChallengeVector2Json),
}

#[derive(Clone, Debug, Eq, PartialEq, AutoFrom)]
#[auto_from(BulletproofPreChallenge)]
#[auto_from(BulletproofPreChallengeJsonProxy)]
pub enum BulletproofPreChallengeJson {
    ScalarChallenge(ScalarChallengeVector2Json),
}
impl_mina_enum_json_serde_with_option!(
    BulletproofPreChallengeJson,
    BulletproofPreChallengeJsonProxy,
    false
);

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct ScalarChallengeVector2(pub Hex64V1, pub Hex64V1, pub ());

pub type ScalarChallengeVector2V1 = Versioned<ScalarChallengeVector2, 1>;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, AutoFrom)]
#[auto_from(ScalarChallengeVector2)]
pub struct ScalarChallengeVector2Json(pub I64, pub I64, #[serde(skip)] pub ());