Documentation ¶
Index ¶
- Variables
- func AssertIsTrit(api frontend.API, v frontend.Variable)
- func FromBase(api frontend.API, base Base, digits []frontend.Variable, ...) frontend.Variable
- func FromBinary(api frontend.API, digits []frontend.Variable, opts ...BaseConversionOption) frontend.Variable
- func FromTernary(api frontend.API, digits []frontend.Variable, opts ...BaseConversionOption) frontend.Variable
- func IthBit(_ ecc.ID, inputs []*big.Int, results []*big.Int) error
- func NBits(_ ecc.ID, inputs []*big.Int, results []*big.Int) error
- func ToBase(api frontend.API, base Base, v frontend.Variable, opts ...BaseConversionOption) []frontend.Variable
- func ToBinary(api frontend.API, v frontend.Variable, opts ...BaseConversionOption) []frontend.Variable
- func ToNAF(api frontend.API, v frontend.Variable, opts ...BaseConversionOption) []frontend.Variable
- func ToTernary(api frontend.API, v frontend.Variable, opts ...BaseConversionOption) []frontend.Variable
- type Base
- type BaseConversionOption
Constants ¶
This section is empty.
Variables ¶
var NNAF = nNaf
NNAF returns the NAF decomposition of the input. The number of digits is defined by the number of elements in the results slice.
var NTrits = nTrits
NTrits returns the first trits of the input. The number of returned trits is defined by the length of the results slice.
Functions ¶
func AssertIsTrit ¶
AssertIsTrit constrains digit to be 0, 1 or 2.
func FromBase ¶
func FromBase(api frontend.API, base Base, digits []frontend.Variable, opts ...BaseConversionOption) frontend.Variable
FromBase compute from a set of digits its canonical representation in little-endian order. For example for base 2, it returns Σbi = Σ (2**i * digits[i])
func FromBinary ¶
func FromBinary(api frontend.API, digits []frontend.Variable, opts ...BaseConversionOption) frontend.Variable
FromBinary is an alias of FromBase(api, Binary, digits)
func FromTernary ¶
func FromTernary(api frontend.API, digits []frontend.Variable, opts ...BaseConversionOption) frontend.Variable
FromTernary is an alias of FromBase(api, Ternary, digits)
func IthBit ¶
IthBit returns the i-tb bit the input. The function expects exactly two integer inputs i and n, takes the little-endian bit representation of n and returns its i-th bit.
func NBits ¶
NBits returns the first bits of the input. The number of returned bits is defined by the length of the results slice.
func ToBase ¶
func ToBase(api frontend.API, base Base, v frontend.Variable, opts ...BaseConversionOption) []frontend.Variable
ToBase decomposes scalar v into digits in given base using options opts. The decomposition is in little-endian order.
func ToBinary ¶
func ToBinary(api frontend.API, v frontend.Variable, opts ...BaseConversionOption) []frontend.Variable
ToBinary is an alias of ToBase(api, Binary, v, opts)
Types ¶
type BaseConversionOption ¶
type BaseConversionOption func(opt *baseConversionConfig) error
BaseConversionOption configures the behaviour of scalar decomposition.
func WithNbDigits ¶
func WithNbDigits(nbDigits int) BaseConversionOption
WithNbDigits set the resulting number of digits to be used in the base conversion. nbDigits must be > 0. If nbDigits is lower than the length of full decomposition, then nbDigits least significant digits are returned. If the option is not set, then the full decomposition is returned.
func WithUnconstrainedInputs ¶
func WithUnconstrainedInputs() BaseConversionOption
WithUnconstrainedInputs indicates to the FromBase apis to constrain its inputs (digits) to ensure they are valid digits in base b. For example, FromBinary without this option will add 1 constraint per bit to ensure it is either 0 or 1.
func WithUnconstrainedOutputs ¶
func WithUnconstrainedOutputs() BaseConversionOption
WithUnconstrainedOutputs sets the bit conversion API to NOT constrain the output bits. This is UNSAFE but is useful when the outputs are already constrained by other circuit constraints. The sum of the digits will is constrained like so Σbi = Σ (base**i * digits[i]) But the individual digits are not constrained to be valid digits in base b.