ont

package
v0.0.0-...-450f598 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package elliptic implements several standard elliptic curves over prime fields.

  • Copyright (C) 2018 The ontology Authors
  • This file is part of The ontology library. *
  • The ontology is free software: you can redistribute it and/or modify
  • it under the terms of the GNU Lesser General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version. *
  • The ontology is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU Lesser General Public License for more details. *
  • You should have received a copy of the GNU Lesser General Public License
  • along with The ontology. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	UNBOUND_TIME_OFFSET = "unboundTimeOffset"
	TOTAL_SUPPLY_NAME   = "totalSupply"
	INIT_NAME           = "init"
	TRANSFER_NAME       = "transfer"
	APPROVE_NAME        = "approve"
	TRANSFERFROM_NAME   = "transferFrom"
	NAME_NAME           = "name"
	SYMBOL_NAME         = "symbol"
	DECIMALS_NAME       = "decimals"
	TOTALSUPPLY_NAME    = "totalSupply"
	BALANCEOF_NAME      = "balanceOf"
	ALLOWANCE_NAME      = "allowance"
)
View Source
const (
	UINT16_SIZE  = 2
	UINT32_SIZE  = 4
	UINT64_SIZE  = 8
	UINT256_SIZE = 32
)
View Source
const (
	// PublicKeySize is the size, in bytes, of public keys as used in this package.
	PublicKeySize = 32
	// PrivateKeySize is the size, in bytes, of private keys as used in this package.
	PrivateKeySize = 64
	// SignatureSize is the size, in bytes, of signatures generated and verified by this package.
	SignatureSize = 64
	// SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032.
	SeedSize = 32
)
View Source
const (
	WS_SUBSCRIBE_ACTION_BLOCK         = "Block"
	WS_SUBSCRIBE_ACTION_EVENT_NOTIFY  = "Notify"
	WS_SUBSCRIBE_ACTION_EVENT_LOG     = "Log"
	WS_SUBSCRIBE_ACTION_BLOCK_TX_HASH = "BlockTxHash"
)
View Source
const (
	// ECDSA curve label
	CP224 byte = 1
	CP256 byte = 2
	CP384 byte = 3
	CP521 byte = 4

	// SM2 curve label
	CPSM2P256V1 byte = 20

	// ED25519 curve label
	ED25519 byte = 25
)
View Source
const ADDR_LEN = 20
View Source
const BlockSize = 64

The blocksize of SM3 in bytes.

View Source
const (

	// DEFAULT_ID is the default user id used in Sign and Verify
	DEFAULT_ID = "1234567812345678"
)
View Source
const MAX_TX_SIZE = 1024 * 1024 // The max size of a transaction to prevent DOS attacks
View Source
const (
	MAX_UINT64 = math.MaxUint64
)
View Source
const MULTI_SIG_MAX_PUBKEY_SIZE = 16
View Source
const MaxBase58AddrLen = 2048 // just to avoid dos
View Source
const Size = 32

The size of a SM3 checksum in bytes.

View Source
const TX_MAX_SIG_SIZE = 16

transaction constants

Variables

View Source
var (
	ONT_CONTRACT_ADDRESS, _           = AddressFromHexString("0100000000000000000000000000000000000000")
	ONG_CONTRACT_ADDRESS, _           = AddressFromHexString("0200000000000000000000000000000000000000")
	ONT_ID_CONTRACT_ADDRESS, _        = AddressFromHexString("0300000000000000000000000000000000000000")
	GLOABL_PARAMS_CONTRACT_ADDRESS, _ = AddressFromHexString("0400000000000000000000000000000000000000")
	AUTH_CONTRACT_ADDRESS, _          = AddressFromHexString("0600000000000000000000000000000000000000")
	GOVERNANCE_CONTRACT_ADDRESS, _    = AddressFromHexString("0700000000000000000000000000000000000000")
)
View Source
var (
	ONT_CONTRACT_VERSION           = byte(0)
	ONG_CONTRACT_VERSION           = byte(0)
	ONT_ID_CONTRACT_VERSION        = byte(0)
	GLOBAL_PARAMS_CONTRACT_VERSION = byte(0)
	AUTH_CONTRACT_VERSION          = byte(0)
	GOVERNANCE_CONTRACT_VERSION    = byte(0)
)
View Source
var A = FieldElement{
	486662, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}

A is a constant in the Montgomery-form of curve25519.

View Source
var ADDRESS_EMPTY = Address{}
View Source
var ErrEof = errors.New("got EOF, can not get the next byte")
View Source
var ErrIrregularData = errors.New("irregular data")
View Source
var ErrRange = errors.New("value out of range")
View Source
var ErrTooLarge = errors.New("bytes.Buffer: too large")
View Source
var NATIVE_INVOKE_NAME = "Ontology.Native.Invoke"
View Source
var OPCODE_IN_PAYLOAD = map[byte]bool{0x00: true, 0xc6: true, 0x6b: true, 0x6a: true, 0xc8: true, 0x6c: true, 0x68: true, 0x67: true,
	0x7c: true, 0x51: true, 0xc1: true}
View Source
var SqrtM1 = FieldElement{
	-32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482,
}

SqrtM1 is the square-root of -1 in the field.

View Source
var UINT256_EMPTY = Uint256{}
View Source
var (
	VERSION_TRANSACTION = byte(0)
)

Functions

func AddressByteArrayReverse

func AddressByteArrayReverse(arr []byte) []byte

func BigIntFromNeoBytes

func BigIntFromNeoBytes(ba []byte) *big.Int

func BuildNativeInvokeCode

func BuildNativeInvokeCode(contractAddress Address, version byte, method string, params []interface{}) ([]byte, error)

func BuildNeoVMParam

func BuildNeoVMParam(builder *ParamsBuilder, smartContractParams []interface{}) error

buildNeoVMParamInter build neovm invoke param code

func ComparePublicKey

func ComparePublicKey(k0, k1 PublicKey) bool

ComparePublicKey checks whether the two public key are the same.

func ConstructPrivateKey

func ConstructPrivateKey(data []byte, curve elliptic.Curve) *ecdsa.PrivateKey

func DecodePublicKey

func DecodePublicKey(data []byte, curve elliptic.Curve) (*ecdsa.PublicKey, error)

func DecodeVarUint

func DecodeVarUint(source *ZeroCopySource) (uint64, error)

func EncodeAddress

func EncodeAddress(sink *ZeroCopySink, addr Address) (size uint64)

func EncodeMultiPubKeyProgramInto

func EncodeMultiPubKeyProgramInto(sink *ZeroCopySink, pubkeys []PublicKey, m int) error

func EncodeParamProgramInto

func EncodeParamProgramInto(sink *ZeroCopySink, sigs [][]byte)

func EncodePublicKey

func EncodePublicKey(key *ecdsa.PublicKey, compressed bool) []byte

