Skip to content

Commit

Permalink
add keccak256 native
Browse files Browse the repository at this point in the history
  • Loading branch information
chessai committed Mar 19, 2024
1 parent 34f5971 commit ddeb817
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 13 deletions.
26 changes: 21 additions & 5 deletions docs/en/pact-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ Return ID if called during current pact execution, failing if not.
Obtain current pact build version.
```lisp
pact> (pact-version)
"4.10"
"4.11"
```

Top level only: this function will fail if used in module code.
Expand Down Expand Up @@ -1796,7 +1796,23 @@ pact> (scalar-mult 'g1 {'x: 1, 'y: 2} 2)
{"x": 1368015179489954701390400359078579693043519447331113978918064868415326638035,"y": 9918110051302171585080402603319702774565515993150576347155970296011118125764}
```

## Poseidon Hash {#Poseidon Hash}
## Hashes {#Hashes}

### keccak256 {#keccak256}

*chunks* `[string]` *→* `string`


Compute the hash of a list of base64-encoded inputs. The hash is computed incrementally over all of the base64-decoded inputs.
```lisp
pact> (keccak256 [""])
"xdJGAYb3IzySfn2y3McDwOUAtlPKgic7e/rYBF2FpHA="
pact> (keccak256 ["IP9FQ2ml0FuBp489sFgZ/qmwjCOE91ywq2qhFd1pDaMTGHShyo9witFRnqlSweJJy1QNGWOSx56HdVQk/ufIkICMViciNZ7qUuihL7u5ad15YdK6UgN0k3VaX6BPDVChqibJtEFIwNO5TRxKWaMayhWui9RKy3gz2OkcS4b6MTWkIzh7gVG0Ez7SP21xh7UOwiBK2QGtdNOW5EJ04OyvquF7O5CF4iJgs1ylOxXMUqu6dYr2eY+9BOzuztZI869P2z3tdVeppc+3OCYSqKjz9FlH0aKc4pByko7Bk8ol1RBxvV4ZhOz0AvMG6nYvDyUoL1KW2Zdli+P5g2lv+m0JXGNptNr3nppdMTYikSj462PBK56fp4r/ej6eGaYgIkk80Tbe+7W7e6G5OPNn/S9j61ynbAsP8hueNsPwcjDPPDB05dpYcECnaXXX459ElKzlSG/L84CrdVjE/ollYzW4Lk24ZZUJ6rRqGWExJuWUBCcy3UxBH0GqjN6sccD7QKlObaVYwF53thgoBvJtmv3z2gDGlBkiLIGGpu+tYAtBDmzi8qeX5J3B8TUxmAH6bzlrBvl14qGQoCPkdLYY5w=="])
"DsjZ0g3fCnsCUelBpyYbVXUH/2KHtQQ2Ko8XNMWpEBI="
pact> (keccak256 ["IP9FQ2ml0FuBp489sFgZ/qmwjCOE91ywq2qhFd1pDaM=", "Exh0ocqPcIrRUZ6pUsHiSctUDRljkseeh3VUJP7nyJA=", "gIxWJyI1nupS6KEvu7lp3Xlh0rpSA3STdVpfoE8NUKE=", "qibJtEFIwNO5TRxKWaMayhWui9RKy3gz2OkcS4b6MTU=", "pCM4e4FRtBM+0j9tcYe1DsIgStkBrXTTluRCdODsr6o=", "4Xs7kIXiImCzXKU7FcxSq7p1ivZ5j70E7O7O1kjzr08=", "2z3tdVeppc+3OCYSqKjz9FlH0aKc4pByko7Bk8ol1RA=", "cb1eGYTs9ALzBup2Lw8lKC9SltmXZYvj+YNpb/ptCVw=", "Y2m02veeml0xNiKRKPjrY8Ernp+niv96Pp4ZpiAiSTw=", "0Tbe+7W7e6G5OPNn/S9j61ynbAsP8hueNsPwcjDPPDA=", "dOXaWHBAp2l11+OfRJSs5Uhvy/OAq3VYxP6JZWM1uC4=", "TbhllQnqtGoZYTEm5ZQEJzLdTEEfQaqM3qxxwPtAqU4=", "baVYwF53thgoBvJtmv3z2gDGlBkiLIGGpu+tYAtBDmw=", "4vKnl+SdwfE1MZgB+m85awb5deKhkKAj5HS2GOc="])
"DsjZ0g3fCnsCUelBpyYbVXUH/2KHtQQ2Ko8XNMWpEBI="
```


### poseidon-hash-hack-a-chain {#poseidon-hash-hack-a-chain}

Expand All @@ -1822,9 +1838,9 @@ pact> (poseidon-hash-hack-a-chain 1 2 3 4 5 6 7 8)
*x* `string` *→* `object:*`


Decode a base-64 encoded Hyperlane Token Message into an object `{recipient:GUARD, amount:DECIMAL, chainId:STRING}`.
Decode a base-64-unpadded encoded Hyperlane Token Message into an object `{recipient:GUARD, amount:DECIMAL, chainId:STRING}`.
```lisp
pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==")
pact> (hyperlane-decode-token-message "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAewAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGF7InByZWQiOiAia2V5cy1hbGwiLCAia2V5cyI6WyJkYTFhMzM5YmQ4MmQyYzJlOTE4MDYyNmEwMGRjMDQzMjc1ZGViM2FiYWJiMjdiNTczOGFiZjZiOWRjZWU4ZGI2Il19AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
{"amount": 0.000000000000000123,"chainId": "4","recipient": KeySet {keys: [da1a339bd82d2c2e9180626a00dc043275deb3ababb27b5738abf6b9dcee8db6],pred: keys-all}}
```

Expand Down Expand Up @@ -1983,7 +1999,7 @@ Retreive any accumulated events and optionally clear event state. Object returne
*→* `[string]`


Queries, or with arguments, sets execution config flags. Valid flags: ["AllowReadInLocal","DisableHistoryInTransactionalMode","DisableInlineMemCheck","DisableModuleInstall","DisableNewTrans","DisablePact40","DisablePact410","DisablePact411","DisablePact42","DisablePact43","DisablePact431","DisablePact44","DisablePact45","DisablePact46","DisablePact47","DisablePact48","DisablePact49","DisablePactEvents","DisableRuntimeReturnTypeChecking","EnforceKeyFormats","OldReadOnlyBehavior","PreserveModuleIfacesBug","PreserveModuleNameBug","PreserveNsModuleInstallBug","PreserveShowDefs"]
Queries, or with arguments, sets execution config flags. Valid flags: ["AllowReadInLocal","DisableHistoryInTransactionalMode","DisableInlineMemCheck","DisableModuleInstall","DisableNewTrans","DisablePact40","DisablePact410","DisablePact411","DisablePact412","DisablePact42","DisablePact43","DisablePact431","DisablePact44","DisablePact45","DisablePact46","DisablePact47","DisablePact48","DisablePact49","DisablePactEvents","DisableRuntimeReturnTypeChecking","EnforceKeyFormats","OldReadOnlyBehavior","PreserveModuleIfacesBug","PreserveModuleNameBug","PreserveNsModuleInstallBug","PreserveShowDefs"]
```lisp
pact> (env-exec-config ['DisableHistoryInTransactionalMode]) (env-exec-config)
["DisableHistoryInTransactionalMode"]
Expand Down
6 changes: 6 additions & 0 deletions golden/gas-model/golden
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,12 @@
(diff-time (time "2016-07-22T12:00:00Z")
(time "2018-07-22T12:00:00Z"))
- 12
- - |-
(keccak256 [""])
(keccak256 ["IP9FQ2ml0FuBp489sFgZ/qmwjCOE91ywq2qhFd1pDaMTGHShyo9witFRnqlSweJJy1QNGWOSx56HdVQk/ufIkICMViciNZ7qUuihL7u5ad15YdK6UgN0k3VaX6BPDVChqibJtEFIwNO5TRxKWaMayhWui9RKy3gz2OkcS4b6MTWkIzh7gVG0Ez7SP21xh7UOwiBK2QGtdNOW5EJ04OyvquF7O5CF4iJgs1ylOxXMUqu6dYr2eY+9BOzuztZI869P2z3tdVeppc+3OCYSqKjz9FlH0aKc4pByko7Bk8ol1RBxvV4ZhOz0AvMG6nYvDyUoL1KW2Zdli+P5g2lv+m0JXGNptNr3nppdMTYikSj462PBK56fp4r/ej6eGaYgIkk80Tbe+7W7e6G5OPNn/S9j61ynbAsP8hueN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y0tel9rc8WtrUKrg87VJ7OR3Rtts5vZ91EBs1OdVldUQPRP536eTcpJNMo+N0fy+taji6L9Mdt4I4/xGqgIfmJxJMpx6ysWmiFVte8vLKl1L5p0yhOnEDsSDjuhZISDOIKC2NeytqoT9VpBQn1T3fjWkF8WEZIvJg5uXTge/qwA46QKV0LE5AlMKgw0cK91T8fnJ+u1Dyk7tCo3XYbx+292iiih8YM1Cr1+cdY5cclAjHAmlglY2ia/GXit5p6K2ggBmd1LpEBdG8DGE4jmeTtiDXLjprpDilq8iCuI0JZ/gvQvMYPekpf8/cMXtTenIxRmhDpYvZzyCxek1F4aoo7/VcAMYV71Mh/T8ox7U1Q4U8hB9oCy1BYcAt06iQai0HXhGFljxsrkL/YSkwsnWVDhhqzxWRRdX3PubpgMzSI290C1gG0Gq4xfKdHTrbm3Q=="])
- 14
- - (make-list longNumber true)
- 1026
- - (make-list medNumber true)
Expand Down
6 changes: 5 additions & 1 deletion pact.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ library
cbits/musl/sqrt_data.c
exposed-modules:
Crypto.Hash.Blake2Native
Crypto.Hash.Keccak256Native
Crypto.Hash.HyperlaneMessageId
Crypto.Hash.PoseidonNative
Pact.Analyze.Remote.Types
Expand Down Expand Up @@ -222,11 +223,12 @@ library
, direct-sqlite >=2.3.27
, directory >=1.2.6.2
, errors >=2.3
, ethereum >= 0.1
, exceptions >=0.8.3
, filepath >=1.4.1.0
, groups
, hashable >=1.4
, ethereum >= 0.1
, hashes >= 0.2
, lens >=4.14
, megaparsec >=9
, memory
Expand Down Expand Up @@ -421,6 +423,7 @@ test-suite hspec
, attoparsec
, base
, base16-bytestring
, base64-bytestring
, bound
, bytestring
, containers
Expand Down Expand Up @@ -471,6 +474,7 @@ test-suite hspec
GoldenSpec
HistoryServiceSpec
HyperlaneSpec
Keccak256Spec
PactContinuationSpec
PersistSpec
PoseidonSpec
Expand Down
57 changes: 57 additions & 0 deletions src/Crypto/Hash/Keccak256Native.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

-- | Implementation of the `keccack256` pact native.
--
-- `keccak256` takes as input a Pact object representing a
-- 'HyperlaneMessage', and returns a base16-encoded hash of the abi-encoding
-- of the input.
module Crypto.Hash.Keccak256Native (keccak256) where

import Control.Exception (Exception(..), SomeException(..), try)
import Control.Lens ((^.))
import Control.Monad (forM_)
import Control.Monad.Catch (throwM)
import Data.ByteString.Base64 qualified as Base64
import Data.ByteString.Short qualified as BSS
import Data.Hash.Class.Mutable (initialize, finalize, updateByteString)
import Data.Hash.Internal.OpenSSL (OpenSslException(..))
import Data.Hash.Keccak (Keccak256(..))
import Data.Text (Text)
import Data.Text.Encoding qualified as Text
import Data.Vector (Vector)
import Pact.Types.Term (Term, Name, _TLitString)
import System.IO.Unsafe (unsafePerformIO)

keccak256 :: Vector (Term Name) -> Text
keccak256 strings = unsafePerformIO $ do
e <- try @SomeException @_ $ do
ctx <- initialize @Keccak256
forM_ strings $ \string -> do
let s = string ^. _TLitString
case Base64.decode (Text.encodeUtf8 s) of
Left b64Err -> do
throwM (Base64Exception b64Err)
Right bytes -> do
updateByteString @Keccak256 ctx bytes
Keccak256 hash <- finalize ctx
pure (BSS.fromShort hash)
case e of
Left err
| Just (OpenSslException _) <- fromException err -> error "keccak256 failed"
| Just (Base64Exception _) <- fromException err -> error "keccak256 failed: invalid base64 input"
| otherwise -> error "keccak256 failed"
Right hash -> pure (Text.decodeUtf8 (Base64.encode hash))
{-# noinline keccak256 #-}

newtype Base64Exception = Base64Exception String
deriving stock (Show)

instance Exception Base64Exception where
displayException (Base64Exception err) =
"base64 decode exception: " ++ err
6 changes: 6 additions & 0 deletions src/Pact/Gas/Table.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ data GasCostConfig = GasCostConfig
, _gasCostConfig_poseidonHashHackAChainLinearGasFactor :: Gas
, _gasCostConfig_hyperlaneMessageIdGasPerRecipientOneHundredBytes :: MilliGas
, _gasCostConfig_hyperlaneDecodeTokenMessageGasPerOneHundredBytes :: MilliGas
, _gasCostConfig_keccak256GasPerOneHundredBytes :: MilliGas
}

defaultGasConfig :: GasCostConfig
Expand Down Expand Up @@ -85,6 +86,7 @@ defaultGasConfig = GasCostConfig
, _gasCostConfig_poseidonHashHackAChainQuadraticGasFactor = 38
, _gasCostConfig_hyperlaneMessageIdGasPerRecipientOneHundredBytes = MilliGas 47
, _gasCostConfig_hyperlaneDecodeTokenMessageGasPerOneHundredBytes = MilliGas 50
, _gasCostConfig_keccak256GasPerOneHundredBytes = MilliGas 146
}

defaultGasTable :: Map Text Gas
Expand Down Expand Up @@ -242,6 +244,7 @@ defaultGasTable =
,("poseidon-hash-hack-a-chain", 124)
,("hyperlane-message-id", 2)
,("hyperlane-decode-token-message", 2)
,("keccak256",3)
]

{-# NOINLINE defaultGasTable #-}
Expand Down Expand Up @@ -345,6 +348,9 @@ tableGasModel gasConfig =
GHyperlaneDecodeTokenMessage len ->
let MilliGas costPerOneHundredBytes = _gasCostConfig_hyperlaneDecodeTokenMessageGasPerOneHundredBytes gasConfig
in MilliGas (costPerOneHundredBytes * div (fromIntegral len) 100)
GKeccak256 numBytes ->
let MilliGas costPerOneHundredBytes = _gasCostConfig_keccak256GasPerOneHundredBytes gasConfig
in MilliGas (costPerOneHundredBytes * div (fromIntegral numBytes) 100)

in GasModel
{ gasModelName = "table"
Expand Down
11 changes: 11 additions & 0 deletions src/Pact/GasModel/GasTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ allTests = HM.fromList
-- SPI/Hyperlane
, ("hyperlane-message-id", hyperlaneMessageIdTests)
, ("enforce-verifier", enforceVerifierTests)
, ("keccak256", keccak256Tests)

-- Non-native concepts to benchmark
, ("use", useTests)
Expand Down Expand Up @@ -2044,3 +2045,13 @@ hyperlaneMessageIdTests = defGasUnitTest $ PactExpression hyperlaneMessageIdExpr
(hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F","sender": "0x6b622d746f6b656e2d726f75746572","tokenMessage": {"amount": 10000000000000000000.0,"recipient": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F"},"version": 1})
(hyperlane-message-id {"destinationDomain": 1,"nonce": 325,"originDomain": 626,"recipient": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F","sender": "0x6b622d746f6b656e2d726f75746572","tokenMessage": {"amount": 10000000000000000000.0,"recipient": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"},"version": 1})
|]

