Documentation ¶
Index ¶
- Constants
- Variables
- func CRandBytes(numBytes int) []byte
- func CReader() io.Reader
- func Hash(hp HashPolicy, s *big.Int) *big.Int
- func Sha256(bytes []byte) []byte
- func Verify(sp SignaturePolicy, hp HashPolicy, publicKey []byte, message []byte, ...) bool
- type Address
- type HashPolicy
- type KeyPair
- type PrivKey
- type PubKey
- type SignaturePolicy
- type Symmetric
Constants ¶
const ( // AddressSize is the size of a pubkey address. AddressSize = herhash.TruncatedSize )
Variables ¶
var (
ErrPrivateKeySize = 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 Address ¶
Address : An address is a []byte, but hex-encoded even in JSON. []byte leaves us the option to change the address length. Use an alias so Unmarshal methods (with ptr receivers) are available too.
type HashPolicy ¶
HashPolicy defines how to create a cryptographic hash.
type KeyPair ¶
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 PrivKey ¶
type PrivKey interface { Bytes() []byte Sign(msg []byte) ([]byte, error) PubKey() PubKey Equals(PrivKey) bool }
PrivKey ...
type PubKey ¶
type PubKey interface { Address() Address Bytes() []byte VerifyBytes(msg []byte, sig []byte) bool Equals(PubKey) bool GetAddress() string // Creates address in string format and precedes the address with 'H' }
PubKey ...
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.