func EncodeSinglePubKeyProgramInto

func EncodeSinglePubKeyProgramInto(sink *ZeroCopySink, pubkey PublicKey)

func EncodeVarUint

func EncodeVarUint(sink *ZeroCopySink, value uint64) (size uint64)

func FeAdd

func FeAdd(dst, a, b *FieldElement)

func FeCMove

func FeCMove(f, g *FieldElement, b int32)

Replace (f,g) with (g,g) if b == 1; replace (f,g) with (f,g) if b == 0.

Preconditions: b in {0,1}.

func FeCombine

func FeCombine(h *FieldElement, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9 int64)

func FeCopy

func FeCopy(dst, src *FieldElement)

func FeFromBytes

func FeFromBytes(dst *FieldElement, src *[32]byte)

func FeInvert

func FeInvert(out, z *FieldElement)

func FeIsNegative

func FeIsNegative(f *FieldElement) byte

func FeIsNonZero

func FeIsNonZero(f *FieldElement) int32

func FeMul

func FeMul(h, f, g *FieldElement)

FeMul calculates h = f * g Can overlap h with f or g.

Preconditions:

|f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
|g| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.

Postconditions:

|h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.

Notes on implementation strategy:

Using schoolbook multiplication. Karatsuba would save a little in some cost models.

Most multiplications by 2 and 19 are 32-bit precomputations; cheaper than 64-bit postcomputations.

There is one remaining multiplication by 19 in the carry chain; one *19 precomputation can be merged into this, but the resulting data flow is considerably less clean.

There are 12 carries below. 10 of them are 2-way parallelizable and vectorizable. Can get away with 11 carries, but then data flow is much deeper.

With tighter constraints on inputs, can squeeze carries into int32.

func FeNeg

func FeNeg(h, f *FieldElement)

FeNeg sets h = -f

Preconditions:

|f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.

Postconditions:

|h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.

func FeOne

func FeOne(fe *FieldElement)

func FeSquare

func FeSquare(h, f *FieldElement)

FeSquare calculates h = f*f. Can overlap h with f.

Preconditions:

|f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.

Postconditions:

|h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.

func FeSquare2

func FeSquare2(h, f *FieldElement)

FeSquare2 sets h = 2 * f * f

Can overlap h with f.

Preconditions:

|f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.

Postconditions:

|h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc.

See fe_mul.c for discussion of implementation strategy.

func FeSub

func FeSub(dst, a, b *FieldElement)

func FeToBytes

func FeToBytes(s *[32]byte, h *FieldElement)

FeToBytes marshals h to s. Preconditions:

|h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.

Write p=2^255-19; q=floor(h/p). Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))).

Proof:

Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4.
Also have |h-2^230 h9|<2^230 so |19 2^(-255)(h-2^230 h9)|<1/4.

Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9).
Then 0<y<1.

Write r=h-pq.
Have 0<=r<=p-1=2^255-20.
Thus 0<=r+19(2^-255)r<r+19(2^-255)2^255<=2^255-1.

Write x=r+19(2^-255)r+y.
Then 0<x<2^255 so floor(2^(-255)x) = 0 so floor(q+2^(-255)x) = q.

Have q+2^(-255)x = 2^(-255)(h + 19 2^(-25) h9 + 2^(-1))
so floor(2^(-255)(h + 19 2^(-25) h9 + 2^(-1))) = q.

func FeZero

func FeZero(fe *FieldElement)

func FileExisted

func FileExisted(filename string) bool

FileExisted checks whether filename exists in filesystem

func FindKey

func FindKey(list []PublicKey, key PublicKey) int

FindKey finds the specified public key in the list and returns its index or -1 if not found.

func GeDoubleScalarMultVartime

func GeDoubleScalarMultVartime(r *ProjectiveGroupElement, a *[32]byte, A *ExtendedGroupElement, b *[32]byte)

GeDoubleScalarMultVartime sets r = a*A + b*B where a = a[0]+256*a[1]+...+256^31 a[31]. and b = b[0]+256*b[1]+...+256^31 b[31]. B is the Ed25519 base point (x,4/5) with x positive.

func GeScalarMultBase

func GeScalarMultBase(h *ExtendedGroupElement, a *[32]byte)

GeScalarMultBase computes h = a*B, where

a = a[0]+256*a[1]+...+256^31 a[31]
B is the Ed25519 base point (x,4/5) with x positive.

Preconditions:

a[31] <= 127

func GenerateECKeyPair

func GenerateECKeyPair(c elliptic.Curve, rand io.Reader, alg ECAlgorithm) (*ECPrivateKey, *ECPublicKey, error)

func GenerateKey

func GenerateKey(curve elliptic.Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error)

GenerateKey returns a public/private key pair. The private key is generated using the given reader, which must return random data.

func GenerateKeyPair

func GenerateKeyPair(t KeyType, opts interface{}) (PrivateKey, PublicKey, error)

GenerateKeyPair generates a pair of private and public keys in type t. opts is the necessary parameter(s), which is defined by the key type:

ECDSA: a byte specifies the elliptic curve, which defined in package ec
SM2:   same as ECDSA
EdDSA: a byte specifies the curve, only ED25519 supported currently.

func GetCurve

func GetCurve(label byte) (elliptic.Curve, error)

func GetCurveLabel

func GetCurveLabel(c elliptic.Curve) (byte, error)

func GetHash

func GetHash(scheme SignatureScheme) hash.Hash

func GetInt

func GetInt(data []byte) (int, error)

func GetNamedCurveLabel

func GetNamedCurveLabel(name string) (byte, error)

func GetNonce

func GetNonce() uint64

GetNonce returns random nonce

func GetStorage

func GetStorage(data []byte) ([]byte, error)

func GetUint32

func GetUint32(data []byte) (uint32, error)

func GetUint64

func GetUint64(data []byte) (uint64, error)

func GetVarUintSize

func GetVarUintSize(value uint64) int

func GetVersion

func GetVersion(data []byte) (string, error)

func HexToBytes

func HexToBytes(value string) ([]byte, error)

HexToBytes convert hex string to []byte

func Marshal

func Marshal(curve Curve, x, y *big.Int) []byte

Marshal converts a point into the uncompressed form specified in section 4.3.6 of ANSI X9.62.

func P256

func P256() elliptic.Curve

P256 returns a Curve which implements P-256 (see FIPS 186-3, section D.2.3)

The cryptographic operations are implemented using constant-time algorithms.

func P384

func P384() elliptic.Curve

P384 returns a Curve which implements P-384 (see FIPS 186-3, section D.2.4)

The cryptographic operations do not use constant-time algorithms.

func P521

func P521() elliptic.Curve

P521 returns a Curve which implements P-521 (see FIPS 186-3, section D.2.5)

The cryptographic operations do not use constant-time algorithms.

