Documentation
¶
Overview ¶
Package p256 implements the NIST P-256 curve, field, scalar, and point types.
See README.md for details.
Index ¶
- Constants
- type BaseField
- func (*BaseField) BitLen() int
- func (*BaseField) Characteristic() cardinal.Cardinal
- func (*BaseField) ElementSize() int
- func (f *BaseField) FromBytesBEReduce(input []byte) (*BaseFieldElement, error)
- func (*BaseField) Hash(bytes []byte) (*BaseFieldElement, error)
- func (*BaseField) Name() string
- func (*BaseField) Order() cardinal.Cardinal
- func (*BaseField) WideElementSize() int
- type BaseFieldElement
- func (fe *BaseFieldElement) MarshalBinary() (data []byte, err error)
- func (fe *BaseFieldElement) MarshalCBOR() ([]byte, error)
- func (*BaseFieldElement) Structure() algebra.Structure[*BaseFieldElement]
- func (fe *BaseFieldElement) UnmarshalBinary(data []byte) error
- func (fe *BaseFieldElement) UnmarshalCBOR(data []byte) error
- type Curve
- func (*Curve) BaseField() algebra.FiniteField[*BaseFieldElement]
- func (*Curve) BaseStructure() algebra.Structure[*BaseFieldElement]
- func (*Curve) Cofactor() cardinal.Cardinal
- func (*Curve) ElementSize() int
- func (*Curve) FromAffine(x, y *BaseFieldElement) (*Point, error)
- func (*Curve) FromAffineX(x *BaseFieldElement, b bool) (*Point, error)
- func (c *Curve) FromBytes(input []byte) (*Point, error)
- func (c *Curve) FromCompressed(input []byte) (*Point, error)
- func (c *Curve) FromUncompressed(input []byte) (*Point, error)
- func (c *Curve) FromWideBytes(input []byte) (*Point, error)
- func (c *Curve) Hash(bytes []byte) (*Point, error)
- func (*Curve) HashWithDst(dst string, bytes []byte) (*Point, error)
- func (*Curve) MultiScalarMul(scalars []*Scalar, points []*Point) (*Point, error)
- func (c *Curve) MultiScalarOp(scalars []*Scalar, points []*Point) (*Point, error)
- func (*Curve) Name() string
- func (*Curve) Order() cardinal.Cardinal
- func (c *Curve) ScalarBaseMul(sc *Scalar) *Point
- func (c *Curve) ScalarBaseOp(sc *Scalar) *Point
- func (*Curve) ScalarField() algebra.PrimeField[*Scalar]
- func (*Curve) ScalarRing() algebra.ZModLike[*Scalar]
- func (*Curve) ScalarStructure() algebra.Structure[*Scalar]
- func (*Curve) ToElliptic() elliptic.Curve
- func (*Curve) WideElementSize() int
- type Point
- func (p *Point) AffineX() (*BaseFieldElement, error)
- func (p *Point) AffineY() (*BaseFieldElement, error)
- func (p *Point) Bytes() []byte
- func (p *Point) HashCode() base.HashCode
- func (*Point) IsTorsionFree() bool
- func (p *Point) MarshalBinary() (data []byte, err error)
- func (p *Point) MarshalCBOR() ([]byte, error)
- func (p *Point) ScalarMul(actor *Scalar) *Point
- func (p *Point) ScalarOp(sc *Scalar) *Point
- func (p *Point) String() string
- func (*Point) Structure() algebra.Structure[*Point]
- func (p *Point) ToCompressed() []byte
- func (p *Point) ToUncompressed() []byte
- func (p *Point) UnmarshalBinary(data []byte) error
- func (p *Point) UnmarshalCBOR(data []byte) error
- type Scalar
- type ScalarField
- func (*ScalarField) BitLen() int
- func (*ScalarField) Characteristic() cardinal.Cardinal
- func (*ScalarField) ElementSize() int
- func (f *ScalarField) FromBytesBEReduce(input []byte) (*Scalar, error)
- func (*ScalarField) Hash(bytes []byte) (*Scalar, error)
- func (*ScalarField) Name() string
- func (*ScalarField) Order() cardinal.Cardinal
- func (*ScalarField) WideElementSize() int
Constants ¶
const ( // CurveName is the curve name. CurveName = "P256" // Hash2CurveSuite is the hash-to-curve suite string. Hash2CurveSuite = "P256_XMD:SHA-256_SSWU_RO_" // Hash2CurveScalarSuite is the hash-to-curve scalar suite string. Hash2CurveScalarSuite = "P256_XMD:SHA-256_SSWU_RO_SC_" )
const (
// BaseFieldName is the base field name.
BaseFieldName = "P256Fp"
)
const (
// ScalarFieldName is the scalar field name.
ScalarFieldName = "P256Fq"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseField ¶
type BaseField struct {
traits.PrimeFieldTrait[*p256Impl.Fp, *BaseFieldElement, BaseFieldElement]
}
BaseField represents the curve base field.
func (*BaseField) Characteristic ¶
Characteristic returns the field characteristic.
func (*BaseField) ElementSize ¶
ElementSize returns the element size in bytes.
func (*BaseField) FromBytesBEReduce ¶
func (f *BaseField) FromBytesBEReduce(input []byte) (*BaseFieldElement, error)
FromBytesBEReduce reduces a big-endian integer into the field.
func (*BaseField) Hash ¶
func (*BaseField) Hash(bytes []byte) (*BaseFieldElement, error)
Hash maps input bytes to an element or point.
func (*BaseField) WideElementSize ¶
WideElementSize returns the wide element size in bytes.
type BaseFieldElement ¶
type BaseFieldElement struct {
traits.PrimeFieldElementTrait[*p256Impl.Fp, p256Impl.Fp, *BaseFieldElement, BaseFieldElement]
}
BaseFieldElement represents an element of the base field.
func (*BaseFieldElement) MarshalBinary ¶
func (fe *BaseFieldElement) MarshalBinary() (data []byte, err error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*BaseFieldElement) MarshalCBOR ¶
func (fe *BaseFieldElement) MarshalCBOR() ([]byte, error)
MarshalCBOR implements cbor.Marshaler.
func (*BaseFieldElement) Structure ¶
func (*BaseFieldElement) Structure() algebra.Structure[*BaseFieldElement]
Structure returns the algebraic structure for the receiver.
func (*BaseFieldElement) UnmarshalBinary ¶
func (fe *BaseFieldElement) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*BaseFieldElement) UnmarshalCBOR ¶
func (fe *BaseFieldElement) UnmarshalCBOR(data []byte) error
UnmarshalCBOR implements cbor.Unmarshaler.
type Curve ¶
Curve represents the elliptic curve group.
func (*Curve) BaseField ¶
func (*Curve) BaseField() algebra.FiniteField[*BaseFieldElement]
BaseField returns the base field.
func (*Curve) BaseStructure ¶
func (*Curve) BaseStructure() algebra.Structure[*BaseFieldElement]
BaseStructure returns the base field structure.
func (*Curve) ElementSize ¶
ElementSize returns the element size in bytes.
func (*Curve) FromAffine ¶
func (*Curve) FromAffine(x, y *BaseFieldElement) (*Point, error)
FromAffine builds a point from affine coordinates.
func (*Curve) FromAffineX ¶
func (*Curve) FromAffineX(x *BaseFieldElement, b bool) (*Point, error)
FromAffineX builds a point from an affine x-coordinate.
func (*Curve) FromCompressed ¶
FromCompressed decodes a compressed point.
func (*Curve) FromUncompressed ¶
FromUncompressed decodes an uncompressed point.
func (*Curve) FromWideBytes ¶
FromWideBytes decodes an element from wide bytes.
func (*Curve) HashWithDst ¶
HashWithDst maps input bytes to a point with a custom DST.
func (*Curve) MultiScalarMul ¶
MultiScalarMul computes a multiscalar multiplication.
func (*Curve) MultiScalarOp ¶
MultiScalarOp computes a multiscalar operation.
func (*Curve) ScalarBaseMul ¶
ScalarBaseMul multiplies the generator by a scalar.
func (*Curve) ScalarBaseOp ¶
ScalarBaseOp adds a scalar multiple of the generator.
func (*Curve) ScalarField ¶
func (*Curve) ScalarField() algebra.PrimeField[*Scalar]
ScalarField returns the scalar field.
func (*Curve) ScalarRing ¶
ScalarRing returns the scalar ring.
func (*Curve) ScalarStructure ¶
ScalarStructure returns the scalar structure.
func (*Curve) ToElliptic ¶
ToElliptic returns the standard library elliptic.Curve adapter.
func (*Curve) WideElementSize ¶
WideElementSize returns the wide element size in bytes.
type Point ¶
type Point struct {
traits.PrimePointTrait[*p256Impl.Fp, *p256Impl.Point, p256Impl.Point, *Point, Point]
}
Point represents a curve point.
func (*Point) AffineX ¶
func (p *Point) AffineX() (*BaseFieldElement, error)
AffineX returns the affine x-coordinate.
func (*Point) AffineY ¶
func (p *Point) AffineY() (*BaseFieldElement, error)
AffineY returns the affine y-coordinate.
func (*Point) IsTorsionFree ¶
IsTorsionFree reports whether the point is torsion-free.
func (*Point) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*Point) MarshalCBOR ¶
MarshalCBOR implements cbor.Marshaler.
func (*Point) ToCompressed ¶
ToCompressed encodes the point in compressed form.
func (*Point) ToUncompressed ¶
ToUncompressed encodes the point in uncompressed form.
func (*Point) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Point) UnmarshalCBOR ¶
UnmarshalCBOR implements cbor.Unmarshaler.
type Scalar ¶
Scalar represents a scalar field element.
func (*Scalar) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*Scalar) MarshalCBOR ¶
MarshalCBOR implements cbor.Marshaler.
func (*Scalar) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Scalar) UnmarshalCBOR ¶
UnmarshalCBOR implements cbor.Unmarshaler.
type ScalarField ¶
ScalarField represents the scalar field.
func NewScalarField ¶
func NewScalarField() *ScalarField
NewScalarField returns the scalar field instance.
func (*ScalarField) BitLen ¶
func (*ScalarField) BitLen() int
BitLen returns the field modulus bit length.
func (*ScalarField) Characteristic ¶
func (*ScalarField) Characteristic() cardinal.Cardinal
Characteristic returns the field characteristic.
func (*ScalarField) ElementSize ¶
func (*ScalarField) ElementSize() int
ElementSize returns the element size in bytes.
func (*ScalarField) FromBytesBEReduce ¶
func (f *ScalarField) FromBytesBEReduce(input []byte) (*Scalar, error)
FromBytesBEReduce reduces a big-endian integer into the field.
func (*ScalarField) Hash ¶
func (*ScalarField) Hash(bytes []byte) (*Scalar, error)
Hash maps input bytes to an element or point.
func (*ScalarField) Name ¶
func (*ScalarField) Name() string
Name returns the name of the structure.
func (*ScalarField) Order ¶
func (*ScalarField) Order() cardinal.Cardinal
Order returns the group or field order.
func (*ScalarField) WideElementSize ¶
func (*ScalarField) WideElementSize() int
WideElementSize returns the wide element size in bytes.