Documentation ¶
Index ¶
- Constants
- Variables
- func DivMod(n, m, p *big.Int) *big.Int
- func FmtKecBytes(in *big.Int, rolen int) (buf []byte)
- func MaskBits(mask, wordSize int, slice []byte) (ret []byte)
- func MerkleHash(x, y *big.Int) (*big.Int, error)
- func ProofMerklePath(root *big.Int, leaf *big.Int, path []*big.Int) bool
- type Account
- func (account *Account) Call(ctx context.Context, call types.FunctionCall) ([]string, error)
- func (account *Account) EstimateFee(ctx context.Context, calls []types.FunctionCall, details types.ExecuteDetails) (*types.FeeEstimate, error)
- func (account *Account) Execute(ctx context.Context, calls []types.FunctionCall, details types.ExecuteDetails) (*types.AddInvokeTransactionOutput, error)
- func (account *Account) Nonce(ctx context.Context) (*big.Int, error)
- func (account *Account) Sign(msgHash *big.Int) (*big.Int, *big.Int, error)
- func (account *Account) TransactionHash(calls []types.FunctionCall, details types.ExecuteDetails) (*big.Int, error)
- type AccountOption
- type AccountOptionFunc
- type AccountPlugin
- type CurveOption
- type Definition
- type Domain
- type FixedSizeMerkleTree
- type ProviderType
- type StarkCurve
- func (sc StarkCurve) Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)
- func (sc StarkCurve) ComputeHashOnElements(elems []*big.Int) (hash *big.Int, err error)
- func (sc StarkCurve) Double(x1, y1 *big.Int) (x, y *big.Int)
- func (sc StarkCurve) EcMult(m, x1, y1 *big.Int) (x, y *big.Int)
- func (sc StarkCurve) GenerateSecret(msgHash, privKey, seed *big.Int) (secret *big.Int)
- func (sc StarkCurve) GetRandomPrivateKey() (priv *big.Int, err error)
- func (sc StarkCurve) GetYCoordinate(starkX *big.Int) *big.Int
- func (sc StarkCurve) HashElements(elems []*big.Int) (hash *big.Int, err error)
- func (sc StarkCurve) InvModCurveSize(x *big.Int) *big.Int
- func (sc StarkCurve) IsOnCurve(x, y *big.Int) bool
- func (sc StarkCurve) MimicEcMultAir(mout, x1, y1, x2, y2 *big.Int) (x *big.Int, y *big.Int, err error)
- func (sc StarkCurve) PedersenHash(elems []*big.Int) (hash *big.Int, err error)
- func (sc StarkCurve) PrivateToPoint(privKey *big.Int) (x, y *big.Int, err error)
- func (sc StarkCurve) ScalarBaseMult(k []byte) (x, y *big.Int)
- func (sc StarkCurve) ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int)
- func (sc StarkCurve) Sign(msgHash, privKey *big.Int, seed ...*big.Int) (x, y *big.Int, err error)
- func (sc StarkCurve) Verify(msgHash, r, s, pubX, pubY *big.Int) bool
- type StarkCurvePayload
- type TypeDef
- type TypedData
- func (td TypedData) EncodeType(inType string) (enc string, err error)
- func (td TypedData) GetMessageHash(account *big.Int, msg TypedMessage, sc StarkCurve) (hash *big.Int, err error)
- func (td TypedData) GetTypeHash(inType string) (ret *big.Int, err error)
- func (td TypedData) GetTypedMessageHash(inType string, msg TypedMessage, sc StarkCurve) (hash *big.Int, err error)
- type TypedMessage
Constants ¶
const ( TRANSACTION_PREFIX = "invoke" EXECUTE_SELECTOR = "__execute__" CONTRACT_ADDRESS_PREFIX = "STARKNET_CONTRACT_ADDRESS" )
Variables ¶
var ( ErrUnsupportedAccount = errors.New("unsupported account implementation") MAX_FEE, _ = big.NewInt(0).SetString("0x20000000000", 0) )
var PedersenParamsRaw []byte
Functions ¶
func FmtKecBytes ¶
format the bytes in Keccak hash
Types ¶
type Account ¶
type Account struct { AccountAddress string // contains filtered or unexported fields }
func NewGatewayAccount ¶
func NewGatewayAccount(private, address string, provider *gateway.GatewayProvider, options ...AccountOptionFunc) (*Account, error)
func NewRPCAccount ¶
func (*Account) EstimateFee ¶
func (account *Account) EstimateFee(ctx context.Context, calls []types.FunctionCall, details types.ExecuteDetails) (*types.FeeEstimate, error)
func (*Account) Execute ¶
func (account *Account) Execute(ctx context.Context, calls []types.FunctionCall, details types.ExecuteDetails) (*types.AddInvokeTransactionOutput, error)
func (*Account) TransactionHash ¶
func (account *Account) TransactionHash(calls []types.FunctionCall, details types.ExecuteDetails) (*big.Int, error)
type AccountOption ¶
type AccountOption struct { AccountPlugin AccountPlugin // contains filtered or unexported fields }
func AccountVersion0 ¶
func AccountVersion0(string, string) (AccountOption, error)
func AccountVersion1 ¶
func AccountVersion1(string, string) (AccountOption, error)
type AccountOptionFunc ¶
type AccountOptionFunc func(string, string) (AccountOption, error)
type AccountPlugin ¶
type AccountPlugin interface {
PluginCall(calls []types.FunctionCall) (types.FunctionCall, error)
}
type CurveOption ¶
type CurveOption interface {
// contains filtered or unexported methods
}
func WithConstants ¶
func WithConstants(paramsPath ...string) CurveOption
functions that require pedersen hashes must be run on a curve initialized with constant points
type Definition ¶
type FixedSizeMerkleTree ¶
func NewFixedSizeMerkleTree ¶
func NewFixedSizeMerkleTree(leaves ...*big.Int) (*FixedSizeMerkleTree, error)
type ProviderType ¶
type ProviderType string
const ( ProviderRPCv01 ProviderType = "rpcv01" ProviderRPCv02 ProviderType = "rpcv02" ProviderGateway ProviderType = "gateway" )
type StarkCurve ¶
type StarkCurve struct { *elliptic.CurveParams EcGenX *big.Int EcGenY *big.Int MinusShiftPointX *big.Int MinusShiftPointY *big.Int Max *big.Int Alpha *big.Int ConstantPoints [][]*big.Int }
Returned stark curve includes several values above and beyond what the 'elliptic' interface calls for to facilitate common starkware functions
var Curve StarkCurve
func (StarkCurve) Add ¶
func (sc StarkCurve) Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)
Gets two points on an elliptic curve mod p and returns their sum. Assumes affine form (x, y) is spread (x1 *big.Int, y1 *big.Int)
func (StarkCurve) ComputeHashOnElements ¶
Hashes the contents of a given array with its size using a golang Pedersen Hash implementation.
func (StarkCurve) Double ¶
func (sc StarkCurve) Double(x1, y1 *big.Int) (x, y *big.Int)
Doubles a point on an elliptic curve with the equation y^2 = x^3 + alpha*x + beta mod p. Assumes affine form (x, y) is spread (x1 *big.Int, y1 *big.Int)
func (StarkCurve) EcMult ¶
func (sc StarkCurve) EcMult(m, x1, y1 *big.Int) (x, y *big.Int)
Multiplies by m a point on the elliptic curve with equation y^2 = x^3 + alpha*x + beta mod p. Assumes affine form (x, y) is spread (x1 *big.Int, y1 *big.Int) and that 0 < m < order(point).
func (StarkCurve) GenerateSecret ¶
func (sc StarkCurve) GenerateSecret(msgHash, privKey, seed *big.Int) (secret *big.Int)
implementation based on https://github.com/codahale/rfc6979/blob/master/rfc6979.go for the specification, see https://tools.ietf.org/html/rfc6979#section-3.2
func (StarkCurve) GetRandomPrivateKey ¶
func (sc StarkCurve) GetRandomPrivateKey() (priv *big.Int, err error)
obtain random primary key on stark curve NOTE: to be used for testing purposes
func (StarkCurve) GetYCoordinate ¶
func (sc StarkCurve) GetYCoordinate(starkX *big.Int) *big.Int
Given the x coordinate of a stark_key, returns a possible y coordinate such that together the point (x,y) is on the curve. Note: the real y coordinate is either y or -y.
func (StarkCurve) HashElements ¶
Hashes the contents of a given array using a golang Pedersen Hash implementation.
func (StarkCurve) InvModCurveSize ¶
func (sc StarkCurve) InvModCurveSize(x *big.Int) *big.Int
func (StarkCurve) MimicEcMultAir ¶
func (sc StarkCurve) MimicEcMultAir(mout, x1, y1, x2, y2 *big.Int) (x *big.Int, y *big.Int, err error)
Computes m * point + shift_point using the same steps like the AIR and throws an exception if and only if the AIR errors.
func (StarkCurve) PedersenHash ¶
Provides the pedersen hash of given array of big integers. NOTE: This function assumes the curve has been initialized with contant points
func (StarkCurve) PrivateToPoint ¶
obtain public key coordinates from stark curve given the private key
func (StarkCurve) ScalarBaseMult ¶
func (sc StarkCurve) ScalarBaseMult(k []byte) (x, y *big.Int)
func (StarkCurve) ScalarMult ¶
func (StarkCurve) Sign ¶
Signs the hash value of contents with the provided private key. Secret is generated using a golang implementation of RFC 6979. Implementation does not yet include "extra entropy" or "retry gen".
(ref: https://datatracker.ietf.org/doc/html/rfc6979)
type StarkCurvePayload ¶
type StarkCurvePayload struct { License []string `json:"_license"` Comment string `json:"_comment"` FieldPrime *big.Int `json:"FIELD_PRIME"` FieldGen int `json:"FIELD_GEN"` EcOrder *big.Int `json:"EC_ORDER"` Alpha int64 `json:"ALPHA"` Beta *big.Int `json:"BETA"` ConstantPoints [][]*big.Int `json:"CONSTANT_POINTS"` }
struct definition for parsing 'pedersen_params.json'
var PedersenParams StarkCurvePayload
type TypeDef ¶
type TypeDef struct { Encoding *big.Int Definitions []Definition }
type TypedData ¶
type TypedData struct { Types map[string]TypeDef PrimaryType string Domain Domain Message TypedMessage }
func NewTypedData ¶
'typedData' interface for interacting and signing typed data in accordance with https://github.com/0xs34n/starknet.js/tree/develop/src/utils/typedData
func (TypedData) GetMessageHash ¶
func (td TypedData) GetMessageHash(account *big.Int, msg TypedMessage, sc StarkCurve) (hash *big.Int, err error)
func (TypedData) GetTypeHash ¶
func (TypedData) GetTypedMessageHash ¶
func (td TypedData) GetTypedMessageHash(inType string, msg TypedMessage, sc StarkCurve) (hash *big.Int, err error)