o1js-pack 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/README.md +8 -2
  3. package/build/src/index.d.ts +5 -5
  4. package/build/src/index.js +5 -5
  5. package/build/src/index.js.map +1 -1
  6. package/build/src/lib/PackingPlant.d.ts +132 -132
  7. package/build/src/lib/PackingPlant.js +190 -190
  8. package/build/src/lib/packed-types/PackedBool.d.ts +85 -85
  9. package/build/src/lib/packed-types/PackedBool.js +49 -49
  10. package/build/src/lib/packed-types/PackedBool.test.d.ts +1 -1
  11. package/build/src/lib/packed-types/PackedBool.test.js +75 -75
  12. package/build/src/lib/packed-types/PackedString.d.ts +181 -181
  13. package/build/src/lib/packed-types/PackedString.js +127 -127
  14. package/build/src/lib/packed-types/PackedString.test.d.ts +1 -1
  15. package/build/src/lib/packed-types/PackedString.test.js +100 -100
  16. package/build/src/lib/packed-types/PackedUInt32.d.ts +85 -85
  17. package/build/src/lib/packed-types/PackedUInt32.js +49 -49
  18. package/build/src/lib/packed-types/PackedUInt32.test.d.ts +1 -1
  19. package/build/src/lib/packed-types/PackedUInt32.test.js +83 -83
  20. package/examples/smart_contract/election/README.md +3 -0
  21. package/examples/smart_contract/election/contract.ts +79 -0
  22. package/examples/smart_contract/election/run.ts +98 -0
  23. package/examples/zk_program/age_gate/README.md +7 -0
  24. package/examples/zk_program/age_gate/circuit.ts +75 -0
  25. package/examples/zk_program/age_gate/non-packed-circuit.ts +68 -0
  26. package/examples/zk_program/age_gate/non-packed-run.ts +36 -0
  27. package/examples/zk_program/age_gate/run.ts +35 -0
  28. package/package.json +2 -4
