我正在查看libsodium-公钥加密的示例,并且在加密明文时,除了接收方公钥之外,似乎还使用了发件人私钥。
摘自相关的example:
crypto_box_easy()函数加密长度为的消息m mlen字节,带有收件人的公钥pk,发件人的密钥sk 和一个nonce n。
这有什么意义?我的理解是签名邮件时只使用了发件人私钥?
答案 0 :(得分:0)
数字签名使用私钥加密,并使用公钥解密。这允许任何人使用签名者的公钥验证签名。
答案 1 :(得分:0)
libsodium文档引用了“身份验证标记”,在以下部分的different chapter中对此进行了解释:
This operation:
* Encrypts a message with a key and a nonce to keep it confidential.
* Computes an authentication tag. This tag is used to make sure that
the message hasn't been tampered with before decrypting it.
因此,libsodium所谓的身份验证标记等同于签署邮件的更常见术语。因此,crypto_box_easy(...)
函数将发件人私钥作为输入是有意义的,因为加密实际上是加密和签名。