0

我遇到了 Gocrypto/ed25519软件包的问题。我正在尝试验证消息的签名,但我必须验证的签名和公钥比crypto/ed25519支持的要长。

crypto/ed25519包中,支持的密钥和签名的长度有限制:

const (
    // PublicKeySize is the size, in bytes, of public keys as used in this package.
    PublicKeySize = 32
    // PrivateKeySize is the size, in bytes, of private keys as used in this package.
    PrivateKeySize = 64
    // SignatureSize is the size, in bytes, of signatures generated and verified by this package.
    SignatureSize = 64
    // SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032.
    SeedSize = 32
)

但是我必须用来验证消息的密钥比这长:

SignatureSize = 128
PublicKeySize = 64

当我尝试使用Verify(...)它返回的函数时,false由于我的签名和公钥大小的大小。我该怎么做才能以当前长度验证我的签名?

4

1 回答 1

1

您拥有的密钥和签名很可能是十六进制编码的,以使它们在标头、json 等中易于阅读和传输。

先尝试解码它们:

    const s = "48656c6c6f20476f7068657221"
    decoded, err := hex.DecodeString(s)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(len(decoded))
于 2020-12-10T20:58:16.897 回答