Skip to main content
Version: 2.15.0

CircuitString

Defined in: lib/provable/string.ts:76

Extends​

Constructors​

Constructor​

new CircuitString(value: {
values: Character[];
}): CircuitString;

Defined in: lib/provable/types/struct.ts:133

Parameters​

value​
values​

Character[]

Returns​

CircuitString

Inherited from​

Struct(RawCircuitString).constructor

Properties​

values​

values: Character[];

Defined in: lib/provable/string.ts:70

Inherited from​

Struct(RawCircuitString).values

_isStruct​

static _isStruct: true;

Defined in: lib/provable/types/struct.ts:133

Inherited from​

Struct(RawCircuitString)._isStruct

check​

static check: (value: {
values: Character[];
}) => void;

Defined in: lib/provable/types/provable-intf.ts:76

Add assertions to the proof to check if value is a valid member of type T. This function does not return anything, instead it creates any number of assertions to prove that value is a valid member of the type T.

For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.

Parameters​

value​

the element of type T to put assertions on.

values​

Character[]

Returns​

void

Inherited from​

Struct(RawCircuitString).check

empty​

static empty: () => {
values: Character[];
};

Defined in: lib/provable/types/struct.ts:143

Returns​

{
values: Character[];
}
values​
values: Character[];

Inherited from​

Struct(RawCircuitString).empty

encoding​

static encoding: CircuitStringEncoding = 'ascii';

Defined in: lib/provable/string.ts:77


fromFields​

static fromFields: (fields: Field[]) => {
values: Character[];
};

Defined in: lib/provable/types/provable-intf.ts:115

Parameters​

fields​

Field[]

Returns​

{
values: Character[];
}
values​
values: Character[];

Inherited from​

Struct(RawCircuitString).fromFields

fromJSON​

static fromJSON: (x: {
values: {
value: string;
}[];
}) => {
values: Character[];
};

Defined in: lib/provable/types/struct.ts:142

Parameters​

x​
values​

{ value: string; }[] = ...

Returns​

{
values: Character[];
}
values​
values: Character[];

Inherited from​

Struct(RawCircuitString).fromJSON

fromValue​

static fromValue: (x: 
| string
| {
values: Character[];
}) => {
values: Character[];
} & (value:
| string
| {
values: Character[];
}) => {
values: Character[];
};

Defined in: lib/provable/types/provable-intf.ts:86

Convert provable type from a normal JS type.

Inherited from​

Struct(RawCircuitString).fromValue

maxLength​

static maxLength: number = DEFAULT_STRING_LENGTH;

Defined in: lib/provable/string.ts:79


toAuxiliary​

static toAuxiliary: (value?: {
values: Character[];
}) => any[];

Defined in: lib/provable/types/provable-intf.ts:47

A function that takes value (optional), an element of type T, as argument and returns an array of any type that make up the "auxiliary" (non-provable) data of value.

Parameters​

value?​

the element of type T to generate the auxiliary data array from, optional. If not provided, a default value for auxiliary data is returned.

values​

Character[]

Returns​

any[]

An array of any type describing how this T element is made up of "auxiliary" (non-provable) data.

Inherited from​

Struct(RawCircuitString).toAuxiliary

toCanonical?​

static optional toCanonical?: (x: {
values: Character[];
}) => {
values: Character[];
};

Defined in: lib/provable/types/provable-intf.ts:104

Optional method which transforms a provable type into its canonical representation.

This is needed for types that have multiple representations of the same underlying value, and might even not have perfect completeness for some of those representations.

An example is the ForeignField class, which allows non-native field elements to exist in unreduced form. The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.

Specific protocols need to be able to protect themselves against incomplete operations at all costs. For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action. toCanonical() converts any input into a safe form and enables us to handle cases like this generically.

Note: For most types, this method is the identity function. The identity function will also be used when the toCanonical() is not present on a type.

Parameters​

x​
values​

Character[]

Returns​

{
values: Character[];
}
values​
values: Character[];

Inherited from​

Struct(RawCircuitString).toCanonical

