Skip to content

Commit a25b316

Browse files
committed
fix: fip FLAG_BITS
1 parent 45e3366 commit a25b316

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/derive/curve.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ macro_rules! new_curve_impl {
140140
#[allow(non_upper_case_globals)]
141141
const [< $name _FLAG_BITS >]: u8 =
142142
if $spare_bits == 1 {
143-
0b0111_1111
143+
0b1000_0000
144144
} else if $spare_bits == 2 {
145-
0b0011_1111
145+
0b1100_0000
146146
} else {
147147
//$spare_bits == 0
148-
0b0000_0000
148+
0b1111_1111
149149
};
150150

151151
impl group::GroupEncoding for $name_affine {
@@ -175,7 +175,7 @@ macro_rules! new_curve_impl {
175175
};
176176

177177
// Clear flag bits
178-
tmp[[< $name _FLAG_BYTE_INDEX>]] &= [< $name _FLAG_BITS >];
178+
tmp[[< $name _FLAG_BYTE_INDEX>]] |= [< $name _FLAG_BITS >];
179179

180180
// Get x-coordinate
181181
let mut xbytes = [0u8; $base::size()];
@@ -329,7 +329,7 @@ macro_rules! new_curve_impl {
329329
let identity_flag = Choice::from( ( ( bytes[ flag_idx ] & IS_IDENTITY_MASK) >> IS_IDENTITY_SHIFT) );
330330

331331
// Clear flags.
332-
bytes[flag_idx] &= [< $name _FLAG_BITS >];
332+
bytes[flag_idx] |= [< $name _FLAG_BITS >];
333333
identity_flag
334334
} else {
335335
// With 0 and 1 spare bit there is no identity flag, so we just rely

0 commit comments

Comments
 (0)