@@ -1,128 +1,128 @@
1
- import { Field, Provable, Character, Poseidon } from 'o1js';
2
- import { PackingPlant, MultiPackingPlant } from '../PackingPlant.js';
3
- const SIZE_IN_BITS = 16n;
4
- const L = 15; // Default to one-field worth of characters
5
- const CHARS_PER_FIELD = 15;
6
- export function PackedStringFactory(l = L) {
7
- class PackedString_ extends PackingPlant(Character, l, SIZE_IN_BITS) {
8
- static extractField(input) {
9
- return input.value;
10
- }
11
- static sizeInBits() {
12
- return SIZE_IN_BITS;
13
- }
14
- /**
15
- *
16
- * @param f Field, packed with the information, as returned by #pack
17
- * @returns Array of Character
18
- */
19
- static unpack(f) {
20
- const unpacked = Provable.witness(Provable.Array(Character, l), () => {
21
- const unpacked = this.unpackToBigints(f);
22
- return unpacked.map((x) => Character.fromString(String.fromCharCode(Number(x))));
23
- });
24
- f.assertEquals(PackedString_.pack(unpacked));
25
- return unpacked;
26
- }
27
- /**
28
- *
29
- * @param characters Array of Character to be packed
30
- * @returns Instance of the implementing class
31
- */
32
- static fromCharacters(input) {
33
- let characters = new Array(this.l);
34
- characters.fill(new Character(Field(0)), 0, this.l);
35
- for (let i = 0; i < input.length; i++) {
36
- characters[i] = input[i];
37
- }
38
- const packed = this.pack(characters);
39
- return new PackedString_(packed);
40
- }
41
- /**
42
- *
43
- * @param str string to be packed
44
- * @returns Instance of the implementing class
45
- */
46
- static fromString(str) {
47
- let characters = new Array(this.l);
48
- characters.fill(new Character(Field(0)), 0, this.l);
49
- for (let i = 0; i < str.length; i++) {
50
- characters[i] = Character.fromString(str[i]);
51
- }
52
- return this.fromCharacters(characters);
53
- }
54
- toString() {
55
- const nullChar = String.fromCharCode(0);
56
- return PackedString_.unpack(this.packed)
57
- .filter((c) => c.toString() !== nullChar)
58
- .join('');
59
- }
60
- }
61
- return PackedString_;
62
- }
63
- /**
64
- *
65
- * @param n number of fields to employ to store the string
66
- * @returns MultiPackedString_ class with length of n * CHARS_PER_FIELD
67
- */
68
- export function MultiPackedStringFactory(n = 8) {
69
- class MultiPackedString_ extends MultiPackingPlant(Character, n * CHARS_PER_FIELD, SIZE_IN_BITS) {
70
- static extractField(input) {
71
- return input.value;
72
- }
73
- static sizeInBits() {
74
- return SIZE_IN_BITS;
75
- }
76
- static elementsPerField() {
77
- return CHARS_PER_FIELD;
78
- }
79
- /**
80
- *
81
- * @param fields Array of Fields, containing packed Characters
82
- * @returns Array of Character
83
- */
84
- static unpack(fields) {
85
- const unpacked = Provable.witness(Provable.Array(Character, this.l), () => {
86
- let unpacked = this.unpackToBigints(fields);
87
- return unpacked.map((x) => Character.fromString(String.fromCharCode(Number(x))));
88
- });
89
- Poseidon.hash(fields).assertEquals(Poseidon.hash(MultiPackedString_.pack(unpacked)));
90
- return unpacked;
91
- }
92
- /**
93
- *
94
- * @param characters Array of Character to be packed
95
- * @returns Instance of the implementing class
96
- */
97
- static fromCharacters(input) {
98
- let characters = new Array(this.l);
99
- characters.fill(new Character(Field(0)), 0, this.l);
100
- for (let i = 0; i < input.length; i++) {
101
- characters[i] = input[i];
102
- }
103
- const packed = this.pack(characters);
104
- return new MultiPackedString_(packed);
105
- }
106
- /**
107
- *
108
- * @param str string to be packed
109
- * @returns Instance of the implementing class
110
- */
111
- static fromString(str) {
112
- let characters = new Array(this.l);
113
- characters.fill(new Character(Field(0)), 0, this.l);
114
- for (let i = 0; i < str.length; i++) {
115
- characters[i] = Character.fromString(str[i]);
116
- }
117
- return this.fromCharacters(characters);
118
- }
119
- toString() {
120
- const nullChar = String.fromCharCode(0);
121
- return MultiPackedString_.unpack(this.packed)
122
- .filter((c) => c.toString() !== nullChar)
123
- .join('');
124
- }
125
- }
126
- return MultiPackedString_;
127
- }
1
+ import { Field, Provable, Character, Poseidon } from 'o1js';
2
+ import { PackingPlant, MultiPackingPlant } from '../PackingPlant.js';
3
+ const SIZE_IN_BITS = 16n;
4
+ const L = 15; // Default to one-field worth of characters
5
+ const CHARS_PER_FIELD = 15;
6
+ export function PackedStringFactory(l = L) {
7
+ class PackedString_ extends PackingPlant(Character, l, SIZE_IN_BITS) {
8
+ static extractField(input) {
9
+ return input.value;
10
+ }
11
+ static sizeInBits() {
12
+ return SIZE_IN_BITS;
13
+ }
14
+ /**
15
+ *
16
+ * @param f Field, packed with the information, as returned by #pack
17
+ * @returns Array of Character
18
+ */
19
+ static unpack(f) {
20
+ const unpacked = Provable.witness(Provable.Array(Character, l), () => {
21
+ const unpacked = this.unpackToBigints(f);
22
+ return unpacked.map((x) => Character.fromString(String.fromCharCode(Number(x))));
23
+ });
24
+ f.assertEquals(PackedString_.pack(unpacked));
25
+ return unpacked;
26
+ }
27
+ /**
28
+ *
29
+ * @param characters Array of Character to be packed
30
+ * @returns Instance of the implementing class
31
+ */
32
+ static fromCharacters(input) {
33
+ let characters = new Array(this.l);
34
+ characters.fill(new Character(Field(0)), 0, this.l);
35
+ for (let i = 0; i < input.length; i++) {
36
+ characters[i] = input[i];
37
+ }
38
+ const packed = this.pack(characters);
39
+ return new PackedString_(packed);
40
+ }
41
+ /**
42
+ *
43
+ * @param str string to be packed
44
+ * @returns Instance of the implementing class
45
+ */
46
+ static fromString(str) {
47
+ let characters = new Array(this.l);
48
+ characters.fill(new Character(Field(0)), 0, this.l);
49
+ for (let i = 0; i < str.length; i++) {
50
+ characters[i] = Character.fromString(str[i]);
51
+ }
52
+ return this.fromCharacters(characters);
53
+ }
54
+ toString() {
55
+ const nullChar = String.fromCharCode(0);
56
+ return PackedString_.unpack(this.packed)
57
+ .filter((c) => c.toString() !== nullChar)
58
+ .join('');
59
+ }
60
+ }
61
+ return PackedString_;
62
+ }
63
+ /**
64
+ *
65
+ * @param n number of fields to employ to store the string
66
+ * @returns MultiPackedString_ class with length of n * CHARS_PER_FIELD
67
+ */
68
+ export function MultiPackedStringFactory(n = 8) {
69
+ class MultiPackedString_ extends MultiPackingPlant(Character, n * CHARS_PER_FIELD, SIZE_IN_BITS) {
70
+ static extractField(input) {
71
+ return input.value;
72
+ }
73
+ static sizeInBits() {
74
+ return SIZE_IN_BITS;
75
+ }
76
+ static elementsPerField() {
77
+ return CHARS_PER_FIELD;
78
+ }
79
+ /**
80
+ *
81
+ * @param fields Array of Fields, containing packed Characters
82
+ * @returns Array of Character
83
+ */
84
+ static unpack(fields) {
85
+ const unpacked = Provable.witness(Provable.Array(Character, this.l), () => {
86
+ let unpacked = this.unpackToBigints(fields);
87
+ return unpacked.map((x) => Character.fromString(String.fromCharCode(Number(x))));
88
+ });
89
+ Poseidon.hash(fields).assertEquals(Poseidon.hash(MultiPackedString_.pack(unpacked)));
90
+ return unpacked;
91
+ }
92
+ /**
93
+ *
94
+ * @param characters Array of Character to be packed
95
+ * @returns Instance of the implementing class
96
+ */
97
+ static fromCharacters(input) {
98
+ let characters = new Array(this.l);
99
+ characters.fill(new Character(Field(0)), 0, this.l);
100
+ for (let i = 0; i < input.length; i++) {
101
+ characters[i] = input[i];
102
+ }
103
+ const packed = this.pack(characters);
104
+ return new MultiPackedString_(packed);
105
+ }
106
+ /**
107
+ *
108
+ * @param str string to be packed
109
+ * @returns Instance of the implementing class
110
+ */
111
+ static fromString(str) {
112
+ let characters = new Array(this.l);
113
+ characters.fill(new Character(Field(0)), 0, this.l);
114
+ for (let i = 0; i < str.length; i++) {
115
+ characters[i] = Character.fromString(str[i]);
116
+ }
117
+ return this.fromCharacters(characters);
118
+ }
119
+ toString() {
120
+ const nullChar = String.fromCharCode(0);
121
+ return MultiPackedString_.unpack(this.packed)
122
+ .filter((c) => c.toString() !== nullChar)
123
+ .join('');
124
+ }
125
+ }
126
+ return MultiPackedString_;
127
+ }
128
128
  //# sourceMappingURL=PackedString.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,101 +1,101 @@
