ecc

package
v0.0.0-...-156c265 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prime

func Prime() *big.Int

Types

type FieldElement

type FieldElement struct {
	Num   *big.Int
	Prime *big.Int
	Err   error
}

func NewFieldElement

func NewFieldElement(num *big.Int, prime *big.Int) (*FieldElement, error)

func NewFieldElementFromInt64

func NewFieldElementFromInt64(num int64, prime int64) (*FieldElement, error)

func (*FieldElement) Add

func (*FieldElement) Calc

func (elm *FieldElement) Calc() (FieldInterface, error)

func (*FieldElement) Copy

func (elm *FieldElement) Copy() FieldInterface

func (*FieldElement) Div

func (*FieldElement) Eq

func (elm *FieldElement) Eq(other FieldInterface) bool

func (*FieldElement) Mul

func (*FieldElement) Ne

func (elm *FieldElement) Ne(other FieldInterface) bool

func (*FieldElement) Pow

func (elm *FieldElement) Pow(n FieldInterface, exp *big.Int) FieldInterface

func (*FieldElement) RMul

func (elm *FieldElement) RMul(n FieldInterface, coef *big.Int) FieldInterface

func (*FieldElement) String

func (elm *FieldElement) String() string

func (*FieldElement) Sub

type Point

func (*Point) Add

func (p *Point) Add(p1, p2 *Point) *Point

func (*Point) Calc

func (p *Point) Calc() (*Point, error)

func (*Point) Eq

func (p *Point) Eq(other *Point) bool

func (*Point) Ne

func (p *Point) Ne(other *Point) bool

func (*Point) RMul

func (p *Point) RMul(r *Point, n *big.Int) *Point

func (*Point) String

func (p *Point) String() string

type PrivateKey

type PrivateKey struct {
	Secret *big.Int
	Point  *S256Point
}

func NewPrivateKey

func NewPrivateKey(secret *big.Int) *PrivateKey

func (*PrivateKey) Hex

func (key *PrivateKey) Hex() string

func (*PrivateKey) Sign

func (key *PrivateKey) Sign(z *big.Int) *Signature

func (*PrivateKey) Wif

func (key *PrivateKey) Wif(compress, testnet bool) string

type S256Field

type S256Field struct {
	*FieldElement
}

func NewS256Field

func NewS256Field(num *big.Int) (*S256Field, error)

func (*S256Field) Sqrt

func (f *S256Field) Sqrt() *S256Field

func (*S256Field) String

func (f *S256Field) String() string

type S256Point

type S256Point struct {
	*Point
}
var (
	G *S256Point

	N *big.Int
)

func NewS256Point

func NewS256Point(x, y *S256Field) (*S256Point, error)

func NewS256PointFromBigInt

func NewS256PointFromBigInt(x, y *big.Int) (*S256Point, error)

func ParseS256Point

func ParseS256Point(b []byte) (*S256Point, error)

func (*S256Point) Add

func (p *S256Point) Add(p1, p2 *S256Point) *S256Point

func (*S256Point) Address

func (p *S256Point) Address(compress, testnet bool) string

func (*S256Point) Hash160

func (p *S256Point) Hash160(compress bool) []byte

func (*S256Point) RMul

func (p *S256Point) RMul(r *S256Point, coef *big.Int) *S256Point

func (*S256Point) Sec

func (p *S256Point) Sec(compress bool) []byte

func (*S256Point) Verify

func (p *S256Point) Verify(z *big.Int, sig *Signature) bool

type Signature

type Signature struct {
	R *big.Int
	S *big.Int
}

func NewSignature

func NewSignature(r, s *big.Int) *Signature

func (*Signature) Der

func (s *Signature) Der() []byte

func (*Signature) String

func (s *Signature) String() string

Jump to

Keyboard shortcuts

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