在本模块文档中(为简单起见,仅考虑 Alice 的一侧),示例代码为:
// Get a group. Use the default one would be enough.
g, _ := GetGroup(0)
// Generate a private key from the group.
// Use the default random number generator.
priv, _ := g.GeneratePrivateKey(nil)
// Get the public key from the private key.
pub := priv.Bytes()
// Send the public key to Bob.
Send("Bob", pub)
// Receive a slice of bytes from Bob, which contains Bob's public key
b := Recv("Bob")
// Recover Bob's public key
bobPubKey := NewPublicKey(b)
// Compute the key
k, _ := group.ComputeKey(bobPubKey, priv)
// Get the key in the form of []byte
key := k.Bytes()
以下是我的问题:
1)
// Get the public key from the private key.
pub := priv.Bytes()
如何将私有字节用作公钥字节?它只是方法的命名错误吗?(应该像假设同时包含私钥和公钥一样)priv.GetPubBytes()priv
2)
// Receive a slice of bytes from Bob, which contains Bob's public key
b := Recv("Bob")
// Recover Bob's public key
bobPubKey := NewPublicKey(b)
如果包含Bob的公钥(通过通道),那么为什么我们需要恢复它?此恢复过程将什么转换为什么?b
宝慕林4294392
红糖糍粑
随时随地看视频慕课网APP
相关分类