本文整理汇总了Golang中github.com/keybase/client/go/saltpack.BoxPublicKey类的典型用法代码示例。如果您正苦于以下问题:Golang BoxPublicKey类的具体用法?Golang BoxPublicKey怎么用?Golang BoxPublicKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoxPublicKey类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Box
func (n naclBoxSecretKey) Box(
receiver saltpack.BoxPublicKey, nonce *saltpack.Nonce, msg []byte) []byte {
ret := box.Seal([]byte{}, msg, (*[24]byte)(nonce),
(*[32]byte)(receiver.ToRawBoxKeyPointer()),
(*[32]byte)(n.Private))
return ret
}
示例2: BoxPublicKeyToKeybaseKID
func BoxPublicKeyToKeybaseKID(k saltpack.BoxPublicKey) (ret keybase1.KID) {
if k == nil {
return ret
}
p := k.ToKID()
return keybase1.KIDFromRawKey(p, KIDNaclDH)
}
示例3: Unbox
// Unbox runs the NaCl unbox operation on the given ciphertext and nonce,
// using the receiver as the secret key.
func (k SecretKey) Unbox(sender saltpack.BoxPublicKey, nonce *saltpack.Nonce, msg []byte) ([]byte, error) {
ret, ok := box.Open([]byte{}, msg, (*[24]byte)(nonce), (*[32]byte)(sender.ToRawBoxKeyPointer()), (*[32]byte)(&k.sec))
if !ok {
return nil, saltpack.ErrDecryptionFailed
}
return ret, nil
}
示例4: Precompute
func (n naclBoxSecretKey) Precompute(
sender saltpack.BoxPublicKey) saltpack.BoxPrecomputedSharedKey {
var res naclBoxPrecomputedSharedKey
box.Precompute((*[32]byte)(&res),
(*[32]byte)(sender.ToRawBoxKeyPointer()),
(*[32]byte)(n.Private))
return res
}
示例5: Unbox
func (n naclBoxSecretKey) Unbox(
sender saltpack.BoxPublicKey, nonce *saltpack.Nonce, msg []byte) (
[]byte, error) {
ret, ok := box.Open([]byte{}, msg, (*[24]byte)(nonce),
(*[32]byte)(sender.ToRawBoxKeyPointer()),
(*[32]byte)(n.Private))
if !ok {
return nil, DecryptionError{}
}
return ret, nil
}
示例6: Precompute
// Precompute computes a shared key with the passed public key.
func (k SecretKey) Precompute(sender saltpack.BoxPublicKey) saltpack.BoxPrecomputedSharedKey {
var res PrecomputedSharedKey
box.Precompute((*[32]byte)(&res), (*[32]byte)(sender.ToRawBoxKeyPointer()), (*[32]byte)(&k.sec))
return res
}