-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into ana/asdata-product-…
…types
- Loading branch information
Showing
60 changed files
with
410 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
module Types | ||
where | ||
|
||
import "cryptonite" Crypto.Hash | ||
import "crypton" Crypto.Hash | ||
|
||
|
||
-- Basic types | ||
|
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 |
---|---|---|
@@ -1,59 +1,36 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
module PlutusCore.Crypto.Ed25519 ( | ||
verifyEd25519Signature_V1, | ||
verifyEd25519Signature_V2 | ||
) where | ||
module PlutusCore.Crypto.Ed25519 (verifyEd25519Signature) | ||
where | ||
|
||
import PlutusCore.Builtin.KnownType (BuiltinResult) | ||
import PlutusCore.Crypto.Utils | ||
|
||
import Cardano.Crypto.DSIGN.Class qualified as DSIGN | ||
import Cardano.Crypto.DSIGN.Ed25519 (Ed25519DSIGN) | ||
import Crypto.ECC.Ed25519Donna (publicKey, signature, verify) | ||
import Crypto.Error (CryptoFailable (..)) | ||
import Data.ByteString qualified as BS | ||
import Data.Text (Text, pack) | ||
|
||
-- | Ed25519 signature verification | ||
-- This will fail if the key or the signature are not of the expected length. | ||
-- This version uses the cardano-crypto implementation of the verification function. | ||
verifyEd25519Signature_V1 | ||
:: BS.ByteString -- ^ Public Key (32 bytes) | ||
-> BS.ByteString -- ^ Message (arbitrary length) | ||
-> BS.ByteString -- ^ Signature (64 bytes) | ||
-> BuiltinResult Bool | ||
verifyEd25519Signature_V1 pubKey msg sig = | ||
case verify | ||
<$> publicKey pubKey | ||
<*> pure msg | ||
<*> signature sig | ||
of CryptoPassed r -> pure r | ||
CryptoFailed err -> failWithMessage loc $ pack (show err) | ||
where | ||
loc :: Text | ||
loc = "Ed25519 signature verification" | ||
import Data.Text (Text) | ||
|
||
-- | Ed25519 signature verification | ||
-- This will fail if the key or the signature are not of the expected length. | ||
-- This version uses the cardano-crypto-class implementation of the verification | ||
-- function (using libsodium). | ||
verifyEd25519Signature_V2 | ||
verifyEd25519Signature | ||
:: BS.ByteString -- ^ Public Key (32 bytes) | ||
-> BS.ByteString -- ^ Message (arbitrary length) | ||
-> BS.ByteString -- ^ Signature (64 bytes) | ||
-> BuiltinResult Bool | ||
verifyEd25519Signature_V2 pk msg sig = | ||
verifyEd25519Signature pk msg sig = | ||
case DSIGN.rawDeserialiseVerKeyDSIGN @Ed25519DSIGN pk of | ||
Nothing -> failWithMessage loc "Invalid verification key." | ||
Just pk' -> case DSIGN.rawDeserialiseSigDSIGN @Ed25519DSIGN sig of | ||
Nothing -> failWithMessage loc "Invalid signature." | ||
Just sig' -> | ||
pure $ | ||
case DSIGN.verifyDSIGN () pk' msg sig' of | ||
Left _ -> False | ||
Right () -> True | ||
case DSIGN.verifyDSIGN () pk' msg sig' of | ||
Left _ -> False | ||
Right () -> True | ||
where | ||
loc :: Text | ||
loc = "Ed25519 signature verification" |
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
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
Oops, something went wrong.