o1js-pack 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/README.md +9 -30
  3. package/build/src/index.d.ts +5 -5
  4. package/build/src/index.js +5 -5
  5. package/build/src/lib/PackingPlant.d.ts +132 -140
  6. package/build/src/lib/PackingPlant.js +190 -191
  7. package/build/src/lib/PackingPlant.js.map +1 -1
  8. package/build/src/lib/packed-types/PackedBool.d.ts +85 -90
  9. package/build/src/lib/packed-types/PackedBool.js +49 -48
  10. package/build/src/lib/packed-types/PackedBool.js.map +1 -1
  11. package/build/src/lib/packed-types/PackedBool.test.d.ts +1 -1
  12. package/build/src/lib/packed-types/PackedBool.test.js +75 -75
  13. package/build/src/lib/packed-types/PackedString.d.ts +181 -92
  14. package/build/src/lib/packed-types/PackedString.js +127 -59
  15. package/build/src/lib/packed-types/PackedString.js.map +1 -1
  16. package/build/src/lib/packed-types/PackedString.test.d.ts +1 -1
  17. package/build/src/lib/packed-types/PackedString.test.js +100 -99
  18. package/build/src/lib/packed-types/PackedString.test.js.map +1 -1
  19. package/build/src/lib/packed-types/PackedUInt32.d.ts +85 -90
  20. package/build/src/lib/packed-types/PackedUInt32.js +49 -48
  21. package/build/src/lib/packed-types/PackedUInt32.js.map +1 -1
  22. package/build/src/lib/packed-types/PackedUInt32.test.d.ts +1 -1
  23. package/build/src/lib/packed-types/PackedUInt32.test.js +83 -83
  24. package/package.json +1 -1
  25. package/tests/provable/end_to_end.test.ts +2 -4
  26. package/tests/provable/example_packed_string_circuit.ts +3 -8
  27. package/tests/provable/example_packed_uint_circuit.ts +6 -12
  28. package/build/src/lib/packed-types/PackedCharacter.d.ts +0 -51
  29. package/build/src/lib/packed-types/PackedCharacter.js +0 -34
  30. package/build/src/lib/packed-types/PackedCharacter.js.map +0 -1
  31. package/build/src/lib/packed-types/PackedCharacter.test.d.ts +0 -1
  32. package/build/src/lib/packed-types/PackedCharacter.test.js +0 -31
  33. package/build/src/lib/packed-types/PackedCharacter.test.js.map +0 -1
  34. package/build/src/lib/scratch.d.ts +0 -1
  35. package/build/src/lib/scratch.js +0 -16
  36. package/build/src/lib/scratch.js.map +0 -1
  37. package/build/src/packed-types/PackedBool.d.ts +0 -51
  38. package/build/src/packed-types/PackedBool.js +0 -34
  39. package/build/src/packed-types/PackedBool.js.map +0 -1
  40. package/build/src/packed-types/PackedBool.test.d.ts +0 -1
  41. package/build/src/packed-types/PackedBool.test.js +0 -101
  42. package/build/src/packed-types/PackedBool.test.js.map +0 -1
  43. package/build/src/packed-types/PackedCharacter.d.ts +0 -51
  44. package/build/src/packed-types/PackedCharacter.js +0 -34
  45. package/build/src/packed-types/PackedCharacter.js.map +0 -1
  46. package/build/src/packed-types/PackedCharacter.test.d.ts +0 -1
  47. package/build/src/packed-types/PackedCharacter.test.js +0 -31
  48. package/build/src/packed-types/PackedCharacter.test.js.map +0 -1
  49. package/build/src/packed-types/PackedUInt32.d.ts +0 -51
  50. package/build/src/packed-types/PackedUInt32.js +0 -34
  51. package/build/src/packed-types/PackedUInt32.js.map +0 -1
  52. package/build/src/packed-types/PackedUInt32.test.d.ts +0 -1
  53. package/build/src/packed-types/PackedUInt32.test.js +0 -68
  54. package/build/src/packed-types/PackedUInt32.test.js.map +0 -1
  55. package/build/src/packed-types/PackingPlant.d.ts +0 -54
  56. package/build/src/packed-types/PackingPlant.js +0 -45
  57. package/build/src/packed-types/PackingPlant.js.map +0 -1
  58. package/build/src/packed-types/scratch.d.ts +0 -1
  59. package/build/src/packed-types/scratch.js +0 -5
  60. package/build/src/packed-types/scratch.js.map +0 -1
  61. package/coverage/clover.xml +0 -166
  62. package/coverage/coverage-final.json +0 -5
  63. package/coverage/lcov-report/PackedBool.ts.html +0 -268
  64. package/coverage/lcov-report/PackedUInt32.ts.html +0 -313
  65. package/coverage/lcov-report/base.css +0 -224
  66. package/coverage/lcov-report/block-navigation.js +0 -87
  67. package/coverage/lcov-report/favicon.png +0 -0
  68. package/coverage/lcov-report/index.html +0 -131
  69. package/coverage/lcov-report/lib/PackingPlant.ts.html +0 -478
  70. package/coverage/lcov-report/lib/index.html +0 -116
  71. package/coverage/lcov-report/lib/packed-types/PackedBool.ts.html +0 -238
  72. package/coverage/lcov-report/lib/packed-types/PackedString.ts.html +0 -364
  73. package/coverage/lcov-report/lib/packed-types/PackedUInt32.ts.html +0 -238
  74. package/coverage/lcov-report/lib/packed-types/index.html +0 -146
  75. package/coverage/lcov-report/prettify.css +0 -1
  76. package/coverage/lcov-report/prettify.js +0 -2
  77. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  78. package/coverage/lcov-report/sorter.js +0 -196
  79. package/coverage/lcov.info +0 -282
