Skip to content

Commit

Permalink
Merge pull request #4779 from input-output-hk/jordan/add-kes-signing-…
Browse files Browse the repository at this point in the history
…function

Implement signArbitraryBytesKes for use in Mithril
  • Loading branch information
Jimbo4350 authored Jan 17, 2023
2 parents 6cba1f6 + be17987 commit 022d552
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cardano-api/src/Cardano/Api/Keys/Praos.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}

-- | Praos consensus key types and their 'Key' class instances
Expand All @@ -20,10 +21,14 @@ module Cardano.Api.Keys.Praos (
Hash(..),
VerificationKey(..),
SigningKey(..),

-- * Signing
signArbitraryBytesKes,
) where

import Prelude

import Data.ByteString (ByteString)
import Data.Either.Combinators (maybeToRight)
import Data.String (IsString (..))

Expand All @@ -36,8 +41,8 @@ import qualified Cardano.Ledger.Crypto as Shelley (KES, VRF)
import qualified Cardano.Ledger.Keys as Shelley

import Cardano.Api.Hash
import Cardano.Api.Keys.Class
import Cardano.Api.HasTypeProxy
import Cardano.Api.Keys.Class
import Cardano.Api.SerialiseBech32
import Cardano.Api.SerialiseCBOR
import Cardano.Api.SerialiseRaw
Expand Down Expand Up @@ -145,6 +150,13 @@ instance HasTextEnvelope (SigningKey KesKey) where
proxy :: Proxy (Shelley.KES StandardCrypto)
proxy = Proxy

signArbitraryBytesKes
:: SigningKey KesKey
-> Crypto.Period -- ^ Desired Kes period
-> ByteString -- ^ Message to sign
-> Crypto.SignedKES (Shelley.KES StandardCrypto) ByteString
signArbitraryBytesKes (KesSigningKey kesKey) period message =
Crypto.signedKES @(Shelley.KES StandardCrypto) () period message kesKey

--
-- VRF keys
Expand Down
3 changes: 3 additions & 0 deletions cardano-api/src/Cardano/Api/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ module Cardano.Api.Shelley
fromMaryValue,
calcMinimumDeposit,

-- * Arbitrary signing
signArbitraryBytesKes,

-- * Signing transactions
-- | Creating transaction witnesses one by one, or all in one go.
Tx(ShelleyTx),
Expand Down

0 comments on commit 022d552

Please sign in to comment.