Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
edisontim committed Apr 3, 2024
1 parent 39168f8 commit ac98f8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/math/src/ed25519.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl PartialEqExtendedHomogeneousPoint of PartialEq<ExtendedHomogeneousPoint> {
}

impl SpanU8IntoU256 of Into<Span<u8>, u256> {
// Decode as little endian
/// Decode as little endian
fn into(self: Span<u8>) -> u256 {
if (self.len() > 32) {
return 0;
Expand Down Expand Up @@ -187,10 +187,9 @@ impl U256TryIntoPoint of TryInto<u256, Point> {
let mut y_le_span: Span<u8> = y_span.reverse().span();

let last_byte = *y_le_span[31];
let mut normed = y_le_span.clone();

let _ = normed.pop_back();
let mut normed_array: Array<u8> = normed.dedup();
let _ = y_le_span.pop_back();
let mut normed_array: Array<u8> = y_le_span.dedup();
normed_array.append(last_byte & ~0x80);

let x_0: u256 = (last_byte.into() / 128) & 1; // bitshift of 255
Expand Down
2 changes: 1 addition & 1 deletion src/math/src/tests/ed25519_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ fn verify_signature_invalid() {
let s_sign: u256 = 0x68e015fa8775659d1f40a01e1f69b8af4409046f4dc8ff02cdb04fdc3585eb01;
let signature = array![r_sign, s_sign];

assert!(verify_signature(msg, signature.span(), pub_key) == false, "Invalid signature");
assert!(!verify_signature(msg, signature.span(), pub_key), "Invalid signature");
}

0 comments on commit ac98f8e

Please sign in to comment.