@@ -1,49 +1,50 @@
1
- import { Provable, Bool } from 'o1js';
2
- import { PackingPlant } from '../PackingPlant.js';
3
- const L = 254; // 254 1-bit booleans fit in one Field
4
- const SIZE_IN_BITS = 1n;
5
- export function PackedBoolFactory(l = L) {
6
- class PackedBool_ extends PackingPlant(Bool, l, SIZE_IN_BITS) {
7
- static extractField(input) {
8
- return input.toField();
9
- }
10
- static sizeInBits() {
11
- return SIZE_IN_BITS;
12
- }
13
- /**
14
- *
15
- * @param f Field, packed with the information, as returned by #pack
16
- * @returns Array of Bool
17
- */
18
- static unpack(f) {
19
- const unpacked = Provable.witness(Provable.Array(Bool, l), () => {
20
- const unpacked = this.unpackToBigints(f);
21
- return unpacked.map((x) => Bool.fromJSON(Boolean(x)));
22
- });
23
- return unpacked;
24
- }
25
- /**
26
- *
27
- * @param bools Array of Bools to be packed
28
- * @returns Instance of the implementing class
29
- */
30
- static fromBools(bools) {
31
- const packed = PackedBool_.pack(bools);
32
- return new PackedBool_(packed);
33
- }
34
- /**
35
- *
36
- * @param booleans Array of booleans to be packed
37
- * @returns Instance of the implementing class
38
- */
39
- static fromBooleans(booleans) {
40
- const bools = booleans.map((x) => Bool(x));
41
- return PackedBool_.fromBools(bools);
42
- }
43
- toBooleans() {
44
- return PackedBool_.unpack(this.packed).map((x) => x.toBoolean());
45
- }
46
- }
47
- return PackedBool_;
48
- }
1
+ import { Provable, Bool } from 'o1js';
2
+ import { PackingPlant } from '../PackingPlant.js';
3
+ const L = 254; // 254 1-bit booleans fit in one Field
4
+ const SIZE_IN_BITS = 1n;
5
+ export function PackedBoolFactory(l = L) {
6
+ class PackedBool_ extends PackingPlant(Bool, l, SIZE_IN_BITS) {
7
+ static extractField(input) {
8
+ return input.toField();
9
+ }
10
+ static sizeInBits() {
11
+ return SIZE_IN_BITS;
12
+ }
13
+ /**
14
+ *
15
+ * @param f Field, packed with the information, as returned by #pack
16
+ * @returns Array of Bool
17
+ */
18
+ static unpack(f) {
19
+ const unpacked = Provable.witness(Provable.Array(Bool, l), () => {
20
+ const unpacked = this.unpackToBigints(f);
21
+ return unpacked.map((x) => Bool.fromJSON(Boolean(x)));
22
+ });
23
+ f.assertEquals(PackedBool_.pack(unpacked));
24
+ return unpacked;
25
+ }
26
+ /**
27
+ *
28
+ * @param bools Array of Bools to be packed
29
+ * @returns Instance of the implementing class
30
+ */
31
+ static fromBools(bools) {
32
+ const packed = PackedBool_.pack(bools);
33
+ return new PackedBool_(packed);
34
+ }
35
+ /**
36
+ *
37
+ * @param booleans Array of booleans to be packed
38
+ * @returns Instance of the implementing class
39
+ */
40
+ static fromBooleans(booleans) {
41
+ const bools = booleans.map((x) => Bool(x));
42
+ return PackedBool_.fromBools(bools);
43
+ }
44
+ toBooleans() {
45
+ return PackedBool_.unpack(this.packed).map((x) => x.toBoolean());
46
+ }
47
+ }
48
+ return PackedBool_;
49
+ }
49
50
  //# sourceMappingURL=PackedBool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PackedBool.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedBool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE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C3C,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED;;;;WAIG;QACH,MAAM,CAAC,SAAS,CAAC,KAAkB;YACjC,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACvC,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QAED;;;;WAIG;QACH,MAAM,CAAC,YAAY,CAAC,QAAwB;YAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,OAAO,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,UAAU;YACR,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QACnE,CAAC;KACF;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,76 +1,76 @@
