@@ -139,11 +139,11 @@ impl<Fq: FqTrait> Sqisign<Fq> {
139
139
}
140
140
141
141
// Decode all but the last bytes for the Montgomery coefficient A
142
- let pk_curve_bytes = & buf[ .. Fq :: ENCODED_LENGTH ] ;
142
+ let ( pk_curve_bytes, buf ) = buf. split_at ( Fq :: ENCODED_LENGTH ) ;
143
143
let curve = Self :: decode_curve ( pk_curve_bytes) ?;
144
144
145
145
// The remaining byte is the hint for the torsion basis generation
146
- let hint = * buf. last ( ) . unwrap ( ) ;
146
+ let hint = buf[ 0 ] ;
147
147
148
148
Ok ( SqisignPublicKey { curve, hint } )
149
149
}
@@ -165,37 +165,30 @@ impl<Fq: FqTrait> Sqisign<Fq> {
165
165
} ) ;
166
166
}
167
167
168
- // Extract out all the buffer bytes into slices.
169
- let mut read = Fq :: ENCODED_LENGTH ;
170
-
171
168
// Extract the bytes for the auxiliary curve
172
- let aux_bytes = & buf[ ..read ] ;
169
+ let ( aux_bytes, buf ) = buf. split_at ( Fq :: ENCODED_LENGTH ) ;
173
170
let aux_curve = Self :: decode_curve ( aux_bytes) ?;
174
171
175
172
// Extract the two u8 to track backtracking and r such that the
176
173
// response length is 2^r.
177
- let backtracking = buf[ read] as usize ;
178
- read += 1 ;
179
- let two_resp_length = buf[ Fq :: ENCODED_LENGTH + 1 ] as usize ;
180
- read += 1 ;
174
+ let backtracking = buf[ 0 ] as usize ;
175
+ let two_resp_length = buf[ 1 ] as usize ;
176
+ let ( _, buf) = buf. split_at ( 2 ) ;
181
177
182
178
// Extract out the four scalars used for the change of basis
183
179
let mut aij: [ & [ u8 ] ; 4 ] = Default :: default ( ) ;
180
+ let ( mut aij_buf, buf) = buf. split_at ( 4 * aij_n_bytes) ;
184
181
for i in 0 ..4 {
185
- aij[ i] = & buf[ read..read + aij_n_bytes] ;
186
- read += aij_n_bytes;
182
+ ( aij[ i] , aij_buf) = aij_buf. split_at ( aij_n_bytes) ;
187
183
}
188
184
189
185
// Extract out the challenge bytes used to create the chl kernel
190
- let chl_scalar = & buf[ read..read + chl_n_bytes] ;
191
- read += chl_n_bytes;
186
+ let ( chl_scalar, buf) = buf. split_at ( chl_n_bytes) ;
192
187
193
188
// Extract out the final two bytes, used for torsion basis on E_aux
194
189
// and E_chl
195
- let hint_aux = buf[ read] ;
196
- read += 1 ;
197
- let hint_chl = buf[ read] ;
198
- assert ! ( read + 1 == buf. len( ) ) ;
190
+ let hint_aux = buf[ 0 ] ;
191
+ let hint_chl = buf[ 1 ] ;
199
192
200
193
Ok ( SqisignSignature {
201
194
aux_curve,
0 commit comments