Documentation ¶
Overview ¶
Package field implements fast arithmetic modulo 2^255-19.
Index ¶
- Constants
- Variables
- func CreateProgramAddress(seeds [][]byte, programID common.Address) (common.Address, error)
- func FindAssociatedTokenAddress(wallet common.Address, mint common.Address, options ...common.Address) (common.Address, uint8, error)
- func FindAssociatedTokenAddressAndBumpSeed(walletAddress common.Address, splTokenMintAddress common.Address, ...) (common.Address, uint8, error)
- func FindProgramAddress(seed [][]byte, programID common.Address) (common.Address, uint8, error)
- func IsOnCurve(b []byte) bool
- type Create
- func (inst Create) Build() *Instruction
- func (inst Create) MarshalWithEncoder(encoder *encodbin.Encoder) error
- func (inst *Create) SetMint(mint common.Address) *Create
- func (inst *Create) SetPayer(payer common.Address) *Create
- func (inst *Create) SetTokenProgramID(tokenProgramID common.Address) *Create
- func (inst *Create) SetWallet(wallet common.Address) *Create
- type Element
- func (v *Element) Absolute(u *Element) *Element
- func (v *Element) Add(a, b *Element) *Element
- func (v *Element) Bytes() []byte
- func (v *Element) Equal(u *Element) int
- func (v *Element) Invert(z *Element) *Element
- func (v *Element) IsNegative() int
- func (v *Element) Mult32(x *Element, y uint32) *Element
- func (v *Element) Multiply(x, y *Element) *Element
- func (v *Element) Negate(a *Element) *Element
- func (v *Element) One() *Element
- func (v *Element) Pow22523(x *Element) *Element
- func (v *Element) Select(a, b *Element, cond int) *Element
- func (v *Element) Set(a *Element) *Element
- func (v *Element) SetBytes(x []byte) (*Element, error)
- func (r *Element) SqrtRatio(u, v *Element) (R *Element, wasSquare int)
- func (v *Element) Square(x *Element) *Element
- func (v *Element) Subtract(a, b *Element) *Element
- func (v *Element) Swap(u *Element, cond int)
- func (v *Element) Zero() *Element
- type Instruction
- type Point
Constants ¶
const ( // Maximum length of derived pubkey seed. MaxSeedLength = 32 // Maximum number of seeds. MaxSeeds = 16 )
const PDA_MARKER = "ProgramDerivedAddress"
Variables ¶
var ErrMaxSeedLengthExceeded = errors.New("Max seed length exceeded")
Functions ¶
func CreateProgramAddress ¶
Create a program address. Ported from https://github.com/solana-labs/solana/blob/216983c50e0a618facc39aa07472ba6d23f1b33a/sdk/program/src/pubkey.rs#L204
func FindProgramAddress ¶
Find a valid program address and its corresponding bump seed.
Types ¶
type Create ¶
type Create struct { Payer common.Address `bin:"-" borsh_skip:"true"` Wallet common.Address `bin:"-" borsh_skip:"true"` Mint common.Address `bin:"-" borsh_skip:"true"` TokenProgramID common.Address `bin:"-" borsh_skip:"true"` // [0] = [WRITE, SIGNER] Payer // ··········· Funding account // // [1] = [WRITE] AssociatedTokenAccount // ··········· Associated token account address to be created // // [2] = [] Wallet // ··········· Wallet address for the new associated token account // // [3] = [] TokenMint // ··········· The token mint for the new associated token account // // [4] = [] SystemProgram // ··········· System program ID // // [5] = [] TokenProgram // ··········· SPL token program ID // // [6] = [] SysVarRent // ··········· SysVarRentPubkey AccountMetaSlice []*base.AccountMeta `bin:"-" borsh_skip:"true"` }
func NewCreateInstruction ¶
func NewCreateInstructionBuilder ¶
func NewCreateInstructionBuilder() *Create
NewCreateInstructionBuilder creates a new `Create` instruction builder.
func (Create) Build ¶
func (inst Create) Build() *Instruction
func (Create) MarshalWithEncoder ¶
func (*Create) SetTokenProgramID ¶
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element represents an element of the field GF(2^255-19). Note that this is not a cryptographically secure group, and should only be used to interact with edwards25519.Point coordinates.
This type works similarly to math/big.Int, and all arguments and receivers are allowed to alias.
The zero value is a valid zero element.
func (*Element) IsNegative ¶
IsNegative returns 1 if v is negative, and 0 otherwise.
func (*Element) SetBytes ¶
SetBytes sets v to x, where x is a 32-byte little-endian encoding. If x is not of the right length, SetBytes returns nil and an error, and the receiver is unchanged.
Consistent with RFC 7748, the most significant bit (the high bit of the last byte) is ignored, and non-canonical values (2^255-19 through 2^255-1) are accepted. Note that this is laxer than specified by RFC 8032, but consistent with most Ed25519 implementations.
func (*Element) SqrtRatio ¶
SqrtRatio sets r to the non-negative square root of the ratio of u and v.
If u/v is square, SqrtRatio returns r and 1. If u/v is not square, SqrtRatio sets r according to Section 4.3 of draft-irtf-cfrg-ristretto255-decaf448-00, and returns r and 0.
type Instruction ¶
type Instruction struct {
encodbin.BaseVariant
}
func (*Instruction) Accounts ¶
func (inst *Instruction) Accounts() (out []*base.AccountMeta)
func (*Instruction) Data ¶
func (inst *Instruction) Data() ([]byte, error)
func (*Instruction) MarshalWithEncoder ¶
func (inst *Instruction) MarshalWithEncoder(encoder *encodbin.Encoder) error
func (*Instruction) ProgramID ¶
func (inst *Instruction) ProgramID() common.Address
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point represents a point on the edwards25519 curve.
This type works similarly to math/big.Int, and all arguments and receivers are allowed to alias.
The zero value is NOT valid, and it may be used only as a receiver.
func (*Point) SetBytes ¶
SetBytes sets v = x, where x is a 32-byte encoding of v. If x does not represent a valid point on the curve, SetBytes returns nil and an error and the receiver is unchanged. Otherwise, SetBytes returns v.
Note that SetBytes accepts all non-canonical encodings of valid points. That is, it follows decoding rules that match most implementations in the ecosystem rather than RFC 8032.