1
- import { Bool, Provable } from 'o1js';
2
- import { PackedBoolFactory } from './PackedBool';
3
- describe('PackedBool', () => {
4
- const booleans = new Array(127).fill([true, false]).flat();
5
- const bools = booleans.map((x) => Bool(x));
6
- class PackedBool extends PackedBoolFactory() {
7
- }
8
- describe('Outside of the circuit', () => {
9
- it('#fromBooleans', () => {
10
- const myPackedBool = PackedBool.fromBooleans(booleans);
11
- expect(myPackedBool.toBooleans()).toMatchObject(booleans);
12
- });
13
- it('#pack and #unPack', () => {
14
- const packed = PackedBool.pack(bools);
15
- const unpacked = PackedBool.unpack(packed);
16
- expect(unpacked.length).toBe(bools.length);
17
- expect(unpacked).toMatchObject(bools);
18
- });
19
- });
20
- describe('Provable Properties', () => {
21
- it('#sizeInFields', () => {
22
- class one extends PackedBoolFactory(1) {
23
- }
24
- class two_five_four extends PackedBoolFactory(254) {
25
- }
26
- expect(one.sizeInFields()).toBe(1);
27
- expect(two_five_four.sizeInFields()).toBe(1);
28
- });
29
- });
30
- describe('Defensive Cases', () => {
31
- it('throws for input >= 255 bools', () => {
32
- expect(() => PackedBoolFactory(254)).not.toThrow();
33
- expect(() => PackedBoolFactory(255)).toThrow();
34
- });
35
- it('initalizes with more input than allowed', () => {
36
- const tooMany = [...booleans].concat(false);
37
- expect(() => {
38
- PackedBool.fromBooleans(tooMany);
39
- }).toThrow();
40
- });
41
- it('initalizes with less input than specified', () => {
42
- const booleans = [true, false];
43
- const pad = new Array(252);
44
- pad.fill(false);
45
- const expected = booleans.concat(pad);
46
- expect(PackedBool.fromBooleans(booleans).toBooleans()).toMatchObject(expected);
47
- });
48
- });
49
- describe('In the circuit', () => {
50
- const outsidePackedBool = PackedBool.fromBooleans(booleans);
51
- it('Initializes', () => {
52
- expect(() => {
53
- Provable.runAndCheck(() => {
54
- const packedBool = new PackedBool(outsidePackedBool.packed);
55
- PackedBool.check({ packed: packedBool.packed });
56
- });
57
- }).not.toThrow();
58
- });
59
- it('#assertEquals', () => {
60
- expect(() => {
61
- Provable.runAndCheck(() => {
62
- const packedBool = new PackedBool(outsidePackedBool.packed);
63
- packedBool.assertEquals(outsidePackedBool);
64
- });
65
- }).not.toThrow();
66
- expect(() => {
67
- Provable.runAndCheck(() => {
68
- const fakePacked = outsidePackedBool.packed.add(32);
69
- const packedBool = new PackedBool(fakePacked);
70
- packedBool.assertEquals(outsidePackedBool);
71
- });
72
- }).toThrow();
73
- });
74
- });
75
- });
1
+ import { Bool, Provable } from 'o1js';
2
+ import { PackedBoolFactory } from './PackedBool';
3
+ describe('PackedBool', () => {
4
+ const booleans = new Array(127).fill([true, false]).flat();
5
+ const bools = booleans.map((x) => Bool(x));
6
+ class PackedBool extends PackedBoolFactory() {
7
+ }
8
+ describe('Outside of the circuit', () => {
9
+ it('#fromBooleans', () => {
10
+ const myPackedBool = PackedBool.fromBooleans(booleans);
11
+ expect(myPackedBool.toBooleans()).toMatchObject(booleans);
12
+ });
13
+ it('#pack and #unPack', () => {
14
+ const packed = PackedBool.pack(bools);
15
+ const unpacked = PackedBool.unpack(packed);
16
+ expect(unpacked.length).toBe(bools.length);
17
+ expect(unpacked).toMatchObject(bools);
18
+ });
19
+ });
20
+ describe('Provable Properties', () => {
21
+ it('#sizeInFields', () => {
22
+ class one extends PackedBoolFactory(1) {
23
+ }
24
+ class two_five_four extends PackedBoolFactory(254) {
25
+ }
26
+ expect(one.sizeInFields()).toBe(1);
27
+ expect(two_five_four.sizeInFields()).toBe(1);
28
+ });
29
+ });
30
+ describe('Defensive Cases', () => {
31
+ it('throws for input >= 255 bools', () => {
32
+ expect(() => PackedBoolFactory(254)).not.toThrow();
33
+ expect(() => PackedBoolFactory(255)).toThrow();
34
+ });
35
+ it('initalizes with more input than allowed', () => {
36
+ const tooMany = [...booleans].concat(false);
37
+ expect(() => {
38
+ PackedBool.fromBooleans(tooMany);
39
+ }).toThrow();
40
+ });
41
+ it('initalizes with less input than specified', () => {
42
+ const booleans = [true, false];
43
+ const pad = new Array(252);
44
+ pad.fill(false);
45
+ const expected = booleans.concat(pad);
46
+ expect(PackedBool.fromBooleans(booleans).toBooleans()).toMatchObject(expected);
47
+ });
48
+ });
49
+ describe('In the circuit', () => {
50
+ const outsidePackedBool = PackedBool.fromBooleans(booleans);
51
+ it('Initializes', () => {
52
+ expect(() => {
53
+ Provable.runAndCheck(() => {
54
+ const packedBool = new PackedBool(outsidePackedBool.packed);
55
+ PackedBool.check({ packed: packedBool.packed });
56
+ });
57
+ }).not.toThrow();
58
+ });
59
+ it('#assertEquals', () => {
60
+ expect(() => {
61
+ Provable.runAndCheck(() => {
62
+ const packedBool = new PackedBool(outsidePackedBool.packed);
63
+ packedBool.assertEquals(outsidePackedBool);
64
+ });
65
+ }).not.toThrow();
66
+ expect(() => {
67
+ Provable.runAndCheck(() => {
68
+ const fakePacked = outsidePackedBool.packed.add(32);
69
+ const packedBool = new PackedBool(fakePacked);
70
+ packedBool.assertEquals(outsidePackedBool);
71
+ });
72
+ }).toThrow();
73
+ });
74
+ });
75
+ });
76
76
  //# sourceMappingURL=PackedBool.test.js.map