toFields​

static toFields: (value: {
values: Character[];
}) => Field[];

Defined in: lib/provable/types/provable-intf.ts:36

A function that takes value, an element of type T, as argument and returns an array of Field elements that make up the provable data of value.

Parameters​

value​

the element of type T to generate the Field array from.

values​

Character[]

Returns​

Field[]

A Field array describing how this T element is made up of Field elements.

Inherited from​

Struct(RawCircuitString).toFields

toInput​

static toInput: (x: {
values: Character[];
}) => {
fields?: Field[];
packed?: [Field, number][];
};

Defined in: lib/provable/types/struct.ts:137

Parameters​

x​
values​

Character[]

Returns​

{
fields?: Field[];
packed?: [Field, number][];
}
fields?​
optional fields?: Field[];
packed?​
optional packed?: [Field, number][];

Inherited from​

Struct(RawCircuitString).toInput

toJSON​

static toJSON: (x: {
values: Character[];
}) => {
values: {
value: string;
}[];
};

Defined in: lib/provable/types/struct.ts:141

Parameters​

x​
values​

Character[]

Returns​

{
values: {
value: string;
}[];
}
values​
values: {
value: string;
}[];

Inherited from​

Struct(RawCircuitString).toJSON

toValue​

static toValue: (x: {
values: Character[];
}) => string;

Defined in: lib/provable/types/provable-intf.ts:81

Convert provable type to a normal JS type.

Parameters​

x​
values​

Character[]

Returns​

string

Inherited from​

Struct(RawCircuitString).toValue

Methods​

append()​

append(str: CircuitString): CircuitString;

Defined in: lib/provable/string.ts:128

appends another string to this one, returns the result and proves that it fits within the maxLength of this string (the other string can have a different maxLength)

Parameters​

str​

CircuitString

Returns​

CircuitString


computeLengthAndMask()​

computeLengthAndMask(): {
length: Field;
mask: Bool[];
};

Defined in: lib/provable/string.ts:91

Returns​

{
length: Field;
mask: Bool[];
}
length​
length: Field;
mask​
mask: Bool[];

equals()​

equals(other: CircuitString): Bool;

Defined in: lib/provable/string.ts:120

returns true if this has the same value as other

Parameters​

other​

CircuitString

Returns​

Bool


hash()​

hash(): Field;

Defined in: lib/provable/string.ts:152

Returns​

Field


length()​

length(): Field;

Defined in: lib/provable/string.ts:113

Returns​

Field


lengthMask()​

lengthMask(): Bool[];

Defined in: lib/provable/string.ts:110

Returns​

Bool[]


maxLength()​

maxLength(): number;

Defined in: lib/provable/string.ts:86

Returns​

number


substring()​

substring(start: number, end: number): CircuitString;

Defined in: lib/provable/string.ts:156

Parameters​

start​

number

end​

number

Returns​

CircuitString


toString()​

toString(encoding?: CircuitStringEncoding): string;

Defined in: lib/provable/string.ts:160

Returns a string representation of an object.

Parameters​

encoding?​

CircuitStringEncoding

Returns​

string


fromCharacters()​

static fromCharacters(chars: Character[]): CircuitString;

Defined in: lib/provable/string.ts:82

Parameters​

chars​

Character[]

Returns​

CircuitString


fromString()​

static fromString(str: string, encoding?: CircuitStringEncoding): CircuitString;

Defined in: lib/provable/string.ts:185

Parameters​

str​

string

encoding?​

CircuitStringEncoding

Returns​

CircuitString


setEncoding()​

static setEncoding(encoding: CircuitStringEncoding): void;

Defined in: lib/provable/string.ts:181

Parameters​

encoding​

CircuitStringEncoding

Returns​

void


sizeInFields()​

static sizeInFields(): number;

Defined in: lib/provable/types/provable-intf.ts:66

Return the size of the T type in terms of Field type, as Field is the primitive type.

Returns​

number

A number representing the size of the T type in terms of Field type.

Inherited from​

Struct(RawCircuitString).sizeInFields