Documentation ¶
Index ¶
- Constants
- func ErrPublicKeyCannotBeNil() error
- func ErrSignableCannotBeNil() error
- func ErrSignatureCannotBeNil() error
- func GenerateKeyPair(algo Algo) (PrivateKey, PublicKey, error)
- type Algo
- type Algos
- type Hash224
- type Hash256
- type Hasher
- type PrivateKey
- type PublicKey
- type Signable
- type SignableStub
- type Signature
- type Signer
Constants ¶
const ( ErrPublicKeyCannotBeNilMsg = "public key cannot be nil" ErrSignableCannotBeNilMsg = "signable cannot be nil" ErrSignatureCannotBeNilMsg = "signature cannot be nil" )
const ( // Hash224Size defines size in bytes. Hash224Size = sha256.Size224 )
const ( // Hash256Size defines size in bytes. Hash256Size = sha256.Size )
Variables ¶
This section is empty.
Functions ¶
func ErrPublicKeyCannotBeNil ¶
func ErrPublicKeyCannotBeNil() error
func ErrSignableCannotBeNil ¶
func ErrSignableCannotBeNil() error
func ErrSignatureCannotBeNil ¶
func ErrSignatureCannotBeNil() error
func GenerateKeyPair ¶
func GenerateKeyPair(algo Algo) (PrivateKey, PublicKey, error)
GenerateKeyPair returns generated private and public keys.
Types ¶
type Algo ¶
type Algo int
Algo supported algo enum type.
const ( // UNKNOWN is unknown algo type. UNKNOWN Algo = -1 // RSA is a copy for the supported RSA key type // from libp2p crypto package to avoid import it in your project. RSA Algo = cc.RSA // Ed25519 is a copy for the supported Ed25519 key type // from libp2p crypto package to avoid import it in your project. Ed25519 Algo = cc.Ed25519 // Secp256k1 is a copy for the supported Secp256k1 key type // from libp2p crypto package to avoid import it in your project. Secp256k1 Algo = cc.Secp256k1 // ECDSA is a copy for the supported ECDSA key type // from libp2p crypto package to avoid import it in your project. ECDSA Algo = cc.ECDSA )
type Algos ¶
Algos describes list of supported algos key is algo name string and val is algo enum type.
type Hash224 ¶
type Hash224 [Hash224Size]byte
Hash224 represents hashed blob with Hash224Size bytes length.
func NewHash224 ¶
NewHash224 makes initialized Hash224. Initial hash calculates SHA224 checksum over SHA256 checksum over specified bytes.
func StrToHash224 ¶
StrToHash224 makes initialized Hash224. Initial hash calculates SHA224 checksum SHA256 checksum over specified strings.
type Hash256 ¶
type Hash256 [Hash256Size]byte
Hash256 represents hashed blob with Hash256Size bytes length.
func NewHash256 ¶
NewHash256 makes initialized Hash256. Initial hash calculates SHA256 checksum over specified bytes.
func StrToHash256 ¶
StrToHash256 makes initialized Hash256. Initial hash calculates SHA256 checksum over specified strings.
type PrivateKey ¶
type PrivateKey interface { // Embedded Signer interface. Signer // Algo returns the private key Algo. Algo() Algo // PublicKey returns the public key paired with this private key. PublicKey() PublicKey }
PrivateKey represents private key interface.
func NewPrivateKey ¶
func NewPrivateKey(ki cc.PrivKey) PrivateKey
NewPrivateKey returns PrivateKey interface.
type PublicKey ¶
type PublicKey interface { // Embedded equaler interface. equal.Equaler // Algo returns the public key Algo. Algo() Algo // Base64 encodes a public key to base64 string. Base64() (string, error) // Decode sets decoded data from protobuf message. Decode(*pb.PublicKey) error // Encode converts data to protobuf message. Encode() (*pb.PublicKey, error) // Equals checks whether two public keys are the same. Equals(PublicKey) bool // Hash224 calculates SHA224 checksum // over SHA256 checksum over public key value. Hash224() (Hash224, error) // Marshal implements marshaler interface for types // that can marshal themselves into bytes. Marshal() ([]byte, error) // MarshalJSON implements marshaler interface for types // that can marshal themselves into valid JSON. MarshalJSON() ([]byte, error) // String implements stringer interface for types // that can converts themselves to string format. String() string // Unmarshal implements unmarshaler interface for types // that can unmarshal bytes of themselves. Unmarshal([]byte) error // UnmarshalJSON implements unmarshaler interface for types // that can unmarshal a JSON description of themselves. UnmarshalJSON([]byte) error // Verify verifies signable object. Verify(Signable) (bool, error) }
PublicKey represents public key interface.
func DecodePublicKey ¶
DecodePublicKey decodes a protobuf encoded message.
func NewPublicKey ¶
NewPublicKey returns PublicKey interface.
type Signable ¶
type Signable interface { // Embedded Hasher interface. Hasher // GetSignature returns the signature. GetSignature() Signature // SetSignature sets the sign to the particular property. SetSignature(Signature) // SetPublicKey sets the public key to the particular property. SetPublicKey(PublicKey) }
Signable represents interface for signable types. It provides ability to calculate a hash func and set the signature as property.
func NewSignable ¶
NewSignable constructs Signable interface over given bytes.
type SignableStub ¶
SignableStub implements Signable interface.
func (*SignableStub) GetSignature ¶
func (c *SignableStub) GetSignature() Signature
GetSignature implements Signable.GetSignature method of interface.
func (*SignableStub) Hash ¶
func (c *SignableStub) Hash() (Hash256, error)
Hash implements Hasher.Hash method of interface.
func (*SignableStub) SetPublicKey ¶
func (c *SignableStub) SetPublicKey(pbKey PublicKey)
SetPublicKey implements Signable.SetPublicKey method of interface.
func (*SignableStub) SetSignature ¶
func (c *SignableStub) SetSignature(sign Signature)
SetSignature implements Signable.SetSignature method of interface.
type Signature ¶
type Signature interface { // Embedded equaler interface. equal.Equaler // Decode sets decoded data from protobuf message. Decode(*pb.Signature) // Encode converts data to protobuf message. Encode() *pb.Signature // Equals checks whether two signatures are the same. Equals(Signature) bool // Marshal implements marshaler interface for types // that can marshal themselves into bytes. Marshal() ([]byte, error) // MarshalJSON implements marshaler interface for types // that can marshal themselves into valid JSON. MarshalJSON() ([]byte, error) // String implements stringer interface for types // that can converts themselves to string format. String() string // Unmarshal implements unmarshaler interface for types // that can unmarshal bytes of themselves. Unmarshal(b []byte) error // UnmarshalJSON implements unmarshaler interface for types // that can unmarshal a JSON description of themselves. UnmarshalJSON([]byte) error }
Signature represents signature interface.
func DecodeSignature ¶
DecodeSignature decodes a protobuf encoded message.
func NewSignature ¶
NewSignature returns Signature interface.