@@ -1,92 +1,181 @@
1
- import { Field, Character } from 'o1js';
2
- export declare function PackedStringFactory(l?: number): {
3
- new (packed: import("o1js/dist/node/lib/field.js").Field[]): {
4
- toString(): string;
5
- bitSize: bigint;
6
- assertEquals(other: {
7
- bitSize: bigint;
8
- assertEquals(other: any): void;
9
- packed: import("o1js/dist/node/lib/field.js").Field[];
10
- }): void;
11
- packed: import("o1js/dist/node/lib/field.js").Field[];
12
- };
13
- extractField(input: Character): Field;
14
- sizeInBits(): bigint;
15
- elementsPerField(): number;
16
- /**
17
- *
18
- * @param fields Array of Fields, containing packed Characters
19
- * @returns Array of Character
20
- */
21
- unpack(fields: Field[]): Character[];
22
- /**
23
- *
24
- * @param characters Array of Character to be packed
25
- * @returns Instance of the implementing class
26
- */
27
- fromCharacters(characters: Array<Character>): {
28
- toString(): string;
29
- bitSize: bigint;
30
- assertEquals(other: {
31
- bitSize: bigint;
32
- assertEquals(other: any): void;
33
- packed: import("o1js/dist/node/lib/field.js").Field[];
34
- }): void;
35
- packed: import("o1js/dist/node/lib/field.js").Field[];
36
- };
37
- /**
38
- *
39
- * @param str string to be packed
40
- * @returns Instance of the implementing class
41
- */
42
- fromString(str: string): {
43
- toString(): string;
44
- bitSize: bigint;
45
- assertEquals(other: {
46
- bitSize: bigint;
47
- assertEquals(other: any): void;
48
- packed: import("o1js/dist/node/lib/field.js").Field[];
49
- }): void;
50
- packed: import("o1js/dist/node/lib/field.js").Field[];
51
- };
52
- type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
53
- packed: import("o1js/dist/node/lib/field.js").Field[];
54
- }, {
55
- packed: string[];
56
- }>;
57
- l: number;
58
- n: number;
59
- checkPack(unpacked: Character[]): void;
60
- pack(unpacked: Character[]): import("o1js/dist/node/lib/field.js").Field[];
61
- unpackToBigints(fields: import("o1js/dist/node/lib/field.js").Field[]): bigint[];
62
- _isStruct: true;
63
- toFields: (value: {
64
- packed: import("o1js/dist/node/lib/field.js").Field[];
65
- }) => import("o1js/dist/node/lib/field.js").Field[];
66
- toAuxiliary: (value?: {
67
- packed: import("o1js/dist/node/lib/field.js").Field[];
68
- } | undefined) => any[];
69
- fromFields: (fields: import("o1js/dist/node/lib/field.js").Field[]) => {
70
- packed: import("o1js/dist/node/lib/field.js").Field[];
71
- };
72
- sizeInFields(): number;
73
- check: (value: {
74
- packed: import("o1js/dist/node/lib/field.js").Field[];
75
- }) => void;
76
- toInput: (x: {
77
- packed: import("o1js/dist/node/lib/field.js").Field[];
78
- }) => {
79
- fields?: import("o1js/dist/node/lib/field.js").Field[] | undefined;
80
- packed?: [import("o1js/dist/node/lib/field.js").Field, number][] | undefined;
81
- };
82
- toJSON: (x: {
83
- packed: import("o1js/dist/node/lib/field.js").Field[];
84
- }) => {
85
- packed: string[];
86
- };
87
- fromJSON: (x: {
88
- packed: string[];
89
- }) => {
90
- packed: import("o1js/dist/node/lib/field.js").Field[];
91
- };
92
- };
1
+ import { Field, Character } from 'o1js';
2
+ export declare function PackedStringFactory(l?: number): {
3
+ new (packed: import("o1js/dist/node/lib/field.js").Field): {
4
+ toString(): string;
5
+ assertEquals(other: {
6
+ assertEquals(other: any): void;
7
+ packed: import("o1js/dist/node/lib/field.js").Field;
8
+ }): void;
9
+ packed: import("o1js/dist/node/lib/field.js").Field;
10
+ };
11
+ extractField(input: Character): Field;
12
+ sizeInBits(): bigint;
13
+ /**
14
+ *
15
+ * @param f Field, packed with the information, as returned by #pack
16
+ * @returns Array of Character
17
+ */
18
+ unpack(f: Field): Character[];
19
+ /**
20
+ *
21
+ * @param characters Array of Character to be packed
22
+ * @returns Instance of the implementing class
23
+ */
24
+ fromCharacters(input: Array<Character>): {
25
+ toString(): string;
26
+ assertEquals(other: {
27
+ assertEquals(other: any): void;
28
+ packed: import("o1js/dist/node/lib/field.js").Field;
29
+ }): void;
30
+ packed: import("o1js/dist/node/lib/field.js").Field;
31
+ };
32
+ /**
33
+ *
34
+ * @param str string to be packed
35
+ * @returns Instance of the implementing class
36
+ */
37
+ fromString(str: string): {
38
+ toString(): string;
39
+ assertEquals(other: {
40
+ assertEquals(other: any): void;
41
+ packed: import("o1js/dist/node/lib/field.js").Field;
42
+ }): void;
43
+ packed: import("o1js/dist/node/lib/field.js").Field;
44
+ };
45
+ /**
46
+ *
47
+ * @param f Field, packed with the information, as returned by #pack
48
+ * @returns Array of Character
49
+ */
50
+ type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
51
+ packed: import("o1js/dist/node/lib/field.js").Field;
52
+ }, {
53
+ packed: string;
54
+ }>;
55
+ l: number;
56
+ bitSize: bigint;
57
+ checkPack(unpacked: Character[]): void;
58
+ pack(unpacked: Character[]): import("o1js/dist/node/lib/field.js").Field;
59
+ unpackToBigints(f: import("o1js/dist/node/lib/field.js").Field): bigint[];
60
+ _isStruct: true;
61
+ toFields: (value: {
62
+ packed: import("o1js/dist/node/lib/field.js").Field;
63
+ }) => import("o1js/dist/node/lib/field.js").Field[];
64
+ toAuxiliary: (value?: {
65
+ packed: import("o1js/dist/node/lib/field.js").Field;
66
+ } | undefined) => any[];
67
+ fromFields: (fields: import("o1js/dist/node/lib/field.js").Field[]) => {
68
+ packed: import("o1js/dist/node/lib/field.js").Field;
69
+ };
70
+ sizeInFields(): number;
71
+ check: (value: {
72
+ packed: import("o1js/dist/node/lib/field.js").Field;
73
+ }) => void;
74
+ toInput: (x: {
75
+ packed: import("o1js/dist/node/lib/field.js").Field;
76
+ }) => {
77
+ fields?: import("o1js/dist/node/lib/field.js").Field[] | undefined;
78
+ packed?: [import("o1js/dist/node/lib/field.js").Field, number][] | undefined;
79
+ };
80
+ toJSON: (x: {
81
+ packed: import("o1js/dist/node/lib/field.js").Field;
82
+ }) => {
83
+ packed: string;
84
+ };
85
+ fromJSON: (x: {
86
+ packed: string;
87
+ }) => {
88
+ packed: import("o1js/dist/node/lib/field.js").Field;
89
+ };
90
+ };
91
+ /**
92
+ *
93
+ * @param n number of fields to employ to store the string
94
+ * @returns MultiPackedString_ class with length of n * CHARS_PER_FIELD
95
+ */
96
+ export declare function MultiPackedStringFactory(n?: number): {
97
+ new (packed: import("o1js/dist/node/lib/field.js").Field[]): {
98
+ toString(): string;
99
+ assertEquals(other: {
100
+ assertEquals(other: any): void;
101
+ packed: import("o1js/dist/node/lib/field.js").Field[];
102
+ }): void;
103
+ packed: import("o1js/dist/node/lib/field.js").Field[];
104
+ };
105
+ extractField(input: Character): Field;
106
+ sizeInBits(): bigint;
107
+ elementsPerField(): number;
108
+ /**
109
+ *
110
+ * @param fields Array of Fields, containing packed Characters
111
+ * @returns Array of Character
112
+ */
113
+ unpack(fields: Field[]): Character[];
114
+ /**
115
+ *
116
+ * @param characters Array of Character to be packed
117
+ * @returns Instance of the implementing class
118
+ */
119
+ fromCharacters(input: Array<Character>): {
120
+ toString(): string;
121
+ assertEquals(other: {
122
+ assertEquals(other: any): void;
123
+ packed: import("o1js/dist/node/lib/field.js").Field[];
124
+ }): void;
125
+ packed: import("o1js/dist/node/lib/field.js").Field[];
126
+ };
127
+ /**
128
+ *
129
+ * @param str string to be packed
130
+ * @returns Instance of the implementing class
131
+ */
132
+ fromString(str: string): {
133
+ toString(): string;
134
+ assertEquals(other: {
135
+ assertEquals(other: any): void;
136
+ packed: import("o1js/dist/node/lib/field.js").Field[];
137
+ }): void;
138
+ packed: import("o1js/dist/node/lib/field.js").Field[];
139
+ };
140
+ type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
141
+ packed: import("o1js/dist/node/lib/field.js").Field[];
142
+ }, {
143
+ packed: string[];
144
+ }>;
145
+ l: number;
146
+ n: number;
147
+ bitSize: bigint;
148
+ checkPack(unpacked: Character[]): void;
149
+ pack(unpacked: Character[]): import("o1js/dist/node/lib/field.js").Field[];
150
+ unpackToBigints(fields: import("o1js/dist/node/lib/field.js").Field[]): bigint[];
151
+ _isStruct: true;
152
+ toFields: (value: {
153
+ packed: import("o1js/dist/node/lib/field.js").Field[];
154
+ }) => import("o1js/dist/node/lib/field.js").Field[];
155
+ toAuxiliary: (value?: {
156
+ packed: import("o1js/dist/node/lib/field.js").Field[];
157
+ } | undefined) => any[];
158
+ fromFields: (fields: import("o1js/dist/node/lib/field.js").Field[]) => {
159
+ packed: import("o1js/dist/node/lib/field.js").Field[];
160
+ };
161
+ sizeInFields(): number;
162
+ check: (value: {
163
+ packed: import("o1js/dist/node/lib/field.js").Field[];
164
+ }) => void;
165
+ toInput: (x: {
166
+ packed: import("o1js/dist/node/lib/field.js").Field[];
167
+ }) => {
168
+ fields?: import("o1js/dist/node/lib/field.js").Field[] | undefined;
169
+ packed?: [import("o1js/dist/node/lib/field.js").Field, number][] | undefined;
170
+ };
171
+ toJSON: (x: {
172
+ packed: import("o1js/dist/node/lib/field.js").Field[];
173
+ }) => {
174
+ packed: string[];
175
+ };
176
+ fromJSON: (x: {
177
+ packed: string[];
178
+ }) => {
179
+ packed: import("o1js/dist/node/lib/field.js").Field[];
180
+ };
181
+ };