1
- import { Character, Provable } from 'o1js';
2
- import { PackedStringFactory, MultiPackedStringFactory } from './PackedString';
3
- describe('PackedString', () => {
4
- describe('Outside of the Circuit', () => {
5
- const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
6
- class EthAddressString extends MultiPackedStringFactory(3) {
7
- }
8
- let characters = [];
9
- beforeEach(() => {
10
- characters = [];
11
- for (let i = 0; i < vitalik_dot_eth.length; i++) {
12
- characters.push(Character.fromString(vitalik_dot_eth[i]));
13
- }
14
- });
15
- it('#fromString', () => {
16
- const myEthAddress = EthAddressString.fromString(vitalik_dot_eth);
17
- expect(myEthAddress.toString()).toBe(vitalik_dot_eth);
18
- });
19
- it('#fromCharacters', () => {
20
- const myEthAddress = EthAddressString.fromCharacters(characters);
21
- expect(myEthAddress.toString()).toBe(vitalik_dot_eth);
22
- });
23
- it('#pack and #unPack', () => {
24
- const unpacked = EthAddressString.unpack(EthAddressString.fromCharacters(characters).packed);
25
- const packed = EthAddressString.pack(unpacked);
26
- expect(packed.length).toBe(Math.ceil(vitalik_dot_eth.length / 15));
27
- expect(unpacked.length).toBe(EthAddressString.l);
28
- expect(unpacked.length).toBe(45);
29
- expect(unpacked.slice(0, characters.length).toString()).toBe(characters.toString());
30
- });
31
- });
32
- describe('Provable Properties', () => {
33
- it('#sizeInFields', () => {
34
- class one extends PackedStringFactory(15) {
35
- }
36
- class two extends MultiPackedStringFactory(2) {
37
- }
38
- class three extends MultiPackedStringFactory(3) {
39
- }
40
- expect(one.sizeInFields()).toBe(1);
41
- expect(two.sizeInFields()).toBe(2);
42
- expect(three.sizeInFields()).toBe(3);
43
- });
44
- });
45
- describe('Defensive Cases', () => {
46
- it('Initializes a class with fewer than allowed characters', () => {
47
- class String10 extends PackedStringFactory(10) {
48
- }
49
- const string0 = String10.fromString('');
50
- const string2 = String10.fromString('ab');
51
- expect(string0.toString()).toBe('');
52
- expect(string2.toString()).toBe('ab');
53
- });
54
- it('Initializes a class with more than allowed characters', () => {
55
- class String10 extends PackedStringFactory(10) {
56
- }
57
- expect(() => {
58
- String10.fromString('abcdefghijk');
59
- }).toThrow();
60
- });
61
- it('Exceeds maximum size string', () => {
62
- const tooLong = 'too long!'.repeat(20);
63
- class MaxString extends MultiPackedStringFactory(8) {
64
- }
65
- expect(() => {
66
- MaxString.fromString(tooLong);
67
- }).toThrow();
68
- });
69
- });
70
- describe('In the circuit', () => {
71
- const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
72
- class EthAddressString extends MultiPackedStringFactory(3) {
73
- }
74
- const outsideEthAddress = EthAddressString.fromString(vitalik_dot_eth);
75
- it('Initializes a string', () => {
76
- expect(() => {
77
- Provable.runAndCheck(() => {
78
- const myEthAddress = new EthAddressString(outsideEthAddress.packed);
79
- EthAddressString.check({ packed: myEthAddress.packed });
80
- });
81
- }).not.toThrow();
82
- });
83
- it('#assertEquals', () => {
84
- expect(() => {
85
- Provable.runAndCheck(() => {
86
- const myEthAddress = new EthAddressString(outsideEthAddress.packed);
87
- myEthAddress.assertEquals(outsideEthAddress);
88
- });
89
- }).not.toThrow();
90
- expect(() => {
91
- Provable.runAndCheck(() => {
92
- const fakePacked = [...outsideEthAddress.packed];
93
- fakePacked[0] = fakePacked[0].add(1);
94
- const myEthAddress = new EthAddressString(fakePacked);
95
- myEthAddress.assertEquals(outsideEthAddress);
96
- });
97
- }).toThrow();
98
- });
99
- });
100
- });
1
+ import { Character, Provable } from 'o1js';
2
+ import { PackedStringFactory, MultiPackedStringFactory } from './PackedString';
3
+ describe('PackedString', () => {
4
+ describe('Outside of the Circuit', () => {
5
+ const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
6
+ class EthAddressString extends MultiPackedStringFactory(3) {
7
+ }
8
+ let characters = [];
9
+ beforeEach(() => {
10
+ characters = [];
11
+ for (let i = 0; i < vitalik_dot_eth.length; i++) {
12
+ characters.push(Character.fromString(vitalik_dot_eth[i]));
13
+ }
14
+ });
15
+ it('#fromString', () => {
16
+ const myEthAddress = EthAddressString.fromString(vitalik_dot_eth);
17
+ expect(myEthAddress.toString()).toBe(vitalik_dot_eth);
18
+ });
19
+ it('#fromCharacters', () => {
20
+ const myEthAddress = EthAddressString.fromCharacters(characters);
21
+ expect(myEthAddress.toString()).toBe(vitalik_dot_eth);
22
+ });
23
+ it('#pack and #unPack', () => {
24
+ const unpacked = EthAddressString.unpack(EthAddressString.fromCharacters(characters).packed);
25
+ const packed = EthAddressString.pack(unpacked);
26
+ expect(packed.length).toBe(Math.ceil(vitalik_dot_eth.length / 15));
27
+ expect(unpacked.length).toBe(EthAddressString.l);
28
+ expect(unpacked.length).toBe(45);
29
+ expect(unpacked.slice(0, characters.length).toString()).toBe(characters.toString());
30
+ });
31
+ });
32
+ describe('Provable Properties', () => {
33
+ it('#sizeInFields', () => {
34
+ class one extends PackedStringFactory(15) {
35
+ }
36
+ class two extends MultiPackedStringFactory(2) {
37
+ }
38
+ class three extends MultiPackedStringFactory(3) {
39
+ }
40
+ expect(one.sizeInFields()).toBe(1);
41
+ expect(two.sizeInFields()).toBe(2);
42
+ expect(three.sizeInFields()).toBe(3);
43
+ });
44
+ });
45
+ describe('Defensive Cases', () => {
46
+ it('Initializes a class with fewer than allowed characters', () => {
47
+ class String10 extends PackedStringFactory(10) {
48
+ }
49
+ const string0 = String10.fromString('');
50
+ const string2 = String10.fromString('ab');
51
+ expect(string0.toString()).toBe('');
52
+ expect(string2.toString()).toBe('ab');
53
+ });
54
+ it('Initializes a class with more than allowed characters', () => {
55
+ class String10 extends PackedStringFactory(10) {
56
+ }
57
+ expect(() => {
58
+ String10.fromString('abcdefghijk');
59
+ }).toThrow();
60
+ });
61
+ it('Exceeds maximum size string', () => {
62
+ const tooLong = 'too long!'.repeat(20);
63
+ class MaxString extends MultiPackedStringFactory(8) {
64
+ }
65
+ expect(() => {
66
+ MaxString.fromString(tooLong);
67
+ }).toThrow();
68
+ });
69
+ });
70
+ describe('In the circuit', () => {
71
+ const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
72
+ class EthAddressString extends MultiPackedStringFactory(3) {
73
+ }
74
+ const outsideEthAddress = EthAddressString.fromString(vitalik_dot_eth);
75
+ it('Initializes a string', () => {
76
+ expect(() => {
77
+ Provable.runAndCheck(() => {
78
+ const myEthAddress = new EthAddressString(outsideEthAddress.packed);
79
+ EthAddressString.check({ packed: myEthAddress.packed });
80
+ });
81
+ }).not.toThrow();
82
+ });
83
+ it('#assertEquals', () => {
84
+ expect(() => {
85
+ Provable.runAndCheck(() => {
86
+ const myEthAddress = new EthAddressString(outsideEthAddress.packed);
87
+ myEthAddress.assertEquals(outsideEthAddress);
88
+ });
89
+ }).not.toThrow();
90
+ expect(() => {
91
+ Provable.runAndCheck(() => {
92
+ const fakePacked = [...outsideEthAddress.packed];
93
+ fakePacked[0] = fakePacked[0].add(1);
94
+ const myEthAddress = new EthAddressString(fakePacked);
95
+ myEthAddress.assertEquals(outsideEthAddress);
96
+ });
97
+ }).toThrow();
98
+ });
99
+ });
100
+ });
101
101
  //# sourceMappingURL=PackedString.test.js.map
