crypto

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2020 License: LGPL-3.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
const (
	KeySize      = 32
	EKeySize     = 33
	ResponseSize = 32
)

Variables

This section is empty.

Functions

func SetEKeyFactory added in v0.2.1

func SetEKeyFactory(f EKeyFactory)

func SetHashFunc added in v0.2.1

func SetHashFunc(h HashFunc)

func SetKeyFactory added in v0.2.1

func SetKeyFactory(f KeyFactory)

Types

type Commitment added in v0.2.1

type Commitment Key

type CosiSignature

type CosiSignature struct {
	Signatures    []Signature `json:"signatures"`
	Mask          uint64      `json:"mask"`
	SignatureMask uint64      `json:"-" msgpack:"-"`
}

func CosiAggregateCommitments added in v0.2.1

func CosiAggregateCommitments(commitments map[int]*Commitment) (*CosiSignature, error)

func (*CosiSignature) AggregateSignature added in v0.2.1

func (c *CosiSignature) AggregateSignature(node int, sig *Signature) error

func (*CosiSignature) Challenge

func (c *CosiSignature) Challenge(allPublics []PublicKey, message []byte) ([32]byte, error)

func (*CosiSignature) DumpSignatureResponse added in v0.2.1

func (c *CosiSignature) DumpSignatureResponse(sig *Signature) *Response

func (CosiSignature) Dumps added in v0.2.1

func (c CosiSignature) Dumps() []byte

func (*CosiSignature) FullVerify

func (c *CosiSignature) FullVerify(publics []PublicKey, threshold int, message []byte) bool

func (*CosiSignature) KeyIndex added in v0.2.1

func (c *CosiSignature) KeyIndex(node int) int

func (*CosiSignature) Keys

func (c *CosiSignature) Keys() []int

func (*CosiSignature) LoadResponseSignature added in v0.2.1

func (c *CosiSignature) LoadResponseSignature(commitment *Commitment, response *Response) *Signature

func (*CosiSignature) Loads added in v0.2.1

func (c *CosiSignature) Loads(data []byte) (rest []byte, err error)

func (*CosiSignature) Mark

func (c *CosiSignature) Mark(i int) error

func (*CosiSignature) MarkSignature added in v0.2.1

func (c *CosiSignature) MarkSignature(i int) error

func (*CosiSignature) SignatureAggregated added in v0.2.1

func (c *CosiSignature) SignatureAggregated(i int) bool

func (CosiSignature) String

func (c CosiSignature) String() string

func (*CosiSignature) ThresholdVerify

func (c *CosiSignature) ThresholdVerify(threshold int) bool

type EKey added in v0.2.1

type EKey [EKeySize]byte

func EKeyFromString added in v0.2.1

func EKeyFromString(s string) (*EKey, error)

func (EKey) AsPrivateKey added in v0.2.1

func (k EKey) AsPrivateKey() (EPrivateKey, error)

func (EKey) AsPublicKey added in v0.2.1

func (k EKey) AsPublicKey() (EPublicKey, error)

func (EKey) MarshalJSON added in v0.2.1

func (k EKey) MarshalJSON() ([]byte, error)

func (*EKey) Scan added in v0.2.1

func (k *EKey) Scan(value interface{}) error

Scan implements the sql.Scanner interface for database deserialization.

func (EKey) String added in v0.2.1

func (k EKey) String() string

func (*EKey) UnmarshalJSON added in v0.2.1

func (k *EKey) UnmarshalJSON(b []byte) error

func (EKey) Value added in v0.2.1

func (k EKey) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database serialization.

type EKeyFactory added in v0.2.1

type EKeyFactory interface {
	EPrivateKeyFromSeed(seed []byte) (EPrivateKey, error)
	EPrivateKeyFromKey(k EKey) (EPrivateKey, error)
	EPublicKeyFromKey(k EKey) (EPublicKey, error)
}

type EPrivateKey added in v0.2.1

type EPrivateKey interface {
	String() string
	EKey() EKey
	EPublic() EPublicKey
	Sign(message []byte) (*Signature, error)
	Decrypt(encryptedText []byte) ([]byte, error)
}

func EPrivateKeyFromSeed added in v0.2.1

func EPrivateKeyFromSeed(seed []byte) (EPrivateKey, error)

func NewEPrivateKey added in v0.2.1

func NewEPrivateKey(randReader io.Reader) EPrivateKey

type EPublicKey added in v0.2.1

type EPublicKey interface {
	String() string
	EKey() EKey
	Verify(message []byte, sig *Signature) bool
	Encrypt(plainText []byte) ([]byte, error)
}

type Hash

type Hash [32]byte

func HashFromString

func HashFromString(src string) (Hash, error)

func NewHash

