【问题标题】:Importing Crypto Modules in Haskell在 Haskell 中导入加密模块
【发布时间】:2017-10-30 04:29:36
【问题描述】:

我正在尝试运行一些 haskell 文件,但我以前从未做过 haskell,我遇到了错误。

import Crypto.Types.PubKey.ECDSA (Signature(..), PrivateKey(..), PublicKey(..))
import Crypto.Types.PubKey.ECC (Curve(CurveFP), CurvePrime(..), CurveCommon(..), Point(..))

import Codec.Crypto.ECC.Base (modinv)

import Crypto.Random (genBytes, GenError, CryptoRandomGen)
import Crypto.Util (bs2i, i2bs, i2bs_unsized)

import ECDSA.Util

Could not find module ‘Crypto.Types.PubKey.ECC’
Use -v to see a list of the files searched for.

如何导入/安装这些模块?谢谢。

ghc-pkg 列表的输出

 Cabal-2.0.0.2
    GLURaw-2.0.0.3
    GLUT-2.7.0.12
    HTTP-4000.3.7
    HUnit-1.6.0.0
    ObjectName-1.1.0.1
    OpenGL-3.0.2.0
    OpenGLRaw-3.2.5.0
    QuickCheck-2.10.0.1
    StateVar-1.1.0.4
    array-0.5.2.0
    async-2.1.1.1
    attoparsec-0.13.2.0
    base-4.10.0.0
    binary-0.8.5.1
    bytestring-0.10.8.2
    call-stack-0.1.0
    case-insensitive-1.2.0.10
    containers-0.5.10.2
    deepseq-1.4.3.0
    directory-1.3.0.2
    fgl-5.6.0.0
    filepath-1.4.1.2
    fixed-0.2.1.1
    ghc-8.2.1
    ghc-boot-8.2.1
    ghc-boot-th-8.2.1
    ghc-compact-0.1.0.0
    ghc-prim-0.5.1.0
    ghci-8.2.1
    half-0.2.2.3
    hashable-1.2.6.1
    haskeline-0.7.4.0
    haskell-src-1.0.2.0
    hoopl-3.10.2.2
    hpc-0.6.0.3
    hscolour-1.24.1
    html-1.0.1.2
    integer-gmp-1.0.1.0
    integer-logarithms-1.0.2
    mtl-2.2.1
    network-2.6.3.2
    network-uri-2.6.1.0
    parallel-3.2.1.1
    parsec-3.1.11
    pretty-1.1.3.3
    primitive-0.6.2.0
    process-1.6.1.0
    random-1.1
    regex-base-0.93.2
    regex-compat-0.95.1
    regex-posix-0.95.2
    rts-1.0
    scientific-0.3.5.1
    split-0.2.3.2
    stm-2.4.4.1
    syb-0.7
    template-haskell-2.12.0.0
    terminfo-0.4.1.0
    text-1.2.2.2
    tf-random-0.5
    time-1.8.0.2
    transformers-0.5.2.0
    unix-2.7.2.2
    unordered-containers-0.2.8.0
    vector-0.12.0.1
    xhtml-3000.2.2
    zlib-0.6.1.2


name:            ecdsa
version:         0.2
cabal-version:   >= 1.8
license:         OtherLicense
license-file:    COPYING
category:        Crypto
copyright:       © 2014 Stephen Paul Weber
author:          Stephen Paul Weber <singpolyma@singpolyma.net>
maintainer:      Stephen Paul Weber <singpolyma@singpolyma.net>
stability:       experimental
tested-with:     GHC == 7.4.1
synopsis:        Basic ECDSA signing implementation
homepage:        https://github.com/singpolyma/ecdsa-haskell
bug-reports:     https://github.com/singpolyma/ecdsa-haskell/issues
build-type:      Simple
description:
        Wraps the stuff in hecc to do ECDSA.

extra-source-files:
        README

library
        exposed-modules:
                ECDSA

        other-modules:
                ECDSA.Util

        build-depends:
                base == 4.*,
                bytestring,
                hecc,
                crypto-pubkey-types,
                crypto-api

source-repository head
        type:     git
        location: git://github.com/singpolyma/ecdsa-haskell.git

这是 .cabal 文件,我从这个 github 链接下载了这个项目来尝试理解它

https://github.com/singpolyma/ecdsa-haskell

【问题讨论】:

  • 您能告诉我们更多有关您的设置的信息吗?您使用的是stack 还是cabal 您有单个文件还是一个项目?你用什么ghc-version,stackcabal是什么版本?你能显示ghc-pkg list的输出吗?
  • 你好@epsilonhalbe 我去了haskell.org/downloads 并下载了“Haskell 平台:安装 GHC、Cabal 和其他一些工具,以及在您系统的全球位置上安装的一组入门库” .我也使用堆栈版本 1.5.1。它是一个项目,我正在使用 Sublime Text IDE。我编辑了帖子以显示 ghc-pkg list 的输出
  • 如果您使用项目,您必须将the-library 添加到您的build-depends 部分的.cabal 文件中。哪个库 - 我不知道,但 stack build应该让您很好地猜测要添加什么。
  • 请告诉我你的.cabal-file 的内容,然后我可以帮助你更多一点。 (也不要发布终端输出的图片,而是包含文本,这样问题是自包含的,如果图片从任何平台上删除,几年内没有人会阅读此内容。)
  • 您好@epsilonhalbe,我将在几分钟后编辑我的帖子。这是我第一次尝试 Haskell,所以对于我提出的一些小问题表示歉意,我应该已经有了答案

标签: haskell module


【解决方案1】:

我尝试构建包,但它需要 llvm-3.9 才能工作,由于某种原因,我的设置中没有。

另外,包hecc 已被弃用 - git repo 已有 4 年历史,已经过时了。如果您将其用于生产目的,我强烈建议您不要这样做。

这是一个stack.yaml,它应该可以工作,但hF2+llvm 一直困扰着我,就像我之前说的那样。

stack.yaml

resolver: nightly-2017-10-28
packages:
- .
extra-deps:
- hF2-0.2
- hecc-0.4.1.1
flags: {}
extra-package-dbs: []

尝试使用stack build构建

【讨论】:

  • 你好@epsilonhalbe 我现在不在家,但是一旦我回到家,我会接受您的更正并继续努力。可以肯定的是,我不应该更改 .cabal 文件?只是 stack.yaml 文件?我绝对不会将它用于生产,我只想看到它运行,这样我就可以理解它在做什么并逐步完成每一行代码。感谢您的建议
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多