Documentation ¶
Overview ¶
Package p2p implements functions for generating symmetric keys for peer to peer communication.
Index ¶
- func GenerateKeys() (*PublicKey, *SecretKey, error)
- func Key(ss SharedSecret) (encrypt.SymmetricKey, error)
- func Keys(sk1 *SecretKey, pks []*PublicKey, pid uint16) ([]encrypt.SymmetricKey, error)
- func VerifySharedSecret(pk1, pk2 *PublicKey, elem SharedSecret) bool
- type PublicKey
- type SecretKey
- type SharedSecret
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Key ¶
func Key(ss SharedSecret) (encrypt.SymmetricKey, error)
Key returns symmetric key for communication between the peers.
func VerifySharedSecret ¶
func VerifySharedSecret(pk1, pk2 *PublicKey, elem SharedSecret) bool
VerifySharedSecret checks whether the shared element comes from the given keys.
Types ¶
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey is a public key used to generate p2p keys.
func DecodePublicKey ¶
DecodePublicKey decodes a verification key encoded as a base64 string.
func NewPublicKey ¶
NewPublicKey returns a public key for the specified secret.
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
SecretKey is a secret key used to generate p2p keys.
func DecodeSecretKey ¶
DecodeSecretKey decodes a secret key encoded as a base64 string.
func NewSecretKey ¶
NewSecretKey returns a secret key with the specified secret.
type SharedSecret ¶
type SharedSecret struct {
// contains filtered or unexported fields
}
SharedSecret is a secret shared between two peers. It should be revealed, when proving that the other party has sent non compliant messages.
func NewSharedSecret ¶
func NewSharedSecret(sk1 *SecretKey, pk2 *PublicKey) SharedSecret
NewSharedSecret returns a secret to share with the other party.
func (*SharedSecret) Marshal ¶
func (ss *SharedSecret) Marshal() []byte
Marshal the shared secret to bytes.
func (*SharedSecret) Unmarshal ¶
func (ss *SharedSecret) Unmarshal(data []byte) (*SharedSecret, error)
Unmarshal the shared secret from bytes.