Documentation ¶
Overview ¶
Package signing is from https://github.com/hyperledger/sawtooth-sdk-go
Index ¶
- func SHA512(input []byte) string
- func Verify(signature, message, public []byte) bool
- func VerifyHex(signature, message, publicKey string) (bool, error)
- func VerifyMsg(signature, message, publicKey string) (bool, error)
- type Context
- type CryptoFactory
- type PrivateKey
- type PublicKey
- type Secp256k1Context
- func (ctx *Secp256k1Context) GetAlgorithmName() string
- func (ctx *Secp256k1Context) GetPublicKey(privateKey PrivateKey) PublicKey
- func (ctx *Secp256k1Context) NewRandomPrivateKey() PrivateKey
- func (ctx *Secp256k1Context) Sign(message []byte, privateKey PrivateKey) []byte
- func (ctx *Secp256k1Context) Verify(signature []byte, message []byte, publicKey PublicKey) bool
- type Secp256k1PrivateKey
- type Secp256k1PublicKey
- type Signer
- func GenerateSigner() *Signer
- func GenerateSignerFromCode(code string) *Signer
- func LoadSignerFromBytes(raw []byte) *Signer
- func LoadSignerFromFile(file string) (*Signer, error)
- func LoadSignerFromHex(hexstr string) (*Signer, error)
- func MustSigner(s *Signer, err error) *Signer
- func NewSigner(key PrivateKey) *Signer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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(privateKey PrivateKey) PublicKey // Sign uses the given private key to calculate a signature for // the given data. Sign(message []byte, privateKey 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, publicKey PublicKey) bool }
Context A context for a cryptographic signing algorithm.
func CreateContext ¶
CreateContext Returns a Context instance by name.
func NewSecp256k1Context ¶
func NewSecp256k1Context() Context
NewSecp256k1Context returns a new secp256k1 context.
type CryptoFactory ¶
type CryptoFactory struct {
// contains filtered or unexported fields
}
CryptoFactory A factory for generating Signers.
func NewCryptoFactory ¶
func NewCryptoFactory(context Context) *CryptoFactory
NewCryptoFactory Creates a factory for generating Signers.
func (*CryptoFactory) GetContext ¶
func (factory *CryptoFactory) GetContext() Context
GetContext returns the context that backs this Factory instance.
func (*CryptoFactory) NewSigner ¶
func (factory *CryptoFactory) NewSigner(privateKey PrivateKey) *Signer
NewSigner 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 }
PrivateKey A private key instance. The underlying content is dependent on implementation.
func GeneratePrivKeyFromCode ¶
func GeneratePrivKeyFromCode(code string) PrivateKey
GeneratePrivKeyFromCode returns a private key from some code.
func NewSecp256k1PrivateKey ¶
func NewSecp256k1PrivateKey(privateKey []byte) PrivateKey
NewSecp256k1PrivateKey creates a PrivateKey instance from private key bytes.
func RandomPrivateKey ¶
func RandomPrivateKey() PrivateKey
RandomPrivateKey returns a random private key.
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 }
PublicKey A public key instance. The underlying content is dependent on implementation.
func NewSecp256k1PublicKey ¶
NewSecp256k1PublicKey creates a PublicKey instance from public key bytes.
type Secp256k1Context ¶
type Secp256k1Context struct {
// contains filtered or unexported fields
}
Secp256k1Context implements signing.Context with KoblitzCurve.
func (*Secp256k1Context) GetAlgorithmName ¶
func (ctx *Secp256k1Context) GetAlgorithmName() string
GetAlgorithmName returns the string "secp256k1".
func (*Secp256k1Context) GetPublicKey ¶
func (ctx *Secp256k1Context) GetPublicKey(privateKey PrivateKey) PublicKey
GetPublicKey produces a public key for the given private key.
func (*Secp256k1Context) NewRandomPrivateKey ¶
func (ctx *Secp256k1Context) NewRandomPrivateKey() PrivateKey
NewRandomPrivateKey generates a new random secp256k1 private key.
func (*Secp256k1Context) Sign ¶
func (ctx *Secp256k1Context) Sign(message []byte, privateKey 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 (ctx *Secp256k1Context) Verify(signature []byte, message []byte, publicKey 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
}
Secp256k1PrivateKey represents a secp256k1 private key.
func (*Secp256k1PrivateKey) AsBytes ¶
func (key *Secp256k1PrivateKey) AsBytes() []byte
AsBytes returns the bytes of the private key.
func (*Secp256k1PrivateKey) AsHex ¶
func (key *Secp256k1PrivateKey) AsHex() string
AsHex returns the private key as a hex-encoded string.
func (*Secp256k1PrivateKey) GetAlgorithmName ¶
func (key *Secp256k1PrivateKey) GetAlgorithmName() string
GetAlgorithmName returns the string "secp256k1".
type Secp256k1PublicKey ¶
type Secp256k1PublicKey struct {
// contains filtered or unexported fields
}
Secp256k1PublicKey represents secp256k1 public key.
func (*Secp256k1PublicKey) AsBytes ¶
func (key *Secp256k1PublicKey) AsBytes() []byte
AsBytes returns the bytes of the public key.
func (*Secp256k1PublicKey) AsHex ¶
func (key *Secp256k1PublicKey) AsHex() string
AsHex returns the public key as a hex-encoded string.
func (*Secp256k1PublicKey) GetAlgorithmName ¶
func (key *Secp256k1PublicKey) GetAlgorithmName() string
GetAlgorithmName returns the string "secp256k1".
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer A convenient wrapper of Context and PrivateKey.
func GenerateSigner ¶
func GenerateSigner() *Signer
GenerateSigner returns a signer with a random private key.
func GenerateSignerFromCode ¶
GenerateSignerFromCode returns a signer from some code.
func LoadSignerFromBytes ¶
LoadSignerFromBytes returns a signer loading from bytes of private key.
func LoadSignerFromFile ¶
LoadSignerFromFile returns signer from private key file.
func LoadSignerFromHex ¶
LoadSignerFromHex returns a signer from hex string.
func NewSigner ¶
func NewSigner(key PrivateKey) *Signer
NewSigner returns a signer from private key.
func (*Signer) GetPublicKey ¶
GetPublicKey returns the public key for this Signer instance.