func ParseNativeTxPayload

func ParseNativeTxPayload(raw []byte) (map[string]interface{}, error)

func ParsePayload

func ParsePayload(code []byte) (map[string]interface{}, error)

func PreComputedGroupElementCMove

func PreComputedGroupElementCMove(t, u *PreComputedGroupElement, b int32)

func Prime

func Prime(rand io.Reader, bits int) (p *big.Int, err error)

Prime returns a number, p, of the given size, such that p is prime with high probability. Prime will return error for any error returned by rand.Read or if bits < 2.

func ProgramFromMultiPubKey

func ProgramFromMultiPubKey(pubkeys []PublicKey, m int) ([]byte, error)

func ProgramFromPubKey

func ProgramFromPubKey(pubkey PublicKey) []byte

func PubKeysEqual

func PubKeysEqual(pks1, pks2 []PublicKey) bool

func ReadBool

func ReadBool(reader io.Reader) (bool, error)

func ReadByte

func ReadByte(reader io.Reader) (byte, error)

func ReadBytes

func ReadBytes(reader io.Reader, length uint64) ([]byte, error)

func ReadString

func ReadString(reader io.Reader) (string, error)

func ReadUint16

func ReadUint16(reader io.Reader) (uint16, error)

func ReadUint32

func ReadUint32(reader io.Reader) (uint32, error)

func ReadUint64

func ReadUint64(reader io.Reader) (uint64, error)

func ReadUint8

func ReadUint8(reader io.Reader) (uint8, error)

func ReadVarBytes

func ReadVarBytes(reader io.Reader) ([]byte, error)

func ReadVarUint

func ReadVarUint(reader io.Reader, maxint uint64) (uint64, error)

func ReadVarUintAddress

func ReadVarUintAddress(r io.Reader) (uint64, error)

func SM2P256V1

func SM2P256V1() elliptic.Curve

SM2P256V1 returns the sm2p256v1 curve.

func SM2Sign

func SM2Sign(rand io.Reader, priv *ecdsa.PrivateKey, id string, msg []byte, hasher hash.Hash) (r, s *big.Int, err error)

SM2Sign generates signature for the input message using the private key and id. It returns (r, s) as the signature or error.

func SM3New

func SM3New() hash.Hash

New returns a new hash.Hash computing the SM3 checksum.

func SafeAdd

func SafeAdd(x, y uint64) (uint64, bool)

func SafeMul

func SafeMul(x, y uint64) (uint64, bool)

func SafeSub

func SafeSub(x, y uint64) (uint64, bool)

func ScMinimal

func ScMinimal(scalar *[32]byte) bool

ScMinimal returns true if the given scalar is less than the order of the curve.

func ScMulAdd

func ScMulAdd(s, a, b, c *[32]byte)

Input:

a[0]+256*a[1]+...+256^31*a[31] = a
b[0]+256*b[1]+...+256^31*b[31] = b
c[0]+256*c[1]+...+256^31*c[31] = c

Output:

s[0]+256*s[1]+...+256^31*s[31] = (ab+c) mod l
where l = 2^252 + 27742317777372353535851937790883648493.

func ScReduce

func ScReduce(out *[32]byte, s *[64]byte)

Input:

s[0]+256*s[1]+...+256^63*s[63] = s

Output:

s[0]+256*s[1]+...+256^31*s[31] = s mod l
where l = 2^252 + 27742317777372353535851937790883648493.

func Serialize

func Serialize(sig *Signature) ([]byte, error)

func SerializePublicKey

func SerializePublicKey(key PublicKey) []byte

func Sum

func Sum(data []byte) [Size]byte

Sum returns the SM3 checksum of the data.

func ToArray

func ToArray(data SerializableData) []byte

func ToArrayReverse

func ToArrayReverse(arr []byte) []byte

func ToHexString

func ToHexString(data []byte) string

ToHexString convert []byte to hex string

func Unmarshal

func Unmarshal(curve Curve, data []byte) (x, y *big.Int)

Unmarshal converts a point, serialized by Marshal, into an x, y pair. It is an error if the point is not in uncompressed form or is not on the curve. On error, x = nil.

func WriteAddress

func WriteAddress(w io.Writer, address Address) error

func WriteBool

func WriteBool(writer io.Writer, val bool) error

func WriteByte

func WriteByte(writer io.Writer, val byte) error

func WriteString

func WriteString(writer io.Writer, value string) error

func WriteUint16

func WriteUint16(writer io.Writer, val uint16) error

func WriteUint32

func WriteUint32(writer io.Writer, val uint32) error

func WriteUint64

func WriteUint64(writer io.Writer, val uint64) error

func WriteUint8

func WriteUint8(writer io.Writer, val uint8) error

func WriteVarBytes

func WriteVarBytes(writer io.Writer, value []byte) error

func WriteVarUint

func WriteVarUint(writer io.Writer, value uint64) error

func WriteVarUintAddress

func WriteVarUintAddress(w io.Writer, value uint64) error

Types

type Account

type Account struct {
	PrivateKey PrivateKey
	PublicKey  PublicKey
	Address    Address
	SigScheme  SignatureScheme
}

crypto object

func NewAccount

func NewAccount(sigscheme ...SignatureScheme) *Account

func NewAccountFromPrivateKey

func NewAccountFromPrivateKey(privateKey []byte, signatureScheme SignatureScheme) (*Account, error)

func (*Account) GetPrivateKey

func (this *Account) GetPrivateKey() PrivateKey

func (*Account) GetPublicKey

func (this *Account) GetPublicKey() PublicKey

func (*Account) GetSigScheme

func (this *Account) GetSigScheme() SignatureScheme

func (*Account) Sign

func (this *Account) Sign(data []byte) ([]byte, error)

type Address

type Address [ADDR_LEN]byte

func AddressFromBase58

func AddressFromBase58(encoded string) (Address, error)

AddressFromBase58 returns Address from encoded base58 string

func AddressFromHexString

func AddressFromHexString(s string) (Address, error)

AddressParseFromHexString returns parsed Address

func AddressFromMultiPubKeys

func AddressFromMultiPubKeys(pubkeys []PublicKey, m int) (Address, error)

func AddressFromPubKey

func AddressFromPubKey(pubkey PublicKey) Address

func AddressFromVmCode

func AddressFromVmCode(code []byte) Address

func AddressParseFromBytes

func AddressParseFromBytes(f []byte) (Address, error)

AddressParseFromBytes returns parsed Address

func DecodeAddress

func DecodeAddress(source *ZeroCopySource) (Address, error)

func ReadAddress

func ReadAddress(r io.Reader) (Address, error)

func (*Address) ToBase58

func (f *Address) ToBase58() string

ToBase58 returns base58 encoded address string

func (*Address) ToHexString

func (f *Address) ToHexString() string

ToHexString returns hex string representation of Address

type Block

