Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
delneg committed Mar 22, 2024
1 parent 64b1fde commit 9c8f005
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions sgxvm/src/precompiles/curve25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl LinearCostPrecompile for Ed25519Verify {
let mut i = [0u8; 128];
i[..128].copy_from_slice(&input[..128]);

let mut buf = [0u8; 4];
let mut buf = [0u8; 32];

let msg = &i[0..32];
let pk = VerifyingKey::try_from(&i[32..64]).map_err(|_| PrecompileFailure::Error {
Expand All @@ -41,9 +41,9 @@ impl LinearCostPrecompile for Ed25519Verify {

// https://docs.rs/rust-crypto/0.2.36/crypto/ed25519/fn.verify.html
if pk.verify(msg, &sig).is_ok() {
buf[3] = 0u8;
buf[31] = 0u8;
} else {
buf[3] = 1u8;
buf[31] = 1u8;
};

Ok((ExitSucceed::Returned, buf.to_vec()))
Expand Down
4 changes: 2 additions & 2 deletions tests/solidity/contracts/ED25519VerifyPrecompile.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ contract ED25519VerifyPrecompile {
}

// Decode the result
bytes4 result = abi.decode(data, (bytes4));
uint256 result = abi.decode(data, (uint256));

// Check it's 0 (valid signature)
return result == bytes4(0);
return result == uint256(0);
}
}

0 comments on commit 9c8f005

Please sign in to comment.