Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
PrivateKeySizeErr = errors.New("private key length does not equal expected key length")
)
Functions ¶
func Hash ¶
func Hash(hp HashPolicy, s *big.Int) *big.Int
Hash returns a hash of a big integer given a hash policy.
func Verify ¶
func Verify(sp SignaturePolicy, hp HashPolicy, publicKey []byte, message []byte, signature []byte) bool
Verify returns true if the given signature was generated using the given public key, message, signature policy, and hash policy.
Types ¶
type HashPolicy ¶
HashPolicy defines how to create a cryptographic hash.
type KeyPair ¶
type KeyPair struct { PrivateKey []byte PublicKey []byte PrivKey crypto.PrivKey PubKey crypto.PubKey }
KeyPair represents a private and public key pair.
func FromPrivateKey ¶
func FromPrivateKey(sp SignaturePolicy, privateKey string) (*KeyPair, error)
FromPrivateKey returns a KeyPair given a signature policy and private key.
func (*KeyPair) PrivateKeyHex ¶
PrivateKeyHex returns the hex representation of the private key.
func (*KeyPair) PublicKeyHex ¶
PublicKeyHex returns the hex representation of the public key.
func (*KeyPair) Sign ¶
func (k *KeyPair) Sign(sp SignaturePolicy, hp HashPolicy, message []byte) ([]byte, error)
Sign returns a cryptographic signature that is a signed hash of the message.
type SignaturePolicy ¶
type SignaturePolicy interface { GenerateKeys() ([]byte, []byte, error) PrivateKeySize() int PrivateToPublic(privateKey []byte) ([]byte, error) PublicKeySize() int Sign(privateKey []byte, message []byte) []byte RandomKeyPair() *KeyPair Verify(publicKey []byte, message []byte, signature []byte) bool }
SignaturePolicy defines the creation and validation of a cryptographic signature.
Click to show internal directories.
Click to hide internal directories.