Documentation ¶
Index ¶
- Constants
- type Curve
- type Field
- func (z *Field) Add(a *Field) *Field
- func (z *Field) AddU64(a uint64) *Field
- func (z *Field) CondAssign(yes saferith.Choice, x *Field) *Field
- func (z *Field) CondNegate(yes saferith.Choice) *Field
- func (z *Field) Eq(x *Field) saferith.Choice
- func (z *Field) EqZero() saferith.Choice
- func (z *Field) HasSqrt() saferith.Choice
- func (z *Field) Invert() *Field
- func (z *Field) IsEven() saferith.Choice
- func (z *Field) MarshalBinary() ([]byte, error)
- func (z *Field) Mul(a *Field) *Field
- func (z *Field) MulU64(a uint64) *Field
- func (z *Field) Negate() *Field
- func (z *Field) Set(x *Field) *Field
- func (z *Field) SetUint64(x uint64) *Field
- func (z *Field) Sqrt() *Field
- func (z *Field) Square() *Field
- func (z *Field) String() string
- func (z *Field) Sub(a *Field) *Field
- func (z *Field) UnmarshalBinary(data []byte) error
- type Point
- func (p1 *Point) Add(other kyokusen.Point) kyokusen.Point
- func (p *Point) CondAssign(yes saferith.Choice, other *Point) *Point
- func (*Point) Curve() kyokusen.Curve
- func (p1 *Point) Equal(other kyokusen.Point) bool
- func (p *Point) IsIdentity() bool
- func (p *Point) MarshalBinary() ([]byte, error)
- func (p *Point) Negate() kyokusen.Point
- func (p *Point) String() string
- func (p *Point) Sub(other kyokusen.Point) kyokusen.Point
- func (p *Point) UnmarshalBinary(data []byte) error
- func (*Point) XScalar() kyokusen.Scalar
- type Scalar
- func (s *Scalar) Act(other kyokusen.Point) kyokusen.Point
- func (s *Scalar) ActOnBase() kyokusen.Point
- func (s1 *Scalar) Add(other kyokusen.Scalar) kyokusen.Scalar
- func (s *Scalar) Curve() kyokusen.Curve
- func (s1 *Scalar) Equal(other kyokusen.Scalar) bool
- func (s1 *Scalar) Invert() kyokusen.Scalar
- func (s1 *Scalar) IsZero() bool
- func (s *Scalar) MarshalBinary() ([]byte, error)
- func (s1 *Scalar) Mul(other kyokusen.Scalar) kyokusen.Scalar
- func (s1 *Scalar) Negate() kyokusen.Scalar
- func (s1 *Scalar) Set(other kyokusen.Scalar) kyokusen.Scalar
- func (s1 *Scalar) SetNat(other *saferith.Nat) kyokusen.Scalar
- func (s *Scalar) String() string
- func (s1 *Scalar) Sub(other kyokusen.Scalar) kyokusen.Scalar
- func (s *Scalar) UnmarshalBinary(data []byte) error
Constants ¶
const FieldBytes = 32
FieldBytes is the number of bytes in the field.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Curve ¶
type Curve struct{}
Curve represents the secp256k1 curve, implementing the kyokusen.Curve interface.
func (Curve) NewBasePoint ¶
func (Curve) SafeScalarBytes ¶
func (Curve) ScalarBits ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field represents an element in the prime field used by secp256k1.
This field is used later to implement point operations on the curve.
func NewField ¶
func NewField() *Field
NewField creates a new field element, with its value set to 0.
func (*Field) CondAssign ¶
CondAssign sets z <- x, only if yes = 1, in constant-time.
func (*Field) CondNegate ¶
CondNegate sets z <- -z, only if yes = 1, in constant-time.
func (*Field) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
This encodes the field element as big endian bytes. The result will always occupy 32 bytes of space.
func (*Field) Sqrt ¶
Sqrt calculates z <- sqrt(z), if such a value exists. Otherwise, the result is undefined.
func (*Field) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
This expects exactly 32 Big Endian bytes, and will also return an error if the resulting value is >= the field modulus.
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point represents a point on the secp256k1 curve.
func (*Point) CondAssign ¶
CondAssign conditionally modifies the contents of a point.
func (*Point) IsIdentity ¶
func (*Point) MarshalBinary ¶
MarshalBinary marshals a Secp256k1 point in the same way as Bitcoin does.
The point at infinity can't be marshalled.
func (*Point) UnmarshalBinary ¶
UnmarshalBinary unmarshals a Secp256k1 point from Bitcoin's encoding.
type Scalar ¶
type Scalar struct {
// contains filtered or unexported fields
}
func (*Scalar) MarshalBinary ¶
MarshalBinary returns the contents of this scalar as Big Endian bytes.
func (*Scalar) UnmarshalBinary ¶
UnmarshalBinary deserializes Big Endian bytes into this scalar.