keccak256Tests :: NativeDefName -> GasUnitTests
keccak256Tests = defGasUnitTest $ PactExpression keccak256ExprText Nothing
where
keccak256ExprText = [text|
(keccak256 [""])
(keccak256 ["IP9FQ2ml0FuBp489sFgZ/qmwjCOE91ywq2qhFd1pDaMTGHShyo9witFRnqlSweJJy1QNGWOSx56HdVQk/ufIkICMViciNZ7qUuihL7u5ad15YdK6UgN0k3VaX6BPDVChqibJtEFIwNO5TRxKWaMayhWui9RKy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b5deKhkKAj5HS2GOc="])
(keccak256 ["T73FllCNJKKgAQ4UCYC4CfucbVXsdRJYkd2YXTdmW9gPm+tqUCB1iKvzzu6Md82KWtSKngqgdO04hzg2JJbS+yyHVDuzNJ6mSZfOPntCTqktEi9X27CFWoAwWEN/4Ir7DItecXm5BEu/TYGnFjsxOeMIiLU2sPlX7/macWL0ylqnVqSpgt+tvzHvJVCDxLXGwbmaEH19Ov/9uJFHwsxMmiZD9Hjl4tOTrqN7THy0tel9rc8WtrUKrg87VJ7OR3Rtts5vZ91EBs1OdVldUQPRP536eTcpJNMo+N0fy+taji6L9Mdt4I4/xGqgIfmJxJMpx6ysWmiFVte8vLKl1L5p0yhOnEDsSDjuhZISDOIKC2NeytqoT9VpBQn1T3fjWkF8WEZIvJg5uXTge/qwA46QKV0LE5AlMKgw0cK91T8fnJ+u1Dyk7tCo3XYbx+292iiih8YM1Cr1+cdY5cclAjHAmlglY2ia/GXit5p6K2ggBmd1LpEBdG8DGE4jmeTtiDXLjprpDilq8iCuI0JZ/gvQvMYPekpf8/cMXtTenIxRmhDpYvZzyCxek1F4aoo7/VcAMYV71Mh/T8ox7U1Q4U8hB9oCy1BYcAt06iQai0HXhGFljxsrkL/YSkwsnWVDhhqzxWRRdX3PubpgMzSI290C1gG0Gq4xfKdHTrbm3Q=="])
|]
10 changes: 9 additions & 1 deletion src/Pact/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ disablePact410Natives = disablePactNatives pact410Natives FlagDisablePact410
disablePact411Natives :: ExecutionConfig -> Endo RefStore
disablePact411Natives = disablePactNatives pact411Natives FlagDisablePact411

