Documentation ¶
Index ¶
- type Context
- type CryptoFactory
- type PrivateKey
- type PublicKey
- type Secp256k1Context
- func (self *Secp256k1Context) GetAlgorithmName() string
- func (self *Secp256k1Context) GetPublicKey(private_key PrivateKey) PublicKey
- func (self *Secp256k1Context) NewRandomPrivateKey() PrivateKey
- func (self *Secp256k1Context) Sign(message []byte, private_key PrivateKey) []byte
- func (self *Secp256k1Context) Verify(signature []byte, message []byte, public_key PublicKey) bool
- type Secp256k1PrivateKey
- type Secp256k1PublicKey
- type Signer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface { // Returns the algorithm name used for this context. GetAlgorithmName() string // Generates a new random private key. NewRandomPrivateKey() PrivateKey // Produces a public key for the given private key. GetPublicKey(private_key PrivateKey) PublicKey // Sign uses the given private key to calculate a signature for // the given data. Sign(message []byte, private_key PrivateKey) []byte // Verify uses the given public key to verify that the given // signature was created from the given data using the associated // private key. Verify(signature []byte, message []byte, public_key PublicKey) bool }
A context for a cryptographic signing algorithm.
func CreateContext ¶
Returns a Context instance by name.
type CryptoFactory ¶
type CryptoFactory struct {
// contains filtered or unexported fields
}
A factory for generating Signers.
func NewCryptoFactory ¶
func NewCryptoFactory(context Context) *CryptoFactory
Creates a factory for generating Signers.
func (*CryptoFactory) GetContext ¶
func (self *CryptoFactory) GetContext() Context
Returns the context that backs this Factory instance.
func (*CryptoFactory) NewSigner ¶
func (self *CryptoFactory) NewSigner(private_key PrivateKey) *Signer
Creates a new Signer for the given private key.
type PrivateKey ¶
type PrivateKey interface { // Returns the algorithm name used for this private key. GetAlgorithmName() string // Returns the private key encoded as a hex string. AsHex() string // Returns the private key bytes. AsBytes() []byte }
A private key instance. The underlying content is dependent on implementation.
func NewSecp256k1PrivateKey ¶
func NewSecp256k1PrivateKey(private_key []byte) PrivateKey
Creates a PrivateKey instance from private key bytes.
type PublicKey ¶
type PublicKey interface { // Returns the algorithm name used for this public key. GetAlgorithmName() string // Returns the public key encoded as a hex string. AsHex() string // Returns the public key bytes. AsBytes() []byte }
A public key instance. The underlying content is dependent on implementation.
func NewSecp256k1PublicKey ¶
Creates a PublicKey instance from public key bytes.
type Secp256k1Context ¶
type Secp256k1Context struct {
// contains filtered or unexported fields
}
func (*Secp256k1Context) GetAlgorithmName ¶
func (self *Secp256k1Context) GetAlgorithmName() string
Returns the string "secp256k1".
func (*Secp256k1Context) GetPublicKey ¶
func (self *Secp256k1Context) GetPublicKey(private_key PrivateKey) PublicKey
Produces a public key for the given private key.
func (*Secp256k1Context) NewRandomPrivateKey ¶
func (self *Secp256k1Context) NewRandomPrivateKey() PrivateKey
Generates a new random secp256k1 private key.
func (*Secp256k1Context) Sign ¶
func (self *Secp256k1Context) Sign(message []byte, private_key PrivateKey) []byte
Sign uses the given private key to calculate a signature for the given data. A sha256 hash of the data is first calculated and this is what is actually signed. Returns the signature as bytes using the compact serialization (which is just (r, s)).
func (*Secp256k1Context) Verify ¶
func (self *Secp256k1Context) Verify(signature []byte, message []byte, public_key PublicKey) bool
Verify uses the given public key to verify that the given signature was created from the given data using the associated private key. A sha256 hash of the data is calculated first and this is what is actually used to verify the signature.
type Secp256k1PrivateKey ¶
type Secp256k1PrivateKey struct {
// contains filtered or unexported fields
}
func PemToSecp256k1PrivateKey ¶
func PemToSecp256k1PrivateKey(pem string, password string) (*Secp256k1PrivateKey, error)
PemToSecp256k1PrivateKey converts a PEM string to a private key.
func (*Secp256k1PrivateKey) AsBytes ¶
func (self *Secp256k1PrivateKey) AsBytes() []byte
Returns the bytes of the private key.
func (*Secp256k1PrivateKey) AsHex ¶
func (self *Secp256k1PrivateKey) AsHex() string
Returns the private key as a hex-encoded string.
func (*Secp256k1PrivateKey) GetAlgorithmName ¶
func (self *Secp256k1PrivateKey) GetAlgorithmName() string
Returns the string "secp256k1".
type Secp256k1PublicKey ¶
type Secp256k1PublicKey struct {
// contains filtered or unexported fields
}
func (*Secp256k1PublicKey) AsBytes ¶
func (self *Secp256k1PublicKey) AsBytes() []byte
Returns the bytes of the public key.
func (*Secp256k1PublicKey) AsHex ¶
func (self *Secp256k1PublicKey) AsHex() string
Returns the public key as a hex-encoded string.
func (*Secp256k1PublicKey) GetAlgorithmName ¶
func (self *Secp256k1PublicKey) GetAlgorithmName() string
Returns the string "secp256k1".
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
A convenient wrapper of Context and PrivateKey.
func (*Signer) GetPublicKey ¶
Returns the public key for this Signer instance.