@@ -1,85 +1,85 @@
1
- import { Field, UInt32 } from 'o1js';
2
- export declare function PackedUInt32Factory(l?: number): {
3
- new (packed: import("o1js/dist/node/lib/field.js").Field): {
4
- toBigInts(): Array<bigint>;
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: UInt32): Field;
12
- sizeInBits(): bigint;
13
- /**
14
- *
15
- * @param f Field, packed with the information, as returned by #pack
16
- * @returns Array of UInt32
17
- */
18
- unpack(f: Field): UInt32[];
19
- /**
20
- *
21
- * @param uint32s Array of UInt32s to be packed
22
- * @returns Instance of the implementing class
23
- */
24
- fromUInt32s(uint32s: Array<UInt32>): {
25
- toBigInts(): Array<bigint>;
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 bigints Array of bigints to be packed
35
- * @returns Instance of the implementing class
36
- */
37
- fromBigInts(bigints: Array<bigint>): {
38
- toBigInts(): Array<bigint>;
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
- type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
46
- packed: import("o1js/dist/node/lib/field.js").Field;
47
- }, {
48
- packed: string;
49
- }>;
50
- l: number;
51
- bitSize: bigint;
52
- checkPack(unpacked: UInt32[]): void;
53
- pack(unpacked: UInt32[]): import("o1js/dist/node/lib/field.js").Field;
54
- unpackToBigints(f: import("o1js/dist/node/lib/field.js").Field): bigint[];
55
- _isStruct: true;
56
- toFields: (value: {
57
- packed: import("o1js/dist/node/lib/field.js").Field;
58
- }) => import("o1js/dist/node/lib/field.js").Field[];
59
- toAuxiliary: (value?: {
60
- packed: import("o1js/dist/node/lib/field.js").Field;
61
- } | undefined) => any[];
62
- fromFields: (fields: import("o1js/dist/node/lib/field.js").Field[]) => {
63
- packed: import("o1js/dist/node/lib/field.js").Field;
64
- };
65
- sizeInFields(): number;
66
- check: (value: {
67
- packed: import("o1js/dist/node/lib/field.js").Field;
68
- }) => void;
69
- toInput: (x: {
70
- packed: import("o1js/dist/node/lib/field.js").Field;
71
- }) => {
72
- fields?: import("o1js/dist/node/lib/field.js").Field[] | undefined;
73
- packed?: [import("o1js/dist/node/lib/field.js").Field, number][] | undefined;
74
- };
75
- toJSON: (x: {
76
- packed: import("o1js/dist/node/lib/field.js").Field;
77
- }) => {
78
- packed: string;
79
- };
80
- fromJSON: (x: {
81
- packed: string;
82
- }) => {
83
- packed: import("o1js/dist/node/lib/field.js").Field;
84
- };
85
- };
1
+ import { Field, UInt32 } from 'o1js';
2
+ export declare function PackedUInt32Factory(l?: number): {
3
+ new (packed: import("o1js/dist/node/lib/field.js").Field): {
4
+ toBigInts(): Array<bigint>;
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: UInt32): Field;
12
+ sizeInBits(): bigint;
13
+ /**
14
+ *
15
+ * @param f Field, packed with the information, as returned by #pack
16
+ * @returns Array of UInt32
17
+ */
18
+ unpack(f: Field): UInt32[];
19
+ /**
20
+ *
21
+ * @param uint32s Array of UInt32s to be packed
22
+ * @returns Instance of the implementing class
23
+ */
24
+ fromUInt32s(uint32s: Array<UInt32>): {
25
+ toBigInts(): Array<bigint>;
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 bigints Array of bigints to be packed
35
+ * @returns Instance of the implementing class
36
+ */
37
+ fromBigInts(bigints: Array<bigint>): {
38
+ toBigInts(): Array<bigint>;
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
+ type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
46
+ packed: import("o1js/dist/node/lib/field.js").Field;
47
+ }, {
48
+ packed: string;
49
+ }>;
50
+ l: number;
51
+ bitSize: bigint;
52
+ checkPack(unpacked: UInt32[]): void;
53
+ pack(unpacked: UInt32[]): import("o1js/dist/node/lib/field.js").Field;
54
+ unpackToBigints(f: import("o1js/dist/node/lib/field.js").Field): bigint[];
55
+ _isStruct: true;
56
+ toFields: (value: {
57
+ packed: import("o1js/dist/node/lib/field.js").Field;
58
+ }) => import("o1js/dist/node/lib/field.js").Field[];
59
+ toAuxiliary: (value?: {
60
+ packed: import("o1js/dist/node/lib/field.js").Field;
61
+ } | undefined) => any[];
62
+ fromFields: (fields: import("o1js/dist/node/lib/field.js").Field[]) => {
63
+ packed: import("o1js/dist/node/lib/field.js").Field;
64
+ };
65
+ sizeInFields(): number;
66
+ check: (value: {
67
+ packed: import("o1js/dist/node/lib/field.js").Field;
68
+ }) => void;
69
+ toInput: (x: {
70
+ packed: import("o1js/dist/node/lib/field.js").Field;
71
+ }) => {
72
+ fields?: import("o1js/dist/node/lib/field.js").Field[] | undefined;
73
+ packed?: [import("o1js/dist/node/lib/field.js").Field, number][] | undefined;
74
+ };
75
+ toJSON: (x: {
76
+ packed: import("o1js/dist/node/lib/field.js").Field;
77
+ }) => {
78
+ packed: string;
79
+ };
80
+ fromJSON: (x: {
81
+ packed: string;
82
+ }) => {
83
+ packed: import("o1js/dist/node/lib/field.js").Field;
84
+ };
85
+ };