@@ -40,7 +40,9 @@ fn blob_fr_to_byte(blob: &[CtFr]) -> Result<[u8; BYTES_PER_BLOB], String> {
40
40
// unsafe { Ok(std::mem::transmute(blob.as_ptr() as *const [u8; BYTES_PER_BLOB])) }
41
41
}
42
42
43
- pub fn load_trusted_setup_filename_mixed ( filepath : & str ) -> Result < MixedKzgSettings , String > {
43
+ pub fn load_trusted_setup_filename_mixed (
44
+ filepath : & str ,
45
+ ) -> Result < MixedKzgSettings < ' static > , String > {
44
46
MixedKzgSettings :: new_from_path ( Path :: new ( filepath) )
45
47
}
46
48
@@ -52,19 +54,10 @@ pub fn blob_to_kzg_commitment_mixed(
52
54
MixedKzgSettings :: Constantine ( ctt_context) => {
53
55
let blob_bytes = blob_fr_to_byte ( blob) ?;
54
56
55
- #[ cfg( feature = "parallel" ) ]
56
- let res = ctt_context
57
- . ctx
58
- . blob_to_kzg_commitment_parallel ( & ctt_context. pool , & blob_bytes) ;
59
-
60
- #[ cfg( not( feature = "parallel" ) ) ]
61
- let res = ctt_context. ctx . blob_to_kzg_commitment ( & blob_bytes) ;
62
-
63
- match res {
64
- Ok ( commitment) => CtG1 :: from_bytes ( & commitment) ,
65
- Err ( x) => Err ( x. to_string ( ) ) ,
66
- }
67
- // return blob_to_kzg_commitment_rust(blob, ctt_context);
57
+ ctt_context
58
+ . blob_to_kzg_commitment ( & blob_bytes)
59
+ . map_err ( |e| e. to_string ( ) )
60
+ . and_then ( |b| CtG1 :: from_bytes ( & b) )
68
61
}
69
62
MixedKzgSettings :: Generic ( generic_context) => {
70
63
blob_to_kzg_commitment_rust ( blob, generic_context)
@@ -81,22 +74,10 @@ pub fn compute_kzg_proof_mixed(
81
74
MixedKzgSettings :: Constantine ( ctt_context) => {
82
75
let blob_bytes = blob_fr_to_byte ( blob) ?;
83
76
84
- #[ cfg( feature = "parallel" ) ]
85
- let res = ctt_context. ctx . compute_kzg_proof_parallel (
86
- & ctt_context. pool ,
87
- & blob_bytes,
88
- & z. to_bytes ( ) ,
89
- ) ;
90
-
91
- #[ cfg( not( feature = "parallel" ) ) ]
92
- let res = ctt_context
93
- . ctx
94
- . compute_kzg_proof ( & blob_bytes, & z. to_bytes ( ) ) ;
95
-
96
- match res {
97
- Ok ( ( proof, y) ) => Ok ( ( CtG1 :: from_bytes ( & proof) ?, CtFr :: from_bytes ( & y) ?) ) ,
98
- Err ( x) => Err ( x. to_string ( ) ) ,
99
- }
77
+ ctt_context
78
+ . compute_kzg_proof ( & blob_bytes, & z. to_bytes ( ) )
79
+ . map_err ( |e| e. to_string ( ) )
80
+ . and_then ( |( proof, y) | Ok ( ( CtG1 :: from_bytes ( & proof) ?, CtFr :: from_bytes ( & y) ?) ) )
100
81
}
101
82
MixedKzgSettings :: Generic ( generic_context) => {
102
83
compute_kzg_proof_rust ( blob, z, generic_context)
@@ -113,22 +94,10 @@ pub fn compute_blob_kzg_proof_mixed(
113
94
MixedKzgSettings :: Constantine ( ctt_context) => {
114
95
let blob_bytes = blob_fr_to_byte ( blob) ?;
115
96
116
- #[ cfg( feature = "parallel" ) ]
117
- let res = ctt_context. ctx . compute_blob_kzg_proof_parallel (
118
- & ctt_context. pool ,
119
- & blob_bytes,
120
- & commitment. to_bytes ( ) ,
121
- ) ;
122
-
123
- #[ cfg( not( feature = "parallel" ) ) ]
124
- let res = ctt_context
125
- . ctx
126
- . compute_blob_kzg_proof ( & blob_bytes, & commitment. to_bytes ( ) ) ;
127
-
128
- match res {
129
- Ok ( proof) => CtG1 :: from_bytes ( & proof) ,
130
- Err ( x) => Err ( x. to_string ( ) ) ,
131
- }
97
+ ctt_context
98
+ . compute_blob_kzg_proof ( & blob_bytes, & commitment. to_bytes ( ) )
99
+ . map_err ( |e| e. to_string ( ) )
100
+ . and_then ( |proof| CtG1 :: from_bytes ( & proof) )
132
101
}
133
102
MixedKzgSettings :: Generic ( generic_context) => {
134
103
compute_blob_kzg_proof_rust ( blob, commitment, generic_context)
@@ -144,18 +113,14 @@ pub fn verify_kzg_proof_mixed(
144
113
s : & MixedKzgSettings ,
145
114
) -> Result < bool , String > {
146
115
match s {
147
- MixedKzgSettings :: Constantine ( ctt_context) => {
148
- let res = ctt_context . ctx . verify_kzg_proof (
116
+ MixedKzgSettings :: Constantine ( ctt_context) => ctt_context
117
+ . verify_kzg_proof (
149
118
& commitment. to_bytes ( ) ,
150
119
& z. to_bytes ( ) ,
151
120
& y. to_bytes ( ) ,
152
121
& proof. to_bytes ( ) ,
153
- ) ;
154
- match res {
155
- Ok ( x) => Ok ( x) ,
156
- Err ( x) => Err ( x. to_string ( ) ) ,
157
- }
158
- }
122
+ )
123
+ . map_err ( |e| e. to_string ( ) ) ,
159
124
MixedKzgSettings :: Generic ( generic_context) => {
160
125
verify_kzg_proof_rust ( commitment, z, y, proof, generic_context)
161
126
}
@@ -172,25 +137,9 @@ pub fn verify_blob_kzg_proof_mixed(
172
137
MixedKzgSettings :: Constantine ( ctt_context) => {
173
138
let blob_bytes = blob_fr_to_byte ( blob) ?;
174
139
175
- #[ cfg( feature = "parallel" ) ]
176
- let res = ctt_context. ctx . verify_blob_kzg_proof_parallel (
177
- & ctt_context. pool ,
178
- & blob_bytes,
179
- & commitment_g1. to_bytes ( ) ,
180
- & proof_g1. to_bytes ( ) ,
181
- ) ;
182
-
183
- #[ cfg( not( feature = "parallel" ) ) ]
184
- let res = ctt_context. ctx . verify_blob_kzg_proof (
185
- & blob_bytes,
186
- & commitment_g1. to_bytes ( ) ,
187
- & proof_g1. to_bytes ( ) ,
188
- ) ;
189
-
190
- match res {
191
- Ok ( x) => Ok ( x) ,
192
- Err ( x) => Err ( x. to_string ( ) ) ,
193
- }
140
+ ctt_context
141
+ . verify_blob_kzg_proof ( & blob_bytes, & commitment_g1. to_bytes ( ) , & proof_g1. to_bytes ( ) )
142
+ . map_err ( |e| e. to_string ( ) )
194
143
}
195
144
MixedKzgSettings :: Generic ( generic_context) => {
196
145
verify_blob_kzg_proof_rust ( blob, commitment_g1, proof_g1, generic_context)
@@ -220,29 +169,16 @@ pub fn verify_blob_kzg_proof_batch_mixed(
220
169
. collect :: < Vec < _ > > ( ) ;
221
170
let proofs_g1 = proofs_g1. iter ( ) . map ( |x| x. to_bytes ( ) ) . collect :: < Vec < _ > > ( ) ;
222
171
223
- let rand_thing = [ 0u8 ; 32 ] ;
224
-
225
- #[ cfg( feature = "parallel" ) ]
226
- let res = ctt_context. ctx . verify_blob_kzg_proof_batch_parallel (
227
- & ctt_context. pool ,
228
- blobs_storage. as_slice ( ) ,
229
- commitments. as_slice ( ) ,
230
- proofs_g1. as_slice ( ) ,
231
- & rand_thing,
232
- ) ;
233
-
234
- #[ cfg( not( feature = "parallel" ) ) ]
235
- let res = ctt_context. ctx . verify_blob_kzg_proof_batch (
236
- blobs_storage. as_slice ( ) ,
237
- commitments. as_slice ( ) ,
238
- proofs_g1. as_slice ( ) ,
239
- & rand_thing,
240
- ) ;
241
-
242
- match res {
243
- Ok ( x) => Ok ( x) ,
244
- Err ( x) => Err ( x. to_string ( ) ) ,
245
- }
172
+ let rand_thing = rand:: random ( ) ;
173
+
174
+ ctt_context
175
+ . verify_blob_kzg_proof_batch (
176
+ blobs_storage. as_slice ( ) ,
177
+ commitments. as_slice ( ) ,
178
+ proofs_g1. as_slice ( ) ,
179
+ & rand_thing,
180
+ )
181
+ . map_err ( |e| e. to_string ( ) )
246
182
}
247
183
MixedKzgSettings :: Generic ( generic_context) => {
248
184
verify_blob_kzg_proof_batch_rust ( blobs, commitments_g1, proofs_g1, generic_context)
0 commit comments