Skip to content

Commit 23d43be

Browse files
fix: bug in decode_point where rec_id was 128 instead of 1
1 parent 6a96d29 commit 23d43be

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

extensions/ecc/guest/src/eddsa.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ where
118118
}
119119
let mut y_bytes = bytes.to_vec();
120120
// most significant bit stores the parity of the x-coordinate
121-
let rec_id = y_bytes[Coordinate::<C>::NUM_LIMBS - 1] & 0b10000000;
121+
let rec_id = (y_bytes[Coordinate::<C>::NUM_LIMBS - 1] & 0b10000000) >> 7;
122122
y_bytes[Coordinate::<C>::NUM_LIMBS - 1] &= 0b01111111;
123123
// from_le_bytes checks that y is reduced
124124
let y = Coordinate::<C>::from_le_bytes(&y_bytes)?;
@@ -136,6 +136,7 @@ where
136136
{
137137
let mut y_bytes = p.y().as_le_bytes().to_vec();
138138
if p.x().as_le_bytes()[0] & 1u8 == 1 {
139+
debug_assert!(y_bytes[Coordinate::<C>::NUM_LIMBS - 1] & 0b10000000 == 0);
139140
y_bytes[Coordinate::<C>::NUM_LIMBS - 1] |= 0b10000000;
140141
}
141142
y_bytes

0 commit comments

Comments
 (0)