@@ -227,6 +227,7 @@ import Data.Bifunctor (first)
227
227
import Data.List as List
228
228
-- import Data.Either
229
229
import Data.String (IsString (fromString ))
230
+ import qualified Data.Text as Text (unpack )
230
231
import Numeric.Natural
231
232
232
233
import Data.ByteString (ByteString )
@@ -866,7 +867,9 @@ data OperationalCertificate =
866
867
data OperationalCertificateIssueCounter =
867
868
OperationalCertificateIssueCounter
868
869
! Natural
869
- ! (VerificationKey StakePoolKey ) -- For consistency checking
870
+ -- TODO: Commenting this out as we're temporarily supporting the old op
871
+ -- cert issue counter format.
872
+ -- !(VerificationKey StakePoolKey) -- For consistency checking
870
873
deriving (Eq , Show )
871
874
deriving anyclass SerialiseAsCBOR
872
875
@@ -880,13 +883,20 @@ instance FromCBOR OperationalCertificate where
880
883
return (OperationalCertificate ocert vkey)
881
884
882
885
instance ToCBOR OperationalCertificateIssueCounter where
883
- toCBOR (OperationalCertificateIssueCounter counter vkey) =
884
- toCBOR (counter, vkey)
886
+ -- TODO: Commenting this out as we're temporarily supporting the old op
887
+ -- cert issue counter format.
888
+ -- toCBOR (OperationalCertificateIssueCounter counter vkey) =
889
+ -- toCBOR (counter, vkey)
890
+ toCBOR (OperationalCertificateIssueCounter counter) =
891
+ toCBOR counter
885
892
886
893
instance FromCBOR OperationalCertificateIssueCounter where
887
- fromCBOR = do
888
- (counter, vkey) <- fromCBOR
889
- return (OperationalCertificateIssueCounter counter vkey)
894
+ -- TODO: Commenting this out as we're temporarily supporting the old op
895
+ -- cert issue counter format.
896
+ -- fromCBOR = do
897
+ -- (counter, vkey) <- fromCBOR
898
+ -- return (OperationalCertificateIssueCounter counter vkey)
899
+ fromCBOR = OperationalCertificateIssueCounter <$> fromCBOR
890
900
891
901
instance HasTypeProxy OperationalCertificate where
892
902
data AsType OperationalCertificate = AsOperationalCertificate
@@ -928,13 +938,20 @@ issueOperationalCertificate :: VerificationKey KesKey
928
938
issueOperationalCertificate (KesVerificationKey kesVKey)
929
939
(StakePoolSigningKey poolSKey)
930
940
kesPeriod
931
- (OperationalCertificateIssueCounter counter poolVKey)
932
- | poolVKey /= poolVKey'
933
- = Left (OperationalCertKeyMismatch poolVKey poolVKey')
934
-
935
- | otherwise
936
- = Right (OperationalCertificate ocert poolVKey,
937
- OperationalCertificateIssueCounter (succ counter) poolVKey)
941
+ -- TODO: Commenting this out as we're temporarily supporting the old op
942
+ -- cert issue counter format.
943
+ -- (OperationalCertificateIssueCounter counter poolVKey)
944
+ (OperationalCertificateIssueCounter counter)
945
+ -- TODO: Commenting this out as we're temporarily supporting the old op
946
+ -- cert issue counter format.
947
+ -- \| poolVKey /= poolVKey'
948
+ -- = Left (OperationalCertKeyMismatch poolVKey poolVKey')
949
+ --
950
+ -- \| otherwise
951
+ -- = Right (OperationalCertificate ocert poolVKey,
952
+ -- OperationalCertificateIssueCounter (succ counter) poolVKey)
953
+ = Right (OperationalCertificate ocert poolVKey',
954
+ OperationalCertificateIssueCounter (succ counter))
938
955
where
939
956
poolVKey' = getVerificationKey (StakePoolSigningKey poolSKey)
940
957
@@ -1025,7 +1042,7 @@ instance Error e => Error (FileError e) where
1025
1042
path ++ " : " ++ displayError e
1026
1043
1027
1044
instance Error TextView. TextViewError where
1028
- displayError _ = " TODO "
1045
+ displayError = Text. unpack . TextView. renderTextViewError
1029
1046
1030
1047
serialiseToTextEnvelope :: forall a . HasTextEnvelope a
1031
1048
=> Maybe TextEnvelopeDescr -> a -> TextEnvelope
@@ -1499,6 +1516,13 @@ instance HasTextEnvelope (SigningKey GenesisDelegateKey) where
1499
1516
-- TODO: use a different type from the stake pool key, since some operations
1500
1517
-- need a genesis key specifically
1501
1518
1519
+ instance CastKeyRole GenesisDelegateKey StakePoolKey where
1520
+ castVerificationKey (GenesisDelegateVerificationKey (Shelley. VKey vkey)) =
1521
+ StakePoolVerificationKey (Shelley. VKey vkey)
1522
+
1523
+ castSigningKey (GenesisDelegateSigningKey skey) =
1524
+ StakePoolSigningKey skey
1525
+
1502
1526
1503
1527
--
1504
1528
-- Genesis UTxO keys
@@ -1745,13 +1769,20 @@ instance SerialiseAsRawBytes (Hash VrfKey) where
1745
1769
VrfKeyHash <$> Crypto. hashFromBytes bs
1746
1770
1747
1771
instance HasTextEnvelope (VerificationKey VrfKey ) where
1748
- textEnvelopeType _ = " VerKeyVRF " <> fromString (Crypto. algorithmNameVRF proxy)
1772
+ textEnvelopeType _ = " VerKeyVRF " <> fromString (backCompatAlgorithmNameVrf proxy)
1749
1773
where
1750
1774
proxy :: Proxy (Shelley. VRF ShelleyCrypto )
1751
1775
proxy = Proxy
1752
1776
1753
1777
instance HasTextEnvelope (SigningKey VrfKey ) where
1754
- textEnvelopeType _ = " SignKeyVRF " <> fromString (Crypto. algorithmNameVRF proxy)
1778
+ textEnvelopeType _ = " SignKeyVRF " <> fromString (backCompatAlgorithmNameVrf proxy)
1755
1779
where
1756
1780
proxy :: Proxy (Shelley. VRF ShelleyCrypto )
1757
1781
proxy = Proxy
1782
+
1783
+ -- | Temporary solution for maintaining backward compatibility with the output
1784
+ -- of 'Cardano.Config.Shelley.VRF.encodeVRFVerificationKey'.
1785
+ backCompatAlgorithmNameVrf :: Proxy (Shelley. VRF ShelleyCrypto ) -> String
1786
+ backCompatAlgorithmNameVrf p =
1787
+ let algoName = Crypto. algorithmNameVRF p
1788
+ in if algoName == " simple" then " SimpleVRF" else algoName
0 commit comments