From 59a9536edc3889e37899995a73eee41f064fd1c6 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Fri, 5 Feb 2021 10:44:36 +0300 Subject: [PATCH] Drop duplicate function --- hschain-utxo-compiler/src/Hschain/Utxo/Compiler/Commands.hs | 2 +- hschain-utxo-lang/src/Hschain/Utxo/Lang/Sigma.hs | 5 ----- hschain-utxo-pow-node/test/TM/SmartCon/Basic.hs | 6 +++--- hschain-utxo-pow-node/test/TM/SmartCon/ErgoMix.hs | 3 +-- hschain-utxo-pow-node/test/TM/SmartCon/PayForCoffee.hs | 4 ++-- hschain-utxo-pow-node/test/TM/SmartCon/XorGame.hs | 3 +-- hschain-utxo-test/src/Hschain/Utxo/Test/Client/Wallet.hs | 2 +- 7 files changed, 9 insertions(+), 16 deletions(-) diff --git a/hschain-utxo-compiler/src/Hschain/Utxo/Compiler/Commands.hs b/hschain-utxo-compiler/src/Hschain/Utxo/Compiler/Commands.hs index a5c9131c..9c455bff 100644 --- a/hschain-utxo-compiler/src/Hschain/Utxo/Compiler/Commands.hs +++ b/hschain-utxo-compiler/src/Hschain/Utxo/Compiler/Commands.hs @@ -111,7 +111,7 @@ signSigma secretFile exprFile txFile output = do case expr of ConstBool _ -> errorExpressionIsConst SigmaResult sigma -> do - let env = Sigma.proofEnvFromKeys [Sigma.getKeyPair secret] + let env = Sigma.toProofEnv [Sigma.getKeyPair secret] signedSigma <- Sigma.newProof env sigma (getSigMessage SigAll tx) saveSigma signedSigma where diff --git a/hschain-utxo-lang/src/Hschain/Utxo/Lang/Sigma.hs b/hschain-utxo-lang/src/Hschain/Utxo/Lang/Sigma.hs index 2a330d6c..de0e5a24 100644 --- a/hschain-utxo-lang/src/Hschain/Utxo/Lang/Sigma.hs +++ b/hschain-utxo-lang/src/Hschain/Utxo/Lang/Sigma.hs @@ -23,7 +23,6 @@ module Hschain.Utxo.Lang.Sigma( , dtupleInput , newProof , verifyProof - , proofEnvFromKeys , newSecret , newKeyPair , toPublicKey @@ -190,10 +189,6 @@ eliminateSigmaBool = go where (bools, sigmas) = partitionEithers $ eliminateSigmaBool <$> as --- | Wrapper to contruct proof environment from list of key-pairs. -proofEnvFromKeys :: [KeyPair] -> ProofEnv -proofEnvFromKeys = toProofEnv - -- | Check if sigma expression is proven with given proof. equalSigmaProof :: Sigma.SigmaE () ProofInput -> Proof -> Bool equalSigmaProof candidate proof = diff --git a/hschain-utxo-pow-node/test/TM/SmartCon/Basic.hs b/hschain-utxo-pow-node/test/TM/SmartCon/Basic.hs index 85a90318..090e7eaf 100644 --- a/hschain-utxo-pow-node/test/TM/SmartCon/Basic.hs +++ b/hschain-utxo-pow-node/test/TM/SmartCon/Basic.hs @@ -11,7 +11,7 @@ import Prelude hiding ((<*)) import Hschain.Utxo.Lang.Types import Hschain.Utxo.Lang.Sigma.Types (generateKeyPair, KeyPair(..)) -import qualified Hschain.Utxo.Lang.Sigma.Protocol as Sigma +import qualified Hschain.Utxo.Lang.Sigma as Sigma import TM.BCH.Util @@ -32,7 +32,7 @@ tests = testGroup "Running blockchain" noDoubleTx :: Mine () noDoubleTx = do alice@KeyPair {getPublicKey=pkAlice } <- liftIO generateKeyPair - let sigmaEnv = Sigma.Env [ alice ] + let sigmaEnv = Sigma.toProofEnv [ alice ] -- H=1. Alice mines block bidAlice <- mineBlock (Just pkAlice) [] -- H=2. Alice spends mining reward @@ -60,7 +60,7 @@ simpleTransfers = do alice@KeyPair {getPublicKey=pkAlice } <- liftIO generateKeyPair bob@KeyPair {getPublicKey=pkBob } <- liftIO generateKeyPair charlie@KeyPair{getPublicKey=pkCharlie} <- liftIO generateKeyPair - let sigmaEnv = Sigma.Env [ alice, bob, charlie ] + let sigmaEnv = Sigma.toProofEnv [ alice, bob, charlie ] ---------------------------------------- -- H=1 Alice mines block bidAlice <- mineBlock (Just pkAlice) [] diff --git a/hschain-utxo-pow-node/test/TM/SmartCon/ErgoMix.hs b/hschain-utxo-pow-node/test/TM/SmartCon/ErgoMix.hs index c35cbcbd..f9a59405 100644 --- a/hschain-utxo-pow-node/test/TM/SmartCon/ErgoMix.hs +++ b/hschain-utxo-pow-node/test/TM/SmartCon/ErgoMix.hs @@ -13,7 +13,6 @@ import Prelude hiding ((<*)) import Hschain.Utxo.Lang import Hschain.Utxo.Lang.Sigma.EllipticCurve(EC(..)) import qualified Hschain.Utxo.Lang.Sigma as Sigma -import qualified Hschain.Utxo.Lang.Sigma.Protocol as Sigma import System.Random (randomIO) import TM.BCH.Util @@ -29,7 +28,7 @@ ergoMixTest = do bob <- liftIO newKeyPair let pkAlice = getPublicKey alice pkBob = getPublicKey bob - sigmaEnv = Sigma.Env [ alice, bob ] + sigmaEnv = Sigma.toProofEnv [ alice, bob ] -- Alice and Bob mine some money bidAlice <- mineBlock (Just pkAlice) [] bidBob <- mineBlock (Just pkBob ) [] diff --git a/hschain-utxo-pow-node/test/TM/SmartCon/PayForCoffee.hs b/hschain-utxo-pow-node/test/TM/SmartCon/PayForCoffee.hs index c982e6f5..9116c34d 100644 --- a/hschain-utxo-pow-node/test/TM/SmartCon/PayForCoffee.hs +++ b/hschain-utxo-pow-node/test/TM/SmartCon/PayForCoffee.hs @@ -14,7 +14,7 @@ import Prelude hiding ((<*)) import Hschain.Utxo.Lang import Hschain.Utxo.Lang.Sigma.Types (generateKeyPair, KeyPair(..)) -import qualified Hschain.Utxo.Lang.Sigma.Protocol as Sigma +import qualified Hschain.Utxo.Lang.Sigma as Sigma import TM.BCH.Util @@ -28,7 +28,7 @@ payforCoffee :: Bool -> Mine () payforCoffee isBob = do alice@KeyPair{getPublicKey=pkAlice} <- liftIO $ generateKeyPair bob@KeyPair {getPublicKey=pkBob } <- liftIO $ generateKeyPair - let sigmaEnv = Sigma.Env [ alice, bob ] + let sigmaEnv = Sigma.toProofEnv [ alice, bob ] -- H=1 Alice mines block bidAlice <- mineBlock (Just pkAlice) [] -- H=2 Alice sends reward to Bob with time-lock diff --git a/hschain-utxo-pow-node/test/TM/SmartCon/XorGame.hs b/hschain-utxo-pow-node/test/TM/SmartCon/XorGame.hs index b5fd97f2..3030ad0b 100644 --- a/hschain-utxo-pow-node/test/TM/SmartCon/XorGame.hs +++ b/hschain-utxo-pow-node/test/TM/SmartCon/XorGame.hs @@ -22,7 +22,6 @@ import Hschain.Utxo.Lang.Sigma.Types (generateKeyPair, KeyPair(..)) import Hschain.Utxo.Lang import qualified Hschain.Utxo.Lang.Sigma as Sigma -import qualified Hschain.Utxo.Lang.Sigma.Protocol as Sigma import qualified Hschain.Utxo.Lang.Utils.Hash as H import TM.BCH.Util @@ -37,7 +36,7 @@ xorGame :: Int64 -> Int64 -> Mine () xorGame aliceGuess bobGuess = do alice@KeyPair {getPublicKey=pkAlice } <- liftIO generateKeyPair bob@KeyPair {getPublicKey=pkBob } <- liftIO generateKeyPair - let sigmaEnv = Sigma.Env [ alice, bob ] + let sigmaEnv = Sigma.toProofEnv [ alice, bob ] -- Alice and Bob mine some money bidAlice <- mineBlock (Just pkAlice) [] bidBob <- mineBlock (Just pkBob ) [] diff --git a/hschain-utxo-test/src/Hschain/Utxo/Test/Client/Wallet.hs b/hschain-utxo-test/src/Hschain/Utxo/Test/Client/Wallet.hs index 70a1feb4..eb5180e7 100644 --- a/hschain-utxo-test/src/Hschain/Utxo/Test/Client/Wallet.hs +++ b/hschain-utxo-test/src/Hschain/Utxo/Test/Client/Wallet.hs @@ -65,7 +65,7 @@ getWalletPrivateKey = wallet'privateKey -- | Gets user proof environment or list of keys getProofEnv :: Wallet -> ProofEnv -getProofEnv Wallet{..} = proofEnvFromKeys [getKeyPair wallet'privateKey] +getProofEnv Wallet{..} = toProofEnv [getKeyPair wallet'privateKey] -- | Query the user balance. getBalance :: Wallet -> App Money