-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add poseidon-hash * add poseidon-hash * add poseidon-hash * Performance and readability Co-authored-by: chessai <[email protected]> * reformat * Renames * Complete gas model * Fix tests * disable poseidon hash before pact 4.10 * Address review * remove redundant TODO * Comment constants and hexify them to match the original --------- Co-authored-by: Davi Bauer <[email protected]> Co-authored-by: chessai <[email protected]>
- Loading branch information
1 parent
9d8d097
commit 422cec4
Showing
15 changed files
with
3,368 additions
and
13 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,20 @@ | ||
{-# LANGUAGE TypeOperators #-} | ||
{-# LANGUAGE DataKinds #-} | ||
|
||
module PoseidonSpec (spec) where | ||
|
||
import Test.Hspec | ||
import Crypto.Hash.PoseidonNative | ||
|
||
spec :: Spec | ||
spec = describe "poseidon" $ do | ||
describe "poseidon-hash" $ do | ||
it "computes the poseidon hash for two integers" $ do | ||
poseidon [1] `shouldBe` 18586133768512220936620570745912940619677854269274689475585506675881198879027 | ||
poseidon [1, 2] `shouldBe` 7853200120776062878684798364095072458815029376092732009249414926327459813530 | ||
poseidon [1, 2, 3] `shouldBe` 6542985608222806190361240322586112750744169038454362455181422643027100751666 | ||
poseidon [1, 2, 3, 4] `shouldBe` 18821383157269793795438455681495246036402687001665670618754263018637548127333 | ||
poseidon [1, 2, 3, 4, 5] `shouldBe` 6183221330272524995739186171720101788151706631170188140075976616310159254464 | ||
poseidon [1, 2, 3, 4, 5, 6] `shouldBe` 20400040500897583745843009878988256314335038853985262692600694741116813247201 | ||
poseidon [1, 2, 3, 4, 5, 6, 7] `shouldBe` 12748163991115452309045839028154629052133952896122405799815156419278439301912 | ||
poseidon [1, 2, 3, 4, 5, 6, 7, 8] `shouldBe` 18604317144381847857886385684060986177838410221561136253933256952257712543953 |
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,10 @@ | ||
;; Test poseidon-hash | ||
|
||
(expect "1 should equal 18586133768512220936620570745912940619677854269274689475585506675881198879027" 18586133768512220936620570745912940619677854269274689475585506675881198879027 (poseidon-hash-hack-a-chain 1)) | ||
(expect "1 2 should equal 7853200120776062878684798364095072458815029376092732009249414926327459813530" 7853200120776062878684798364095072458815029376092732009249414926327459813530 (poseidon-hash-hack-a-chain 1 2)) | ||
(expect "1 2 3 should equal 6542985608222806190361240322586112750744169038454362455181422643027100751666" 6542985608222806190361240322586112750744169038454362455181422643027100751666 (poseidon-hash-hack-a-chain 1 2 3)) | ||
(expect "1 2 3 4 should equal 18821383157269793795438455681495246036402687001665670618754263018637548127333" 18821383157269793795438455681495246036402687001665670618754263018637548127333 (poseidon-hash-hack-a-chain 1 2 3 4)) | ||
(expect "1 2 3 4 5 should equal 6183221330272524995739186171720101788151706631170188140075976616310159254464" 6183221330272524995739186171720101788151706631170188140075976616310159254464 (poseidon-hash-hack-a-chain 1 2 3 4 5)) | ||
(expect "1 2 3 4 5 6 should equal 20400040500897583745843009878988256314335038853985262692600694741116813247201" 20400040500897583745843009878988256314335038853985262692600694741116813247201 (poseidon-hash-hack-a-chain 1 2 3 4 5 6)) | ||
(expect "1 2 3 4 5 6 7 should equal 12748163991115452309045839028154629052133952896122405799815156419278439301912" 12748163991115452309045839028154629052133952896122405799815156419278439301912 (poseidon-hash-hack-a-chain 1 2 3 4 5 6 7)) | ||
(expect "1 2 3 4 5 6 7 8 should equal 18604317144381847857886385684060986177838410221561136253933256952257712543953" 18604317144381847857886385684060986177838410221561136253933256952257712543953 (poseidon-hash-hack-a-chain 1 2 3 4 5 6 7 8)) |