Documentation ¶
Overview ¶
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2019 Annchain Authors <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func GenerateRandomIndices(count int, upper int) []int
- func MaxInt(x, y int) int
- func MaxUint64(x, y uint64) uint64
- func MinInt(x, y int) int
- func MustParseBig256(s string) *big.Int
- func PaddedBigBytes(bigint *big.Int, n int) []byte
- func ParseBig256(s string) (*big.Int, bool)
- func ReadBits(bigint *big.Int, buf []byte)
- type BigInt
- func (bi *BigInt) Add(increment *BigInt) *BigInt
- func (z *BigInt) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *BigInt) EncodeMsg(en *msgp.Writer) (err error)
- func (bi *BigInt) GetBytes() []byte
- func (bi *BigInt) GetInt64() int64
- func (bi *BigInt) GetSigBytes() []byte
- func (bi *BigInt) GetString(base int) string
- func (bi *BigInt) MarshalJSON() ([]byte, error)
- func (z *BigInt) MarshalMsg(b []byte) (o []byte, err error)
- func (z *BigInt) Msgsize() (s int)
- func (bi *BigInt) Set(x *BigInt) *BigInt
- func (bi *BigInt) SetInt64(x int64)
- func (bi *BigInt) SetString(x string, base int)
- func (bi *BigInt) Sign() int
- func (bi *BigInt) String() string
- func (bi *BigInt) Sub(decrement *BigInt) *BigInt
- func (bi *BigInt) UnmarshalJSON(b []byte) error
- func (z *BigInt) UnmarshalMsg(bts []byte) (o []byte, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomIndices ¶ added in v0.0.7
GenerateRandomIndices generates [count] unique random numbers within range [0, upper) if count > upper, use all available indices
func MustParseBig256 ¶
MustParseBig256 parses s as a 256 bit big integer and panics if the string is invalid.
func PaddedBigBytes ¶
PaddedBigBytes encodes a big integer as a big-endian byte slice. The length of the slice is at least n bytes.
func ParseBig256 ¶
ParseBig256 parses s as a 256 bit integer in decimal or hexadecimal syntax. Leading zeros are accepted. The empty string parses as zero.
Types ¶
type BigInt ¶
A BigInt represents an unsigned multi-precision integer. The BigInt should always be unsigned since the sign of the number is not serialized.
func NewBigIntFromBigInt ¶
NewBigInt allocates and returns a new BigInt set to x.
func NewBigIntFromString ¶
NewBigInt allocates and returns a new BigInt set to x.
func (*BigInt) GetInt64 ¶
GetInt64 returns the int64 representation of x. If x cannot be represented in an int64, the result is undefined.
func (*BigInt) GetSigBytes ¶
GetSigBytes returns the bytes of bigint. This bytes are for signatures only.
func (*BigInt) GetString ¶
GetString returns the value of x as a formatted string in some number base.
func (*BigInt) MarshalJSON ¶
func (*BigInt) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*BigInt) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*BigInt) SetString ¶
SetString sets the big int to x.
The string prefix determines the actual conversion base. A prefix of "0x" or "0X" selects base 16; the "0" prefix selects base 8, and a "0b" or "0B" prefix selects base 2. Otherwise the selected base is 10.