-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from Plutonomicon/staging
Plutarch 1.2
- Loading branch information
Showing
472 changed files
with
14,196 additions
and
6,159 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
flake.lock linguist-generated=true |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/result* | ||
/dist-newstyle | ||
/dist-* | ||
.direnv | ||
bench.csv |
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 |
---|---|---|
@@ -1,40 +1,70 @@ | ||
module Plutarch ( | ||
(:-->), | ||
ClosedTerm, | ||
compile, | ||
Dig, | ||
hashTerm, | ||
papp, | ||
pdelay, | ||
PDelayed, | ||
perror, | ||
pforce, | ||
phoistAcyclic, | ||
plam', | ||
plet, | ||
Term, | ||
S, | ||
PType, | ||
PlutusType (..), | ||
printTerm, | ||
printScript, | ||
(#$), | ||
(#), | ||
pinl, | ||
PCon (..), | ||
PMatch (..), | ||
pto, | ||
pfix, | ||
POpaque (..), | ||
popaque, | ||
plam, | ||
DerivePNewtype (DerivePNewtype), | ||
(PI.:-->), | ||
PI.ClosedTerm, | ||
PI.compile, | ||
PI.Dig, | ||
PI.hashTerm, | ||
PI.papp, | ||
PI.pdelay, | ||
PI.PDelayed, | ||
PI.perror, | ||
PI.pforce, | ||
PI.phoistAcyclic, | ||
PI.plet, | ||
PI.pthrow, | ||
PI.Term, | ||
PI.S, | ||
PI.PType, | ||
PP.PlutusType, | ||
PP.PInner, | ||
PP.pcon, | ||
PP.pmatch, | ||
PP.PCon, | ||
PP.PMatch, | ||
PPR.prettyTerm, | ||
PPR.prettyScript, | ||
PO.printTerm, | ||
PO.printScript, | ||
(PL.#$), | ||
(PL.#), | ||
PL.pinl, | ||
PO.pto, | ||
PO.pfix, | ||
PO.POpaque (PO.POpaque), | ||
PO.popaque, | ||
PL.plam, | ||
PT.TermCont (TermCont), | ||
PT.hashOpenTerm, | ||
PT.runTermCont, | ||
PT.unTermCont, | ||
PI.Config (Config, tracingMode), | ||
PI.TracingMode (NoTracing, DoTracing, DetTracing), | ||
PI.pgetConfig, | ||
PQ.PForall (PForall), | ||
PQ.PSome (PSome), | ||
PS.PScottEncoded (PScottEncoded), | ||
PS.PlutusTypeScott, | ||
PN.PlutusTypeNewtype, | ||
PP.DerivePlutusType, | ||
PP.DPTStrat, | ||
PP.PCovariant, | ||
PP.PCovariant', | ||
PP.PContravariant, | ||
PP.PContravariant', | ||
PP.PVariant, | ||
PP.PVariant', | ||
) where | ||
|
||
import Plutarch.Internal.Other | ||
import qualified Plutarch.Internal as PI | ||
import qualified Plutarch.Internal.Newtype as PN | ||
import qualified Plutarch.Internal.Other as PO | ||
import qualified Plutarch.Internal.PLam as PL | ||
import qualified Plutarch.Internal.PlutusType as PP | ||
import qualified Plutarch.Internal.Quantification as PQ | ||
import qualified Plutarch.Internal.ScottEncoding as PS | ||
import Plutarch.Num () | ||
import qualified Plutarch.Pretty as PPR | ||
import qualified Plutarch.TermCont as PT | ||
|
||
-- import orphan instances | ||
import Prelude () |
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,44 @@ | ||
module Plutarch.Api.Internal.Hashing ( | ||
hashScriptWithPrefix, | ||
hashData, | ||
hashLedgerBytes, | ||
) where | ||
|
||
import Codec.Serialise (serialise) | ||
import Crypto.Hash (hashWith) | ||
import Crypto.Hash.Algorithms ( | ||
Blake2b_224 (Blake2b_224), | ||
Blake2b_256 (Blake2b_256), | ||
HashAlgorithm, | ||
) | ||
import Data.ByteArray (convert) | ||
import Data.ByteString (ByteString) | ||
import qualified Data.ByteString.Lazy as Lazy | ||
|
||
import qualified PlutusLedgerApi.V1 as Plutus | ||
import qualified PlutusLedgerApi.V1.Scripts as Plutus | ||
import qualified PlutusTx.Builtins as PlutusTx | ||
|
||
_plutusHashWith :: HashAlgorithm alg => alg -> ByteString -> PlutusTx.BuiltinByteString | ||
_plutusHashWith alg = PlutusTx.toBuiltin . convert @_ @ByteString . hashWith alg | ||
|
||
hashBlake2b_224 :: ByteString -> PlutusTx.BuiltinByteString | ||
hashBlake2b_224 = _plutusHashWith Blake2b_224 | ||
|
||
hashBlake2b_256 :: ByteString -> PlutusTx.BuiltinByteString | ||
hashBlake2b_256 = _plutusHashWith Blake2b_256 | ||
|
||
-- | Hash a Script with the given version prefix | ||
hashScriptWithPrefix :: ByteString -> Plutus.Script -> Plutus.ScriptHash | ||
hashScriptWithPrefix prefix scr = | ||
Plutus.ScriptHash | ||
. hashBlake2b_224 | ||
$ prefix <> Lazy.toStrict (serialise scr) | ||
|
||
-- | Hash Plutus 'Data'. | ||
hashData :: Plutus.Data -> PlutusTx.BuiltinByteString | ||
hashData = hashBlake2b_256 . Lazy.toStrict . serialise | ||
|
||
-- | Hash 'LedgerBytes'. | ||
hashLedgerBytes :: Plutus.LedgerBytes -> PlutusTx.BuiltinByteString | ||
hashLedgerBytes = hashBlake2b_224 . Plutus.fromBuiltin . Plutus.getLedgerBytes |
This file was deleted.
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
Oops, something went wrong.