-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into _update-deps/runtim…
…everification/k
- Loading branch information
Showing
14 changed files
with
157 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DEF = ecdsa | ||
include $(CURDIR)/../include.mk | ||
KOMPILE_OPTS += --hook-namespaces KRYPTO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#unparseData(#addrFromPrivateKey("0x2b8ba85ff7f2c7fa62cddb20ae40ef2553b9fdbff086f60d1647ecaab15af867"), 20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<k> | ||
"0xd308979bf428e38b458a99da348e28933a4cddb1" ~> . | ||
</k> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#unparseData(#addrFromPrivateKey("0x0000000000000000000000000000000000000000000000000000000000000001"), 20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<k> | ||
"0x7e5f4552091a69125d5dfcb7b8c2659029395bdf" ~> . | ||
</k> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#unparseData(#addrFromPrivateKey("0x0000000000000000000000000000000000000000000000000000000000000002"), 20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<k> | ||
"0x2b5ad5c4795c026514f8317c7a215e218dccd6cf" ~> . | ||
</k> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
module ECDSA | ||
imports INT | ||
imports BYTES | ||
imports STRING | ||
imports BOOL | ||
|
||
syntax String ::= Hex2Raw ( String ) [function] | ||
| Keccak256 ( String ) [function, hook(KRYPTO.keccak256)] | ||
| ECDSAPubKey ( String ) [function, hook(KRYPTO.ecdsaPubKey)] | ||
// ----------------------------------------------- | ||
rule Hex2Raw ( S ) => #unparseByteStack( #parseByteStack ( S ) ) | ||
|
||
syntax Int ::= #addrFromPrivateKey ( String ) [function, klabel(addrFromPrivateKey)] | ||
// ------------------------------------------------------------------------------------ | ||
rule [addrFromPrivateKey]: #addrFromPrivateKey ( KEY ) => #addr( #parseHexWord( Keccak256 ( Hex2Raw ( ECDSAPubKey( Hex2Raw ( KEY ) ) ) ) ) ) | ||
|
||
syntax Int ::= #parseHexWord ( String ) [function] | ||
// -------------------------------------------------- | ||
rule #parseHexWord("") => 0 | ||
rule #parseHexWord("0x") => 0 | ||
rule #parseHexWord(S) => String2Base(replaceAll(S, "0x", ""), 16) requires (S =/=String "") andBool (S =/=String "0x") | ||
|
||
syntax Bytes ::= #parseByteStack ( String ) [function, memo] | ||
| #parseHexBytes ( String ) [function] | ||
| #parseHexBytesAux ( String ) [function] | ||
// -------------------------------------------------------- | ||
rule #parseByteStack(S) => #parseHexBytes(replaceAll(S, "0x", "")) | ||
|
||
rule #parseHexBytes(S) => #parseHexBytesAux(#alignHexString(S)) | ||
rule #parseHexBytesAux("") => .Bytes | ||
rule #parseHexBytesAux(S) => Int2Bytes(lengthString(S) /Int 2, String2Base(S, 16), BE) | ||
requires lengthString(S) >=Int 2 | ||
|
||
syntax String ::= #alignHexString ( String ) [function, total] | ||
// -------------------------------------------------------------- | ||
rule #alignHexString(S) => S requires lengthString(S) modInt 2 ==Int 0 | ||
rule #alignHexString(S) => "0" +String S requires notBool lengthString(S) modInt 2 ==Int 0 | ||
|
||
syntax String ::= #unparseByteStack ( Bytes ) [function, klabel(unparseByteStack), symbol] | ||
// ------------------------------------------------------------------------------------------ | ||
rule #unparseByteStack(WS) => Bytes2String(WS) | ||
|
||
syntax String ::= #unparseData ( Int, Int ) [function] | ||
| #unparseDataBytes ( Bytes ) [function] | ||
// ------------------------------------------------------------ | ||
rule #unparseData( DATA, LENGTH ) => #unparseDataBytes(#padToWidth(LENGTH,#asByteStack(DATA))) | ||
|
||
rule #unparseDataBytes( DATA ) => replaceFirst(Base2String(#asInteger(#asByteStack(1) +Bytes DATA), 16), "1", "0x") | ||
|
||
syntax Int ::= #asInteger ( Bytes ) [function, total] | ||
// ----------------------------------------------------- | ||
rule #asInteger(WS) => Bytes2Int(WS, BE, Unsigned) [concrete] | ||
|
||
syntax Bytes ::= #asByteStack ( Int ) [function, total] | ||
// ------------------------------------------------------- | ||
rule #asByteStack(W) => Int2Bytes(W, BE, Unsigned) [concrete] | ||
|
||
syntax Bytes ::= #padToWidth ( Int , Bytes ) [function, total] | ||
| #padRightToWidth ( Int , Bytes ) [function, total] | ||
// ------------------------------------------------------------------- | ||
rule #padToWidth(N, BS) => BS requires notBool (N >=Int 0) | ||
rule [padToWidthNonEmpty]: #padToWidth(N, BS) => padLeftBytes(BS, N, 0) requires N >=Int 0 | ||
rule #padRightToWidth(N, BS) => BS requires notBool (N >=Int 0) | ||
rule [padRightToWidthNonEmpty]: #padRightToWidth(N, BS) => padRightBytes(BS, N, 0) requires N >=Int 0 | ||
|
||
syntax Int ::= #addr ( Int ) [function] | ||
// --------------------------------------- | ||
rule #addr(W) => W %Word pow160 | ||
|
||
syntax Int ::= Int "%Word" Int [function, total] | ||
// ------------------------------------------------ | ||
rule _ %Word W1 => 0 requires W1 ==Int 0 | ||
rule W0 %Word W1 => W0 modInt W1 requires W1 =/=Int 0 | ||
|
||
syntax Int ::= "pow160" [alias] /* 2 ^Int 160 */ | ||
// ------------------------------------------------ | ||
rule pow160 => 1461501637330902918203684832716283019655932542976 | ||
|
||
configuration | ||
<k> $PGM:Pgm </k> | ||
|
||
syntax Pgm ::= Bytes | String | Int | ||
// ----------------------------------- | ||
|
||
endmodule |