我将如何验证 128 长度的 ED25519 签名
How would I verify a 128 length ED25519 signature
我遇到了 Go 的 crypto/ed25519
包的问题。我正在尝试验证消息的签名,但我必须验证的签名和 Public 密钥比 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(...)
函数时,它 returns false
因为我的签名大小和 public 密钥。我该怎么做才能以当前长度验证我的签名?
您拥有的密钥和签名很可能是十六进制编码的,以确保它们在 headers、json 等格式中易于阅读和传输
先尝试解码它们:
const s = "48656c6c6f20476f7068657221"
decoded, err := hex.DecodeString(s)
if err != nil {
log.Fatal(err)
}
fmt.Println(len(decoded))
我遇到了 Go 的 crypto/ed25519
包的问题。我正在尝试验证消息的签名,但我必须验证的签名和 Public 密钥比 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(...)
函数时,它 returns false
因为我的签名大小和 public 密钥。我该怎么做才能以当前长度验证我的签名?
您拥有的密钥和签名很可能是十六进制编码的,以确保它们在 headers、json 等格式中易于阅读和传输
先尝试解码它们:
const s = "48656c6c6f20476f7068657221"
decoded, err := hex.DecodeString(s)
if err != nil {
log.Fatal(err)
}
fmt.Println(len(decoded))