Documentation ¶
Index ¶
- Constants
- func Verify(currencyID byte, data []byte, keyType byte, sig []byte, addr string) error
- type Opts
- type Signer
- type SignerImpl
- func (s *SignerImpl) GetAddr(ctx context.Context, currencyID byte) (byte, string, error)
- func (s *SignerImpl) ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)
- func (s *SignerImpl) RetireKey(ctx context.Context, currencyID byte, timeout time.Duration) <-chan error
- func (s *SignerImpl) SetKey(ctx context.Context, currencyID byte, keyType byte, prv []byte) error
- func (s *SignerImpl) Shutdown()
- func (s *SignerImpl) Sign(ctx context.Context, currencyID byte, data []byte) (byte, []byte, error)
- func (s *SignerImpl) StopRetire(ctx context.Context, currencyID byte) error
Constants ¶
const (
FIL = byte(1)
)
const (
SECP256K1 = byte(1)
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Opts ¶
type Opts struct { // The datastore path of the signer. Path string }
Opts is the options for the signer.
type Signer ¶
type Signer interface { // SetKey is used to set a private key for a given currency id. It will return error if there is // an existing key already associated with the given currency id. // // @input - context, currency id, key type, private key. // // @output - error. SetKey(ctx context.Context, currencyID byte, keyType byte, prv []byte) error // GetAddr is used to obtain the key type and the address derived from the private key associated // with the given currency id. // // @input - context, currency id. // // @output - key type, address, error. GetAddr(ctx context.Context, currencyID byte) (byte, string, error) // Sign is used to sign given data with the private key associated with given currency id. // // @input - context, currency id, data. // // @output - signature type, signature, error. Sign(ctx context.Context, currencyID byte, data []byte) (byte, []byte, error) // RetireKey is used to retire a key for a given currency id. If within timeout the key is touched // it will return error. // // @input - context, currency id, timeout. // // @output - error channel out. RetireKey(ctx context.Context, currencyID byte, timeout time.Duration) <-chan error // StopRetire is used to stop retiring a key for a given currency id. // // @input - context, currency id. // // @output - error. StopRetire(ctx context.Context, currencyID byte) error // ListCurrencyIDs lists all currencies. // // @input - context. // // @output - currency chan out, error chan out. ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error) }
Signer is the interface for a secured signing tool. It can save one key for a given currency id. The key is used for signing offers and for transacting on chain.
type SignerImpl ¶
type SignerImpl struct {
// contains filtered or unexported fields
}
SignerImpl is the implementation of the Signer interface.
func NewSignerImpl ¶
func NewSignerImpl(ctx context.Context, opts Opts) (*SignerImpl, error)
NewSignerImpl creates a new Signer.
@input - context, options.
@output - signer, error.
func (*SignerImpl) GetAddr ¶
GetAddr is used to obtain the key type and the address derived from the private key associated with the given currency id.
@input - context, currency id.
@output - key type, address, error.
func (*SignerImpl) ListCurrencyIDs ¶
func (s *SignerImpl) ListCurrencyIDs(ctx context.Context) (<-chan byte, <-chan error)
ListCurrencyIDs lists all currencies.
@input - context.
@output - currency chan out, error chan out.
func (*SignerImpl) RetireKey ¶
func (s *SignerImpl) RetireKey(ctx context.Context, currencyID byte, timeout time.Duration) <-chan error
RetireKey is used to retire a key for a given currency id. If within timeout the key is touched it will return error.
@input - context, currency id, timeout.
@output - error channel out.
func (*SignerImpl) SetKey ¶
SetKey is used to set a private key for a given currency id. It will return error if there is an existing key already associated with the given currency id.
@input - context, currency id, key type, private key.
@output - error.
func (*SignerImpl) Shutdown ¶
func (s *SignerImpl) Shutdown()
Shutdown safely shuts down the component.
func (*SignerImpl) Sign ¶
Sign is used to sign given data with the private key associated with given currency id.
@input - context, currency id, data.
@output - key type, signature, error.
func (*SignerImpl) StopRetire ¶
func (s *SignerImpl) StopRetire(ctx context.Context, currencyID byte) error
StopRetire is used to stop retiring a key for a given currency id.
@input - context, currency id.
@output - error.