type Block struct {
	Header       *Header
	Transactions []*Transaction
}

func BlockFromRawBytes

func BlockFromRawBytes(raw []byte) (*Block, error)

if no error, ownership of param raw is transfered to Transaction

func GetBlock

func GetBlock(data []byte) (*Block, error)

func (*Block) Deserialization

func (self *Block) Deserialization(source *ZeroCopySource) error

type BlockTxHashes

type BlockTxHashes struct {
	Hash         Uint256
	Height       uint32
	Transactions []Uint256
}

func GetBlockTxHashes

func GetBlockTxHashes(data []byte) (*BlockTxHashes, error)

type BlockTxHashesStr

type BlockTxHashesStr struct {
	Hash         string
	Height       uint32
	Transactions []string
}

type CachedGroupElement

type CachedGroupElement struct {
	Z, T2d FieldElement
	// contains filtered or unexported fields
}

type Client

type Client interface {
	// Nonce(address string) (uint64, error)
	GetBalance(address string, asset string) (uint64, error)
	BestBlockNumber() (uint32, error)
	GetBlockByNumber(number uint32) (val *Block, err error)
	GetTransactionByHash(tx string) (val *Transaction, err error)
	SendRawTransaction(tx []byte) (string, error)
	BalanceOfAsset(address string, asset string) (uint64, error)
	// DecimalsOfAsset(asset string) (int, error)
	GetTransactionReceipt(tx string) (val *SmartContactEvent, err error)
	SuggestGasPrice() (uint32, error)
	Decimals() (uint64, error)
	TotalSupply() (uint64, error)
	Symbol() (string, error)
}

Client eth web3 api client

func New

func New(url string) Client

New return RPCImpl instance

type CompletedGroupElement

type CompletedGroupElement struct {
	X, Y, Z, T FieldElement
}

func (*CompletedGroupElement) ToExtended

func (p *CompletedGroupElement) ToExtended(r *ExtendedGroupElement)

func (*CompletedGroupElement) ToProjective

func (p *CompletedGroupElement) ToProjective(r *ProjectiveGroupElement)

type Curve

type Curve interface {
	// Params returns the parameters for the curve.
	Params() *CurveParams
	// IsOnCurve reports whether the given (x,y) lies on the curve.
	IsOnCurve(x, y *big.Int) bool
	// Add returns the sum of (x1,y1) and (x2,y2)
	Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)
	// Double returns 2*(x,y)
	Double(x1, y1 *big.Int) (x, y *big.Int)
	// ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
	ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int)
	// ScalarBaseMult returns k*G, where G is the base point of the group
	// and k is an integer in big-endian form.
	ScalarBaseMult(k []byte) (x, y *big.Int)
}

A Curve represents a short-form Weierstrass curve with a=-3. See https://www.hyperelliptic.org/EFD/g1p/auto-shortw.html

func P224

func P224() Curve

P224 returns a Curve which implements P-224 (see FIPS 186-3, section D.2.2).

The cryptographic operations are implemented using constant-time algorithms.

type CurveParams

type CurveParams struct {
	P       *big.Int // the order of the underlying field
	N       *big.Int // the order of the base point
	B       *big.Int // the constant of the curve equation
	Gx, Gy  *big.Int // (x,y) of the base point
	BitSize int      // the size of the underlying field
	Name    string   // the canonical name of the curve
}

CurveParams contains the parameters of an elliptic curve and also provides a generic, non-constant time implementation of Curve.

func (*CurveParams) Add

func (curve *CurveParams) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

func (*CurveParams) Double

func (curve *CurveParams) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

func (*CurveParams) IsOnCurve

func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool

func (*CurveParams) Params

func (curve *CurveParams) Params() *CurveParams

func (*CurveParams) ScalarBaseMult

func (curve *CurveParams) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

func (*CurveParams) ScalarMult

func (curve *CurveParams) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)

type DSASignature

type DSASignature struct {
	R, S  *big.Int
	Curve elliptic.Curve
}

type DeployCode

type DeployCode struct {
	Code        []byte
	NeedStorage bool
	Name        string
	Version     string
	Author      string
	Email       string
	Description string
	// contains filtered or unexported fields
}

DeployCode is an implementation of transaction payload for deploy smartcontract

func GetSmartContract

func GetSmartContract(data []byte) (*DeployCode, error)

func (*DeployCode) Deserialization

func (dc *DeployCode) Deserialization(source *ZeroCopySource) error

note: DeployCode.Code has data reference of param source

func (*DeployCode) Deserialize

func (dc *DeployCode) Deserialize(r io.Reader) error

func (*DeployCode) Serialization

func (dc *DeployCode) Serialization(sink *ZeroCopySink) error

func (*DeployCode) Serialize

func (dc *DeployCode) Serialize(w io.Writer) error

type ECAlgorithm

type ECAlgorithm byte
const (
	ECDSA ECAlgorithm = iota
	SM2
)

type ECPrivateKey

type ECPrivateKey struct {
	Algorithm ECAlgorithm
	*ecdsa.PrivateKey
}

func (*ECPrivateKey) Public

func (this *ECPrivateKey) Public() crypto.PublicKey

type ECPublicKey

type ECPublicKey struct {
	Algorithm ECAlgorithm
	*ecdsa.PublicKey
}

type ExtendedGroupElement

type ExtendedGroupElement struct {
	X, Y, Z, T FieldElement
}

func (*ExtendedGroupElement) Double

func (*ExtendedGroupElement) FromBytes

func (p *ExtendedGroupElement) FromBytes(s *[32]byte) bool

func (*ExtendedGroupElement) ToBytes

func (p *ExtendedGroupElement) ToBytes(s *[32]byte)

func (*ExtendedGroupElement) ToCached

func (p *ExtendedGroupElement) ToCached(r *CachedGroupElement)

func (*ExtendedGroupElement) ToProjective

func (p *ExtendedGroupElement) ToProjective(r *ProjectiveGroupElement)

func (*ExtendedGroupElement) Zero

func (p *ExtendedGroupElement) Zero()

type FieldElement

type FieldElement [10]int32

FieldElement represents an element of the field GF(2^255 - 19). An element t, entries t[0]...t[9], represents the integer t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9]. Bounds on each t[i] vary depending on context.

type Fixed64

type Fixed64 int64

the 64 bit fixed-point number, precise 10^-8

func (Fixed64) GetData

func (f Fixed64) GetData() int64

type GlobalParam

type GlobalParam struct {
	Key   string
	Value string
}
type Header struct {
	Version          uint32
	PrevBlockHash    Uint256
	TransactionsRoot Uint256
	BlockRoot        Uint256
	Timestamp        uint32
	Height           uint32
	ConsensusData    uint64
	ConsensusPayload []byte
	NextBookkeeper   Address

	//Program *program.Program
	Bookkeepers []PublicKey
	SigData     [][]byte
	// contains filtered or unexported fields
}