func NewHash(data []byte) Hash

func (Hash) ForNetwork

func (h Hash) ForNetwork(net Hash) Hash

func (Hash) HasValue

func (h Hash) HasValue() bool

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

func (*Hash) Scan added in v0.0.7

func (h *Hash) Scan(value interface{}) (err error)

Scan implements the sql.Scanner interface for database deserialization.

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(b []byte) error

func (Hash) Value added in v0.0.7

func (h Hash) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database serialization.

type HashFunc added in v0.2.1

type HashFunc func(data []byte) (digest [32]byte)

type Key

type Key [KeySize]byte

func KeyFromString

func KeyFromString(s string) (*Key, error)

func (Key) AsPrivateKey added in v0.2.1

func (k Key) AsPrivateKey() (PrivateKey, error)

func (Key) AsPublicKey added in v0.2.1

func (k Key) AsPublicKey() (PublicKey, error)

func (Key) HasValue

func (k Key) HasValue() bool

func (Key) MarshalJSON

func (k Key) MarshalJSON() ([]byte, error)

func (*Key) Scan added in v0.0.7

func (k *Key) Scan(value interface{}) error

Scan implements the sql.Scanner interface for database deserialization.

func (Key) String

func (k Key) String() string

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(b []byte) error

func (Key) Value added in v0.0.7

func (k Key) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database serialization.

type KeyFactory added in v0.2.1

type KeyFactory interface {
	PrivateKeyFromSeed(seed []byte) (PrivateKey, error)
	PrivateKeyFromKey(k Key) (PrivateKey, error)
	PublicKeyFromKey(k Key) (PublicKey, error)

	// cosi
	CosiDumps(cosi *CosiSignature) (data []byte)
	CosiLoads(cosi *CosiSignature, data []byte) (rest []byte, err error)
	CosiAggregateCommitments(cosi *CosiSignature, commitments map[int]*Commitment) error
	CosiChallenge(cosi *CosiSignature, publics map[int]PublicKey, message []byte) ([32]byte, error)
	CosiAggregateSignature(cosi *CosiSignature, keyIndex int, sig *Signature) error
	CosiFullVerify(publics map[int]PublicKey, message []byte, sig *CosiSignature) bool

	UpdateSignatureCommitment(sig *Signature, commitment *Commitment)
	DumpSignatureResponse(sig *Signature) *Response
	LoadResponseSignature(cosi *CosiSignature, commitment *Commitment, response *Response) *Signature
}

type PrivateKey added in v0.2.1

type PrivateKey interface {
	String() string
	Key() Key
	Public() PublicKey
	AddPrivate(p PrivateKey) PrivateKey
	ScalarMult(pub PublicKey) PublicKey
	Sign(message []byte) (*Signature, error)
	SignWithChallenge(random PrivateKey, message []byte, hReduced [32]byte) (*Signature, error)
}

func DeriveGhostPrivateKey

func DeriveGhostPrivateKey(R PublicKey, a, b PrivateKey, outputIndex uint64) PrivateKey

func NewPrivateKey added in v0.2.1

func NewPrivateKey(randReader io.Reader) PrivateKey

func PrivateKeyFromSeed added in v0.2.1

func PrivateKeyFromSeed(seed []byte) PrivateKey

func PrivateKeyFromString added in v0.2.1

func PrivateKeyFromString(s string) (PrivateKey, error)

type PublicKey added in v0.2.1

type PublicKey interface {
	String() string
	Key() Key
	AddPublic(p PublicKey) PublicKey
	SubPublic(p PublicKey) PublicKey
	ScalarHash(outputIndex uint64) PrivateKey
	DeterministicHashDerive() PrivateKey
	Challenge(R PublicKey, message []byte) [32]byte
	Verify(message []byte, sig *Signature) bool
	VerifyWithChallenge(message []byte, sig *Signature, hReduced [32]byte) bool
}

func DeriveGhostPublicKey

func DeriveGhostPublicKey(r PrivateKey, A, B PublicKey, outputIndex uint64) PublicKey

func PublicKeyFromString added in v0.2.1

func PublicKeyFromString(s string) (PublicKey, error)

func ViewGhostOutputKey

func ViewGhostOutputKey(R, P PublicKey, a PrivateKey, outputIndex uint64) PublicKey

type Response added in v0.2.1

type Response [ResponseSize]byte

type Signature

type Signature [64]byte

func (Signature) MarshalJSON

func (s Signature) MarshalJSON() ([]byte, error)

func (Signature) String

func (s Signature) String() string

func (*Signature) UnmarshalJSON

func (s *Signature) UnmarshalJSON(b []byte) error

func (*Signature) WithCommitment added in v0.2.1

func (s *Signature) WithCommitment(commitment *Commitment)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL