Skip to content

Commit

Permalink
Drop duplicate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Shimuuar committed Feb 5, 2021
1 parent befb871 commit 59a9536
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions hschain-utxo-lang/src/Hschain/Utxo/Lang/Sigma.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module Hschain.Utxo.Lang.Sigma(
, dtupleInput
, newProof
, verifyProof
, proofEnvFromKeys
, newSecret
, newKeyPair
, toPublicKey
Expand Down Expand Up @@ -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 =
Expand Down
6 changes: 3 additions & 3 deletions hschain-utxo-pow-node/test/TM/SmartCon/Basic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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) []
Expand Down
3 changes: 1 addition & 2 deletions hschain-utxo-pow-node/test/TM/SmartCon/ErgoMix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ) []
Expand Down
4 changes: 2 additions & 2 deletions hschain-utxo-pow-node/test/TM/SmartCon/PayForCoffee.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions hschain-utxo-pow-node/test/TM/SmartCon/XorGame.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ) []
Expand Down
2 changes: 1 addition & 1 deletion hschain-utxo-test/src/Hschain/Utxo/Test/Client/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 59a9536

Please sign in to comment.