Skip to content

Commit

Permalink
network, evm: add EVM_EC_ERROR exceptional status code for crypto fun…
Browse files Browse the repository at this point in the history
…ction errors
  • Loading branch information
Everett Hildenbrandt committed Apr 12, 2018
1 parent ac178c9 commit acdfbb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions evm.md
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ Precompiled Contracts
syntax InternalOp ::= #ecadd(G1Point, G1Point)
// ----------------------------------------------
rule <k> #ecadd(P1, P2) => #exception EVM_INTERNAL_ERROR ... </k>
rule <k> #ecadd(P1, P2) => #exception EVM_EC_ERROR ... </k>
requires notBool isValidPoint(P1) orBool notBool isValidPoint(P2)
rule <k> #ecadd(P1, P2) => #end ... </k> <output> _ => #point(BN128Add(P1, P2)) </output>
requires isValidPoint(P1) andBool isValidPoint(P2)
Expand All @@ -1813,7 +1813,7 @@ Precompiled Contracts
syntax InternalOp ::= #ecmul(G1Point, Int)
// ------------------------------------------
rule <k> #ecmul(P, S) => #exception EVM_INTERNAL_ERROR ... </k>
rule <k> #ecmul(P, S) => #exception EVM_EC_ERROR ... </k>
requires notBool isValidPoint(P)
rule <k> #ecmul(P, S) => #end ... </k> <output> _ => #point(BN128Mul(P, S)) </output>
requires isValidPoint(P)
Expand All @@ -1827,7 +1827,7 @@ Precompiled Contracts
rule <k> ECPAIRING => #ecpairing(.List, .List, 0, DATA, #sizeWordStack(DATA)) ... </k>
<callData> DATA </callData>
requires #sizeWordStack(DATA) modInt 192 ==Int 0
rule <k> ECPAIRING => #exception EVM_INTERNAL_ERROR ... </k>
rule <k> ECPAIRING => #exception EVM_EC_ERROR ... </k>
<callData> DATA </callData>
requires #sizeWordStack(DATA) modInt 192 =/=Int 0
Expand All @@ -1842,7 +1842,7 @@ Precompiled Contracts
// -----------------------------------
rule <k> (#checkPoint => .) ~> #ecpairing(ListItem(AK::G1Point) _, ListItem(BK::G2Point) _, _, _, _) ... </k>
requires isValidPoint(AK) andBool isValidPoint(BK)
rule <k> #checkPoint ~> #ecpairing(ListItem(AK::G1Point) _, ListItem(BK::G2Point) _, _, _, _) => #exception EVM_INTERNAL_ERROR ... </k>
rule <k> #checkPoint ~> #ecpairing(ListItem(AK::G1Point) _, ListItem(BK::G2Point) _, _, _, _) => #exception EVM_EC_ERROR ... </k>
requires notBool isValidPoint(AK) orBool notBool isValidPoint(BK)
```

Expand Down
2 changes: 2 additions & 0 deletions network.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The following codes all indicate that the VM ended execution with an exception,
This can happen when accessing local memory with `CODECOPY*` or `CALLDATACOPY`, or when accessing return data with `RETURNDATACOPY`.
- `EVM_STATIC_MODE_ERROR` indicates that a `STATICCALL` tried to change state.
**TODO:** Avoid `_ERROR` suffix that suggests fatal error.
- `EVM_EC_ERROR` indicates an error with the eliptic curve cryptographic builtins.

```k
syntax ExceptionalStatusCode ::= "EVM_FAILURE"
Expand All @@ -37,6 +38,7 @@ The following codes all indicate that the VM ended execution with an exception,
| "EVM_STACK_UNDERFLOW"
| "EVM_INVALID_MEMORY_ACCESS"
| "EVM_STATIC_MODE_ERROR"
| "EVM_EC_ERROR"
```

### Ending Codes
Expand Down

0 comments on commit acdfbb9

Please sign in to comment.