func (*Header) Deserialization

func (bd *Header) Deserialization(source *ZeroCopySource) error

func (*Header) Hash

func (bd *Header) Hash() Uint256

type InventoryType

type InventoryType byte
const (
	TRANSACTION InventoryType = 0x01
	BLOCK       InventoryType = 0x02
	CONSENSUS   InventoryType = 0xe0
)

type InvokeCode

type InvokeCode struct {
	Code []byte
}

InvokeCode is an implementation of transaction payload for invoke smartcontract

func (*InvokeCode) Deserialization

func (self *InvokeCode) Deserialization(source *ZeroCopySource) error

note: InvokeCode.Code has data reference of param source

func (*InvokeCode) Deserialize

func (self *InvokeCode) Deserialize(r io.Reader) error

func (*InvokeCode) Serialization

func (self *InvokeCode) Serialization(sink *ZeroCopySink) error

func (*InvokeCode) Serialize

func (self *InvokeCode) Serialize(w io.Writer) error

type JSONReqest

type JSONReqest struct {
	Version string        `json:"jsonrpc"`
	ID      string        `json:"id"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
}

JSONReqest object in rpc

type JSONResponse

type JSONResponse struct {
	ID     string          `json:"id"`
	Error  int64           `json:"error"`
	Desc   string          `json:"desc"`
	Result json.RawMessage `json:"result"`
}

JSONResponse object response for JsonRpcRequest

type KeyType

type KeyType byte
const (
	PK_ECDSA KeyType = 0x12
	PK_SM2   KeyType = 0x13
	PK_EDDSA KeyType = 0x14

	PK_P256_E  KeyType = 0x02
	PK_P256_O  KeyType = 0x03
	PK_P256_NC KeyType = 0x04
)

Supported key types

func GetKeyType

func GetKeyType(p PublicKey) KeyType

type MemPoolTxCount

type MemPoolTxCount struct {
	Verified uint32 //Tx count of verified
	Verifing uint32 //Tx count of verifing
}

func GetMemPoolTxCount

func GetMemPoolTxCount(data []byte) (*MemPoolTxCount, error)

type MemPoolTxState

type MemPoolTxState struct {
	State []*MemPoolTxStateItem
}

func GetMemPoolTxState

func GetMemPoolTxState(data []byte) (*MemPoolTxState, error)

type MemPoolTxStateItem

type MemPoolTxStateItem struct {
	Height  uint32 // The height in which tx was verified
	Type    int    // The validator flag: stateless/stateful
	ErrCode int    // Verified result
}

type MerkleProof

type MerkleProof struct {
	Type             string
	TransactionsRoot string
	BlockHeight      uint32
	CurBlockRoot     string
	CurBlockHeight   uint32
	TargetHashes     []string
}

MerkleProof return struct

func GetMerkleProof

func GetMerkleProof(data []byte) (*MerkleProof, error)

type MutableTransaction

type MutableTransaction struct {
	Version  byte
	TxType   TransactionType
	Nonce    uint32
	GasPrice uint64
	GasLimit uint64
	Payer    Address
	Payload  Payload

	Sigs []Sig
	// contains filtered or unexported fields
}

func NewInvokeTransaction

func NewInvokeTransaction(gasPrice, gasLimit uint64, invokeCode []byte) *MutableTransaction

func (*MutableTransaction) GetSignatureAddresses

func (self *MutableTransaction) GetSignatureAddresses() []Address

GetSignatureAddresses .

func (*MutableTransaction) Hash

func (self *MutableTransaction) Hash() Uint256

func (*MutableTransaction) IntoImmutable

func (self *MutableTransaction) IntoImmutable() (*Transaction, error)

output has no reference to self

type NotifyEventInfo

type NotifyEventInfo struct {
	ContractAddress string
	States          interface{}
}

func (*NotifyEventInfo) UnmarshalJSON

func (this *NotifyEventInfo) UnmarshalJSON(data []byte) error

type OpCode

type OpCode byte
const (
	// Constants
	PUSH0       OpCode = 0x00 // An empty array of bytes is pushed onto the stack.
	PUSHF       OpCode = PUSH0
	PUSHBYTES1  OpCode = 0x01 // 0x01-0x4B The next opcode bytes is data to be pushed onto the stack
	PUSHBYTES75 OpCode = 0x4B
	PUSHDATA1   OpCode = 0x4C // The next byte contains the number of bytes to be pushed onto the stack.
	PUSHDATA2   OpCode = 0x4D // The next two bytes contain the number of bytes to be pushed onto the stack.
	PUSHDATA4   OpCode = 0x4E // The next four bytes contain the number of bytes to be pushed onto the stack.
	PUSHM1      OpCode = 0x4F // The number -1 is pushed onto the stack.
	PUSH1       OpCode = 0x51 // The number 1 is pushed onto the stack.
	PUSHT       OpCode = PUSH1
	PUSH2       OpCode = 0x52 // The number 2 is pushed onto the stack.
	PUSH3       OpCode = 0x53 // The number 3 is pushed onto the stack.
	PUSH4       OpCode = 0x54 // The number 4 is pushed onto the stack.
	PUSH5       OpCode = 0x55 // The number 5 is pushed onto the stack.
	PUSH6       OpCode = 0x56 // The number 6 is pushed onto the stack.
	PUSH7       OpCode = 0x57 // The number 7 is pushed onto the stack.
	PUSH8       OpCode = 0x58 // The number 8 is pushed onto the stack.
	PUSH9       OpCode = 0x59 // The number 9 is pushed onto the stack.
	PUSH10      OpCode = 0x5A // The number 10 is pushed onto the stack.
	PUSH11      OpCode = 0x5B // The number 11 is pushed onto the stack.
	PUSH12      OpCode = 0x5C // The number 12 is pushed onto the stack.
	PUSH13      OpCode = 0x5D // The number 13 is pushed onto the stack.
	PUSH14      OpCode = 0x5E // The number 14 is pushed onto the stack.
	PUSH15      OpCode = 0x5F // The number 15 is pushed onto the stack.
	PUSH16      OpCode = 0x60 // The number 16 is pushed onto the stack.

	// Flow control
	NOP      OpCode = 0x61 // Does nothing.
	JMP      OpCode = 0x62
	JMPIF    OpCode = 0x63
	JMPIFNOT OpCode = 0x64
	CALL     OpCode = 0x65
	RET      OpCode = 0x66
	APPCALL  OpCode = 0x67
	SYSCALL  OpCode = 0x68
	TAILCALL OpCode = 0x69

	// Stack
	DUPFROMALTSTACK OpCode = 0x6A
	TOALTSTACK      OpCode = 0x6B // Puts the input onto the top of the alt stack. Removes it from the main stack.
	FROMALTSTACK    OpCode = 0x6C // Puts the input onto the top of the main stack. Removes it from the alt stack.
	XDROP           OpCode = 0x6D
	DCALL           OpCode = 0x6E
	XSWAP           OpCode = 0x72
	XTUCK           OpCode = 0x73
	DEPTH           OpCode = 0x74 // Puts the number of stack items onto the stack.
	DROP            OpCode = 0x75 // Removes the top stack item.
	DUP             OpCode = 0x76 // Duplicates the top stack item.
	NIP             OpCode = 0x77 // Removes the second top stack item.
	OVER            OpCode = 0x78 // Copies the second top stack item to the top.
	PICK            OpCode = 0x79 // The item n back in the stack is copied to the top.
	ROLL            OpCode = 0x7A // The item n back in the stack is moved to the top.
	ROT             OpCode = 0x7B // Move third top item on the top of stack.
	SWAP            OpCode = 0x7C // The top two items on the stack are swapped.
	TUCK            OpCode = 0x7D // The item at the top of the stack is copied and inserted before the second-to-top item.

	// Splice
	CAT    OpCode = 0x7E // Concatenates two strings.
	SUBSTR OpCode = 0x7F // Returns a section of a string.
	LEFT   OpCode = 0x80 // Keeps only characters left of the specified point in a string.
	RIGHT  OpCode = 0x81 // Keeps only characters right of the specified point in a string.
	SIZE   OpCode = 0x82 // Returns the length of the input string.

	// Bitwise logic
	INVERT OpCode = 0x83 // Flips all of the bits in the input.
	AND    OpCode = 0x84 // Boolean and between each bit in the inputs.
	OR     OpCode = 0x85 // Boolean or between each bit in the inputs.
	XOR    OpCode = 0x86 // Boolean exclusive or between each bit in the inputs.
	EQUAL  OpCode = 0x87 // Returns 1 if the inputs are exactly equal, 0 otherwise.

	// Arithmetic
	// Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.
	INC         OpCode = 0x8B // 1 is added to the input.
	DEC         OpCode = 0x8C // 1 is subtracted from the input.
	SIGN        OpCode = 0x8D
	NEGATE      OpCode = 0x8F // The sign of the input is flipped.
	ABS         OpCode = 0x90 // The input is made positive.
	NOT         OpCode = 0x91 // If the input is 0 or 1, it is flipped. Otherwise the output will be 0.
	NZ          OpCode = 0x92 // Returns 0 if the input is 0. 1 otherwise.
	ADD         OpCode = 0x93 // a is added to b.
	SUB         OpCode = 0x94 // b is subtracted from a.
	MUL         OpCode = 0x95 // a is multiplied by b.
	DIV         OpCode = 0x96 // a is divided by b.
	MOD         OpCode = 0x97 // Returns the remainder after dividing a by b.
	SHL         OpCode = 0x98 // Shifts a left b bits, preserving sign.
	SHR         OpCode = 0x99 // Shifts a right b bits, preserving sign.
	BOOLAND     OpCode = 0x9A // If both a and b are not 0, the output is 1. Otherwise 0.
	BOOLOR      OpCode = 0x9B // If a or b is not 0, the output is 1. Otherwise 0.
	NUMEQUAL    OpCode = 0x9C // Returns 1 if the numbers are equal, 0 otherwise.
	NUMNOTEQUAL OpCode = 0x9E // Returns 1 if the numbers are not equal, 0 otherwise.
	LT          OpCode = 0x9F // Returns 1 if a is less than b, 0 otherwise.
	GT          OpCode = 0xA0 // Returns 1 if a is greater than b, 0 otherwise.
	LTE         OpCode = 0xA1 // Returns 1 if a is less than or equal to b, 0 otherwise.
	GTE         OpCode = 0xA2 // Returns 1 if a is greater than or equal to b, 0 otherwise.
	MIN         OpCode = 0xA3 // Returns the smaller of a and b.
	MAX         OpCode = 0xA4 // Returns the larger of a and b.
	WITHIN      OpCode = 0xA5 // Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.

	// Crypto
	//RIPEMD160 = 0xA6 // The input is hashed using RIPEMD-160.
	SHA1          OpCode = 0xA7 // The input is hashed using SHA-1.
	SHA256        OpCode = 0xA8 // The input is hashed using SHA-256.
	HASH160       OpCode = 0xA9
	HASH256       OpCode = 0xAA
	CHECKSIG      OpCode = 0xAC // The entire transaction's outputs inputs and script (from the most recently-executed CODESEPARATOR to the end) are hashed. The signature used by CHECKSIG must be a valid signature for this hash and public key. If it is 1 is returned 0 otherwise.
	VERIFY        OpCode = 0xAD
	CHECKMULTISIG OpCode = 0xAE // For each signature and public key pair CHECKSIG is executed. If more public keys than signatures are listed some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid 1 is returned 0 otherwise. Due to a bug one extra unused value is removed from the stack.

	// Array
	ARRAYSIZE OpCode = 0xC0
	PACK      OpCode = 0xC1
	UNPACK    OpCode = 0xC2
	PICKITEM  OpCode = 0xC3
	SETITEM   OpCode = 0xC4
	NEWARRAY  OpCode = 0xC5
	NEWSTRUCT OpCode = 0xC6
	NEWMAP    OpCode = 0xC7
	APPEND    OpCode = 0xC8
	REVERSE   OpCode = 0xC9
	REMOVE    OpCode = 0xCA
	HASKEY    OpCode = 0xCB
	KEYS      OpCode = 0xCC
	VALUES    OpCode = 0xCD

	//Exception
	THROW      = 0xF0
	THROWIFNOT = 0xF1
)

type ParamsBuilder

type ParamsBuilder struct {
	// contains filtered or unexported fields
}

func NewParamsBuilder

func NewParamsBuilder(buffer *bytes.Buffer) *ParamsBuilder

func (*ParamsBuilder) Emit

func (p *ParamsBuilder) Emit(op OpCode)

func (*ParamsBuilder) EmitPushBool

func (p *ParamsBuilder) EmitPushBool(data bool)

func (*ParamsBuilder) EmitPushByteArray

func (p *ParamsBuilder) EmitPushByteArray(data []byte)

func (*ParamsBuilder) EmitPushCall

func (p *ParamsBuilder) EmitPushCall(address []byte)

func (*ParamsBuilder) EmitPushInteger

func (p *ParamsBuilder) EmitPushInteger(data *big.Int)

func (*ParamsBuilder) ToArray

func (p *ParamsBuilder) ToArray() []byte

type Payload

type Payload interface {
	//Serialize payload data
	Serialize(w io.Writer) error

	Deserialize(r io.Reader) error
}

type PreComputedGroupElement

type PreComputedGroupElement struct {
	// contains filtered or unexported fields
}

func (*PreComputedGroupElement) Zero

func (p *PreComputedGroupElement) Zero()

type PreExecResult

type PreExecResult struct {
	State  byte
	Gas    uint64
	Result *ResultItem
}

func (*PreExecResult) UnmarshalJSON

func (this *PreExecResult) UnmarshalJSON(data []byte) (err error)

type PrivateKey

type PrivateKey interface {
	crypto.PrivateKey
	Public() crypto.PublicKey
}

type PrivateKeyBytes

type PrivateKeyBytes []byte

func NewKeyFromSeed

func NewKeyFromSeed(seed []byte) PrivateKeyBytes

NewKeyFromSeed calculates a private key from a seed. It will panic if len(seed) is not SeedSize. This function is provided for interoperability with RFC 8032. RFC 8032's private keys correspond to seeds in this package.

func (PrivateKeyBytes) Public

func (priv PrivateKeyBytes) Public() crypto.PublicKey

type ProgramBuilder

type ProgramBuilder struct {
	// contains filtered or unexported fields
}

func (*ProgramBuilder) PushBytes

func (self *ProgramBuilder) PushBytes(data []byte) *ProgramBuilder

func (*ProgramBuilder) PushNum

func (self *ProgramBuilder) PushNum(num uint16) *ProgramBuilder

func (*ProgramBuilder) PushOpCode

func (self *ProgramBuilder) PushOpCode(op OpCode) *ProgramBuilder

func (*ProgramBuilder) PushPubKey

func (self *ProgramBuilder) PushPubKey(pubkey PublicKey) *ProgramBuilder

type ProjectiveGroupElement

type ProjectiveGroupElement struct {
	X, Y, Z FieldElement
}

func (*ProjectiveGroupElement) Double

func (*ProjectiveGroupElement) ToBytes

func (p *ProjectiveGroupElement) ToBytes(s *[32]byte)

func (*ProjectiveGroupElement) Zero

func (p *ProjectiveGroupElement) Zero()

type PublicKey

type PublicKey crypto.PublicKey

PublicKey represents a public key using an unspecified algorithm.

func DeserializePublicKey

func DeserializePublicKey(data []byte) (PublicKey, error)

DeserializePublicKey parse the byte sequencce to a public key.

func SortPublicKeys

func SortPublicKeys(list []PublicKey) []PublicKey

type PublicKeyBytes

type PublicKeyBytes []byte

type RawSig

type RawSig struct {
	Invoke []byte
	Verify []byte
}

func (*RawSig) Deserialization

func (self *RawSig) Deserialization(source *ZeroCopySource) error

type ResultItem

type ResultItem struct {
	// contains filtered or unexported fields
}

func (*ResultItem) ToArray

func (this *ResultItem) ToArray() ([]*ResultItem, error)

func (ResultItem) ToBool

func (this ResultItem) ToBool() (bool, error)

func (ResultItem) ToByteArray

func (this ResultItem) ToByteArray() ([]byte, error)

func (ResultItem) ToInteger

func (this ResultItem) ToInteger() (*big.Int, error)

func (ResultItem) ToString

func (this ResultItem) ToString() (string, error)

type SM2Curve

type SM2Curve interface {
	elliptic.Curve

	// ABytes returns the little endian byte sequence of parameter A.
	ABytes() []byte
}

type SM2Signature

type SM2Signature struct {
	DSASignature
	ID string
}

type SerializableData

type SerializableData interface {
	// Write data to writer
	Serialize(w io.Writer) error

	// read data to reader
	Deserialize(r io.Reader) error
}

SerializableData describe the data need be serialized.

type Sig

type Sig struct {
	SigData [][]byte
	PubKeys []PublicKey
	M       uint16
}

func (*Sig) Serialization

func (self *Sig) Serialization(sink *ZeroCopySink) error

type Signature

type Signature struct {
	Scheme SignatureScheme
	Value  interface{}
}

func Sign

func Sign(scheme SignatureScheme, pri PrivateKey, msg []byte, opt interface{}) (sig *Signature, err error)

Sign generates the signature for the input message @msg, using private key @pri and the signature scheme @scheme.

Some signature scheme may use extra parameters, which could be inputted via the last argument @opt:

  • SM2 signature needs the user ID (string). If it is an empty string, the default ID ("1234567812345678") would be used.

type SignatureScheme

type SignatureScheme byte
const (
	SHA224withECDSA SignatureScheme = iota
	SHA256withECDSA
	SHA384withECDSA
	SHA512withECDSA
	SHA3_224withECDSA
	SHA3_256withECDSA
	SHA3_384withECDSA
	SHA3_512withECDSA
	RIPEMD160withECDSA

	SM3withSM2

	SHA512withEDDSA
)

type Signer

type Signer interface {
	Sign(data []byte) ([]byte, error)
	GetPublicKey() PublicKey
	GetPrivateKey() PrivateKey
	GetSigScheme() SignatureScheme
}

type SmartContactEvent

type SmartContactEvent struct {
	TxHash      string
	State       byte
	GasConsumed uint64
	Notify      []*NotifyEventInfo
}

SmartContactEvent object for event of transaction

func GetSmartContactEvents

func GetSmartContactEvents(data []byte) ([]*SmartContactEvent, error)

func GetSmartContractEvent

func GetSmartContractEvent(data []byte) (*SmartContactEvent, error)

type SmartContract

type SmartContract DeployCode

type SmartContractEventLog

type SmartContractEventLog struct {
	TxHash          string
	ContractAddress string
	Message         string
}

func GetSmartContractEventLog

func GetSmartContractEventLog(data []byte) (*SmartContractEventLog, error)

type State

type State struct {
	From  Address
	To    Address
	Value uint64
}

func (*State) Deserialization

func (this *State) Deserialization(source *ZeroCopySource) error

func (*State) Deserialize

func (this *State) Deserialize(r io.Reader) error

func (*State) Serialization

func (this *State) Serialization(sink *ZeroCopySink)

func (*State) Serialize

func (this *State) Serialize(w io.Writer) error

type Transaction

type Transaction struct {
	Version  byte
	TxType   TransactionType
	Nonce    uint32
	GasPrice uint64
	GasLimit uint64
	Payer    Address
	Payload  Payload

	Sigs []RawSig

	Raw []byte // raw transaction data

	SignedAddr []Address // this is assigned when passed signature verification
	// contains filtered or unexported fields
}

func GetTransaction

func GetTransaction(data []byte) (*Transaction, error)

func TransactionFromRawBytes

func TransactionFromRawBytes(raw []byte) (*Transaction, error)

func (*Transaction) Deserialization

func (tx *Transaction) Deserialization(source *ZeroCopySource) error

Transaction has internal reference of param `source`

func (*Transaction) Hash

func (tx *Transaction) Hash() Uint256

func (*Transaction) Serialize

func (tx *Transaction) Serialize(w io.Writer) error

Serialize the Transaction

func (*Transaction) ToArray

func (tx *Transaction) ToArray() []byte

func (*Transaction) Type

func (tx *Transaction) Type() InventoryType

type TransactionType

type TransactionType byte
const (
	Bookkeeper TransactionType = 0x02
	Deploy     TransactionType = 0xd0
	Invoke     TransactionType = 0xd1
)

type Uint256

type Uint256 [UINT256_SIZE]byte

func ComputeMerkleRoot

func ComputeMerkleRoot(hashes []Uint256) Uint256

param hashes will be used as workspace

func GetUint256

func GetUint256(data []byte) (Uint256, error)

func Uint256FromHexString

func Uint256FromHexString(s string) (Uint256, error)

func Uint256ParseFromBytes

func Uint256ParseFromBytes(f []byte) (Uint256, error)

func (*Uint256) Deserialize

func (u *Uint256) Deserialize(r io.Reader) error

func (*Uint256) Serialize

func (u *Uint256) Serialize(w io.Writer) error

func (*Uint256) ToArray

func (u *Uint256) ToArray() []byte

func (*Uint256) ToHexString

func (u *Uint256) ToHexString() string

type ZeroCopySink

type ZeroCopySink struct {
	// contains filtered or unexported fields
}

func NewZeroCopySink

func NewZeroCopySink(b []byte) *ZeroCopySink

NewReader returns a new ZeroCopySink reading from b.

func (*ZeroCopySink) BackUp

func (self *ZeroCopySink) BackUp(n uint64)

Backs up a number of bytes, so that the next call to NextXXX() returns data again that was already returned by the last call to NextXXX().

func (*ZeroCopySink) Bytes

func (self *ZeroCopySink) Bytes() []byte

func (*ZeroCopySink) NextBytes

func (self *ZeroCopySink) NextBytes(n uint64) (data []byte)

func (*ZeroCopySink) Reset

func (self *ZeroCopySink) Reset()

func (*ZeroCopySink) Size

func (self *ZeroCopySink) Size() uint64

func (*ZeroCopySink) WriteAddress

func (self *ZeroCopySink) WriteAddress(addr Address)

func (*ZeroCopySink) WriteBool

func (self *ZeroCopySink) WriteBool(data bool)

func (*ZeroCopySink) WriteByte

func (self *ZeroCopySink) WriteByte(c byte)

func (*ZeroCopySink) WriteBytes

func (self *ZeroCopySink) WriteBytes(p []byte)

func (*ZeroCopySink) WriteHash

func (self *ZeroCopySink) WriteHash(hash Uint256)

func (*ZeroCopySink) WriteInt16

func (self *ZeroCopySink) WriteInt16(data int16)

func (*ZeroCopySink) WriteInt32

func (self *ZeroCopySink) WriteInt32(data int32)

func (*ZeroCopySink) WriteInt64

func (self *ZeroCopySink) WriteInt64(data int64)

func (*ZeroCopySink) WriteString

func (self *ZeroCopySink) WriteString(data string) (size uint64)

func (*ZeroCopySink) WriteUint16

func (self *ZeroCopySink) WriteUint16(data uint16)

func (*ZeroCopySink) WriteUint32

func (self *ZeroCopySink) WriteUint32(data uint32)

func (*ZeroCopySink) WriteUint64

func (self *ZeroCopySink) WriteUint64(data uint64)

func (*ZeroCopySink) WriteUint8

func (self *ZeroCopySink) WriteUint8(data uint8)

func (*ZeroCopySink) WriteVarBytes

func (self *ZeroCopySink) WriteVarBytes(data []byte) (size uint64)

func (*ZeroCopySink) WriteVarUint

func (self *ZeroCopySink) WriteVarUint(data uint64) (size uint64)

type ZeroCopySource

type ZeroCopySource struct {
	// contains filtered or unexported fields
}

func NewZeroCopySource

func NewZeroCopySource(b []byte) *ZeroCopySource

NewReader returns a new ZeroCopySource reading from b.

func (*ZeroCopySource) BackUp

func (self *ZeroCopySource) BackUp(n uint64)

Backs up a number of bytes, so that the next call to NextXXX() returns data again that was already returned by the last call to NextXXX().

func (*ZeroCopySource) Len

func (self *ZeroCopySource) Len() uint64

Len returns the number of bytes of the unread portion of the slice.

func (*ZeroCopySource) NextAddress

func (self *ZeroCopySource) NextAddress() (data Address, eof bool)

func (*ZeroCopySource) NextBool

func (self *ZeroCopySource) NextBool() (data bool, irregular bool, eof bool)

func (*ZeroCopySource) NextByte

func (self *ZeroCopySource) NextByte() (data byte, eof bool)

ReadByte implements the io.ByteReader interface.

func (*ZeroCopySource) NextBytes

func (self *ZeroCopySource) NextBytes(n uint64) (data []byte, eof bool)

Read implements the io.ZeroCopySource interface.

func (*ZeroCopySource) NextHash

func (self *ZeroCopySource) NextHash() (data Uint256, eof bool)

func (*ZeroCopySource) NextInt16

func (self *ZeroCopySource) NextInt16() (data int16, eof bool)

func (*ZeroCopySource) NextInt32

func (self *ZeroCopySource) NextInt32() (data int32, eof bool)

func (*ZeroCopySource) NextInt64

func (self *ZeroCopySource) NextInt64() (data int64, eof bool)

func (*ZeroCopySource) NextString

func (self *ZeroCopySource) NextString() (data string, size uint64, irregular bool, eof bool)

func (*ZeroCopySource) NextUint16

func (self *ZeroCopySource) NextUint16() (data uint16, eof bool)

func (*ZeroCopySource) NextUint32

func (self *ZeroCopySource) NextUint32() (data uint32, eof bool)

func (*ZeroCopySource) NextUint64

func (self *ZeroCopySource) NextUint64() (data uint64, eof bool)

func (*ZeroCopySource) NextUint8

func (self *ZeroCopySource) NextUint8() (data uint8, eof bool)

func (*ZeroCopySource) NextVarBytes

func (self *ZeroCopySource) NextVarBytes() (data []byte, size uint64, irregular bool, eof bool)

func (*ZeroCopySource) NextVarUint

func (self *ZeroCopySource) NextVarUint() (data uint64, size uint64, irregular bool, eof bool)

func (*ZeroCopySource) Pos

func (self *ZeroCopySource) Pos() uint64

func (*ZeroCopySource) Size

func (self *ZeroCopySource) Size() uint64

Size returns the original length of the underlying byte slice. Size is the number of bytes available for reading via ReadAt. The returned value is always the same and is not affected by calls to any other method.

func (*ZeroCopySource) Skip

func (self *ZeroCopySource) Skip(n uint64) (eof bool)

Jump to

Keyboard shortcuts

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