I ve正在尝试使用。 Library 以及 I with problems with keygen,从Crypto.BLST
到签名
keygen :: (ByteArrayAccess ba, 32 <= n, KnownNat n) => SizedByteArray n ba -> SecretKey
我如何制定<条码>。 SizedByteArray n ba Object? 在link 实例
sk1 = keygen $ AS.unsafeSizedByteArray @32 @ByteString "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
www.un.org/Depts/DGACM/index_french.htm 数据。 这个例子不利于我。 当我试图做同样的事时,这些话语不会奏效。
Then I tried this code
import Data.ByteArray.Sized qualified as AS
import Data.Text.Encoding
import qualified Data.ByteString as B
import qualified Data.Text as T
import Data.Proxy (Proxy(..))
import Crypto.BLST
sk ="79cc407e6917b5673a1f6966c23c9e15
d257e5ab46cfe7b9b2f64200f2b2843e"
skp = T.pack sk
skpb = encodeUtf8 skp
姓名skpb
为ByteString
。 因此,根据<代码>大小ByteArray的定义。 (见下文)我应当获得<代码>Maybe SizedByteArray?
-- | create a SizedByteArray from the given ByteArrayAccess if the
-- size is the same as the target size.
--
sizedByteArray :: forall n ba . (KnownNat n, ByteArrayAccess ba)
=> ba
-> Maybe (SizedByteArray n ba)
sizedByteArray ba
| length ba == n = Just $ SizedByteArray ba
| otherwise = Nothing
where
n = fromInteger $ natVal (Proxy @n)
After trying this I get these errors:
ghci> AS.sizedByteArray skpb
<interactive>:7:1: error: [GHC-39999]
• No instance for ‘GHC.TypeNats.KnownNat n0’
arising from a use of ‘it’
• In the first argument of ‘print’, namely ‘it’
In a stmt of an interactive GHCi comm以及: print it
以及
ghci> keygen $ AS.sizedByteArray skpb
<interactive>:8:1: error: [GHC-64725]
• Cannot satisfy: 32 <= n0
• In the first argument of ‘($)’, namely ‘keygen’
In the expression: keygen $ AS.sizedByteArray skpb
In an equation for ‘it’: it = keygen $ AS.sizedByteArray skpb
我做了什么错误?