disablePact412Natives :: ExecutionConfig -> Endo RefStore
disablePact412Natives = disablePactNatives pact412Natives FlagDisablePact412

pact40Natives :: [Text]
pact40Natives = ["enumerate" , "distinct" , "emit-event" , "concat" , "str-to-list"]

Expand All @@ -278,6 +281,9 @@ pact410Natives = ["poseidon-hash-hack-a-chain"]
pact411Natives :: [Text]
pact411Natives = ["enforce-verifier", "hyperlane-message-id", "hyperlane-decode-token-message"]

pact412Natives :: [Text]
pact412Natives = ["keccak256"]

initRefStore :: RefStore
initRefStore = RefStore nativeDefs

Expand All @@ -292,7 +298,9 @@ versionedNativesRefStore ec = versionNatives initRefStore
, disablePact46Natives ec
, disablePact47Natives ec
, disablePact410Natives ec
, disablePact411Natives ec ]
, disablePact411Natives ec
, disablePact412Natives ec
]

mkSQLiteEnv :: Logger -> Bool -> PSL.SQLiteConfig -> Loggers -> IO (PactDbEnv (DbEnv PSL.SQLite))
mkSQLiteEnv initLog deleteOldFile c loggers = do
Expand Down
Loading

0 comments on commit ddeb817

Please sign in to comment.