本文整理匯總了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
}