o1js-pack 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.husky/pre-commit +0 -0
- package/README.md +9 -30
- package/build/src/index.d.ts +5 -5
- package/build/src/index.js +5 -5
- package/build/src/lib/PackingPlant.d.ts +132 -140
- package/build/src/lib/PackingPlant.js +190 -191
- package/build/src/lib/PackingPlant.js.map +1 -1
- package/build/src/lib/packed-types/PackedBool.d.ts +85 -90
- package/build/src/lib/packed-types/PackedBool.js +49 -48
- package/build/src/lib/packed-types/PackedBool.js.map +1 -1
- package/build/src/lib/packed-types/PackedBool.test.d.ts +1 -1
- package/build/src/lib/packed-types/PackedBool.test.js +75 -75
- package/build/src/lib/packed-types/PackedString.d.ts +181 -92
- package/build/src/lib/packed-types/PackedString.js +127 -59
- package/build/src/lib/packed-types/PackedString.js.map +1 -1
- package/build/src/lib/packed-types/PackedString.test.d.ts +1 -1
- package/build/src/lib/packed-types/PackedString.test.js +100 -99
- package/build/src/lib/packed-types/PackedString.test.js.map +1 -1
- package/build/src/lib/packed-types/PackedUInt32.d.ts +85 -90
- package/build/src/lib/packed-types/PackedUInt32.js +49 -48
- package/build/src/lib/packed-types/PackedUInt32.js.map +1 -1
- package/build/src/lib/packed-types/PackedUInt32.test.d.ts +1 -1
- package/build/src/lib/packed-types/PackedUInt32.test.js +83 -83
- package/package.json +1 -1
- package/tests/provable/end_to_end.test.ts +2 -4
- package/tests/provable/example_packed_string_circuit.ts +3 -8
- package/tests/provable/example_packed_uint_circuit.ts +6 -12
- package/build/src/lib/packed-types/PackedCharacter.d.ts +0 -51
- package/build/src/lib/packed-types/PackedCharacter.js +0 -34
- package/build/src/lib/packed-types/PackedCharacter.js.map +0 -1
- package/build/src/lib/packed-types/PackedCharacter.test.d.ts +0 -1
- package/build/src/lib/packed-types/PackedCharacter.test.js +0 -31
- package/build/src/lib/packed-types/PackedCharacter.test.js.map +0 -1
- package/build/src/lib/scratch.d.ts +0 -1
- package/build/src/lib/scratch.js +0 -16
- package/build/src/lib/scratch.js.map +0 -1
- package/build/src/packed-types/PackedBool.d.ts +0 -51
- package/build/src/packed-types/PackedBool.js +0 -34
- package/build/src/packed-types/PackedBool.js.map +0 -1
- package/build/src/packed-types/PackedBool.test.d.ts +0 -1
- package/build/src/packed-types/PackedBool.test.js +0 -101
- package/build/src/packed-types/PackedBool.test.js.map +0 -1
- package/build/src/packed-types/PackedCharacter.d.ts +0 -51
- package/build/src/packed-types/PackedCharacter.js +0 -34
- package/build/src/packed-types/PackedCharacter.js.map +0 -1
- package/build/src/packed-types/PackedCharacter.test.d.ts +0 -1
- package/build/src/packed-types/PackedCharacter.test.js +0 -31
- package/build/src/packed-types/PackedCharacter.test.js.map +0 -1
- package/build/src/packed-types/PackedUInt32.d.ts +0 -51
- package/build/src/packed-types/PackedUInt32.js +0 -34
- package/build/src/packed-types/PackedUInt32.js.map +0 -1
- package/build/src/packed-types/PackedUInt32.test.d.ts +0 -1
- package/build/src/packed-types/PackedUInt32.test.js +0 -68
- package/build/src/packed-types/PackedUInt32.test.js.map +0 -1
- package/build/src/packed-types/PackingPlant.d.ts +0 -54
- package/build/src/packed-types/PackingPlant.js +0 -45
- package/build/src/packed-types/PackingPlant.js.map +0 -1
- package/build/src/packed-types/scratch.d.ts +0 -1
- package/build/src/packed-types/scratch.js +0 -5
- package/build/src/packed-types/scratch.js.map +0 -1
- package/coverage/clover.xml +0 -166
- package/coverage/coverage-final.json +0 -5
- package/coverage/lcov-report/PackedBool.ts.html +0 -268
- package/coverage/lcov-report/PackedUInt32.ts.html +0 -313
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -131
- package/coverage/lcov-report/lib/PackingPlant.ts.html +0 -478
- package/coverage/lcov-report/lib/index.html +0 -116
- package/coverage/lcov-report/lib/packed-types/PackedBool.ts.html +0 -238
- package/coverage/lcov-report/lib/packed-types/PackedString.ts.html +0 -364
- package/coverage/lcov-report/lib/packed-types/PackedUInt32.ts.html +0 -238
- package/coverage/lcov-report/lib/packed-types/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -282
@@ -1,192 +1,191 @@
|
|
1
|
-
import { Field, Struct, provable, Provable, } from 'o1js';
|
2
|
-
const MAX_BITS_PER_FIELD = 254n;
|
3
|
-
export function PackingPlant(elementType, l, bitSize) {
|
4
|
-
if (bitSize * BigInt(l) > MAX_BITS_PER_FIELD) {
|
5
|
-
throw new Error(`The Packing Plant is only accepting orders that can fit into one Field, try using MultiPackingPlant`);
|
6
|
-
}
|
7
|
-
class Packed_ extends Struct({
|
8
|
-
packed: Field,
|
9
|
-
}) {
|
10
|
-
constructor(packed) {
|
11
|
-
super({ packed });
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
*
|
27
|
-
* @
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
*
|
37
|
-
* @
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
this.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
*
|
52
|
-
* @
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
Packed_.
|
76
|
-
Packed_.
|
77
|
-
return Packed_;
|
78
|
-
}
|
79
|
-
export function MultiPackingPlant(elementType, l, bitSize) {
|
80
|
-
if (bitSize * BigInt(l) > 8n * MAX_BITS_PER_FIELD) {
|
81
|
-
throw new Error(`The Packing Plant is only accepting orders that can fit into eight Fields`);
|
82
|
-
}
|
83
|
-
const n = Math.ceil(Number(bitSize * BigInt(l)) / Number(255n));
|
84
|
-
class Packed_ extends Struct({
|
85
|
-
packed: Provable.Array(Field, n),
|
86
|
-
}) {
|
87
|
-
constructor(packed) {
|
88
|
-
super({ packed });
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
*
|
107
|
-
* @
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
*
|
117
|
-
* @
|
118
|
-
*
|
119
|
-
*
|
120
|
-
*
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
this.
|
125
|
-
let fields = [];
|
126
|
-
let mutableUnpacked = [...unpacked];
|
127
|
-
|
128
|
-
let f = this.extractField(mutableUnpacked
|
129
|
-
if (!f) {
|
130
|
-
throw new Error('Unexpected Array Length');
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
*
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
let
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
Packed_.
|
188
|
-
Packed_.
|
189
|
-
Packed_
|
190
|
-
|
191
|
-
}
|
1
|
+
import { Field, Struct, provable, Provable, } from 'o1js';
|
2
|
+
const MAX_BITS_PER_FIELD = 254n;
|
3
|
+
export function PackingPlant(elementType, l, bitSize) {
|
4
|
+
if (bitSize * BigInt(l) > MAX_BITS_PER_FIELD) {
|
5
|
+
throw new Error(`The Packing Plant is only accepting orders that can fit into one Field, try using MultiPackingPlant`);
|
6
|
+
}
|
7
|
+
class Packed_ extends Struct({
|
8
|
+
packed: Field,
|
9
|
+
}) {
|
10
|
+
constructor(packed) {
|
11
|
+
super({ packed });
|
12
|
+
}
|
13
|
+
// Must implement these in type-specific implementation
|
14
|
+
static extractField(input) {
|
15
|
+
throw new Error('Must implement extractField');
|
16
|
+
}
|
17
|
+
static sizeInBits() {
|
18
|
+
throw new Error('Must implement sizeInBits');
|
19
|
+
}
|
20
|
+
static unpack(f) {
|
21
|
+
throw new Error('Must implement unpack');
|
22
|
+
}
|
23
|
+
// End
|
24
|
+
/**
|
25
|
+
*
|
26
|
+
* @param unpacked Array of the implemented packed type
|
27
|
+
* @throws if the length of the array is longer than the length of the implementing factory config
|
28
|
+
*/
|
29
|
+
static checkPack(unpacked) {
|
30
|
+
if (unpacked.length > l) {
|
31
|
+
throw new Error(`Input of size ${unpacked.length} is larger than expected size of ${l}`);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
*
|
36
|
+
* @param unpacked Array of the implemented packed type, must be shorter than the max allowed, which varies by type, will throw if the input is too long
|
37
|
+
* @returns Field, packed with the information from the unpacked input
|
38
|
+
*/
|
39
|
+
static pack(unpacked) {
|
40
|
+
this.checkPack(unpacked);
|
41
|
+
let f = this.extractField(unpacked[0]);
|
42
|
+
const n = Math.min(unpacked.length, l);
|
43
|
+
for (let i = 1; i < n; i++) {
|
44
|
+
const c = Field((2n ** this.sizeInBits()) ** BigInt(i));
|
45
|
+
f = f.add(this.extractField(unpacked[i]).mul(c));
|
46
|
+
}
|
47
|
+
return f;
|
48
|
+
}
|
49
|
+
/**
|
50
|
+
*
|
51
|
+
* @param f Field, packed with the information, as returned by #pack
|
52
|
+
* @returns Array of bigints, which can be decoded by the implementing class into the final type
|
53
|
+
*/
|
54
|
+
static unpackToBigints(f) {
|
55
|
+
let unpacked = new Array(l);
|
56
|
+
unpacked.fill(0n);
|
57
|
+
let packedN;
|
58
|
+
if (f) {
|
59
|
+
packedN = f.toBigInt();
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
throw new Error('No Packed Value Provided');
|
63
|
+
}
|
64
|
+
for (let i = 0; i < l; i++) {
|
65
|
+
unpacked[i] = packedN & ((1n << this.sizeInBits()) - 1n);
|
66
|
+
packedN >>= this.sizeInBits();
|
67
|
+
}
|
68
|
+
return unpacked;
|
69
|
+
}
|
70
|
+
assertEquals(other) {
|
71
|
+
this.packed.assertEquals(other.packed);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
Packed_.type = provable({ packed: Field }, {});
|
75
|
+
Packed_.l = l;
|
76
|
+
Packed_.bitSize = bitSize;
|
77
|
+
return Packed_;
|
78
|
+
}
|
79
|
+
export function MultiPackingPlant(elementType, l, bitSize) {
|
80
|
+
if (bitSize * BigInt(l) > 8n * MAX_BITS_PER_FIELD) {
|
81
|
+
throw new Error(`The Packing Plant is only accepting orders that can fit into eight Fields`);
|
82
|
+
}
|
83
|
+
const n = Math.ceil(Number(bitSize * BigInt(l)) / Number(255n));
|
84
|
+
class Packed_ extends Struct({
|
85
|
+
packed: Provable.Array(Field, n),
|
86
|
+
}) {
|
87
|
+
constructor(packed) {
|
88
|
+
super({ packed });
|
89
|
+
}
|
90
|
+
// Must implement these in type-specific implementation
|
91
|
+
static extractField(input) {
|
92
|
+
throw new Error('Must implement extractField');
|
93
|
+
}
|
94
|
+
static sizeInBits() {
|
95
|
+
throw new Error('Must implement sizeInBits');
|
96
|
+
}
|
97
|
+
static elementsPerField() {
|
98
|
+
throw new Error('Must implement elementsPerField');
|
99
|
+
}
|
100
|
+
static unpack(fields) {
|
101
|
+
throw new Error('Must implement unpack');
|
102
|
+
}
|
103
|
+
// End
|
104
|
+
/**
|
105
|
+
*
|
106
|
+
* @param unpacked Array of the implemented packed type
|
107
|
+
* @throws if the length of the array is longer than the length of the implementing factory config
|
108
|
+
*/
|
109
|
+
static checkPack(unpacked) {
|
110
|
+
if (unpacked.length > this.l) {
|
111
|
+
throw new Error(`Input of size ${unpacked.length} is larger than expected size of ${l}`);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
*
|
116
|
+
* @param unpacked Array of the implemented packed type, must be shorter than the max allowed, which varies by type, will throw if the input is too long
|
117
|
+
* @returns Array of Fields, packed such that each Field has as much information as possible
|
118
|
+
*
|
119
|
+
* e.g. 15 Characters pack into 1 Field. 15 or fewer Characters will return an array of 1 Field
|
120
|
+
* 30 of fewer Characters will return an aray of 2 Fields
|
121
|
+
*/
|
122
|
+
static pack(unpacked) {
|
123
|
+
this.checkPack(unpacked);
|
124
|
+
const q = this.elementsPerField();
|
125
|
+
let fields = [];
|
126
|
+
let mutableUnpacked = [...unpacked];
|
127
|
+
for (let i = 0; i < this.n; i++) {
|
128
|
+
let f = this.extractField(mutableUnpacked[i * q]);
|
129
|
+
if (!f) {
|
130
|
+
throw new Error('Unexpected Array Length');
|
131
|
+
}
|
132
|
+
for (let j = 1; j < q; j++) {
|
133
|
+
const idx = i * q + j;
|
134
|
+
let value = this.extractField(mutableUnpacked[idx]);
|
135
|
+
if (!value) {
|
136
|
+
throw new Error('Unexpected Array Length');
|
137
|
+
}
|
138
|
+
value = value || Field(0);
|
139
|
+
const c = Field((2n ** this.sizeInBits()) ** BigInt(j));
|
140
|
+
f = f.add(value.mul(c));
|
141
|
+
}
|
142
|
+
fields.push(f);
|
143
|
+
}
|
144
|
+
return fields;
|
145
|
+
}
|
146
|
+
/**
|
147
|
+
*
|
148
|
+
* @param fields Array of Fields, packed such that each Field has as much information as possible, as returned in #pack
|
149
|
+
* @returns Array of bigints, which can be decoded by the implementing class into the final type
|
150
|
+
*/
|
151
|
+
static unpackToBigints(fields) {
|
152
|
+
let uints_ = new Array(this.l); // array length is number of elements per field * number of fields
|
153
|
+
uints_.fill(0n);
|
154
|
+
let packedNs = new Array(this.n);
|
155
|
+
packedNs.fill(0n);
|
156
|
+
const packedArg = new Array(this.n);
|
157
|
+
packedArg.fill(Field(0), 0, this.n);
|
158
|
+
for (let i = 0; i < this.n; i++) {
|
159
|
+
if (fields[i]) {
|
160
|
+
packedArg[i] = fields[i];
|
161
|
+
}
|
162
|
+
}
|
163
|
+
if (packedArg.length !== this.n) {
|
164
|
+
throw new Error(`Packed value must be exactly ${this.n} in length`);
|
165
|
+
}
|
166
|
+
for (let i = 0; i < this.n; i++) {
|
167
|
+
packedNs[i] = packedArg[i].toConstant().toBigInt();
|
168
|
+
}
|
169
|
+
for (let i = 0; i < packedNs.length; i++) {
|
170
|
+
let packedN = packedNs[i];
|
171
|
+
for (let j = 0; j < this.elementsPerField(); j++) {
|
172
|
+
const k = i * this.elementsPerField() + j;
|
173
|
+
uints_[k] = packedN & ((1n << this.sizeInBits()) - 1n);
|
174
|
+
packedN >>= this.sizeInBits();
|
175
|
+
}
|
176
|
+
}
|
177
|
+
return uints_;
|
178
|
+
}
|
179
|
+
assertEquals(other) {
|
180
|
+
for (let x = 0; x < n; x++) {
|
181
|
+
this.packed[x].assertEquals(other.packed[x]);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
Packed_.type = provable({ packed: Provable.Array(Field, n) }, {});
|
186
|
+
Packed_.l = l;
|
187
|
+
Packed_.n = n;
|
188
|
+
Packed_.bitSize = bitSize;
|
189
|
+
return Packed_;
|
190
|
+
}
|
192
191
|
//# sourceMappingURL=PackingPlant.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PackingPlant.js","sourceRoot":"","sources":["../../../src/lib/PackingPlant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EAEN,QAAQ,EAER,QAAQ,GACT,MAAM,MAAM,CAAC;AAEd,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,MAAM,UAAU,YAAY,CAC1B,WAAc,EACd,CAAS,EACT,OAAe;IAEf,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,kBAAkB,EAAE;QAC5C,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAC;KACH;IACD,MAAe,OAAQ,SAAQ,MAAM,CAAC;QACpC,MAAM,EAAE,KAAK;KACd,CAAC;QAKA,YAAY,MAAa;YACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"PackingPlant.js","sourceRoot":"","sources":["../../../src/lib/PackingPlant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EAEN,QAAQ,EAER,QAAQ,GACT,MAAM,MAAM,CAAC;AAEd,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,MAAM,UAAU,YAAY,CAC1B,WAAc,EACd,CAAS,EACT,OAAe;IAEf,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,kBAAkB,EAAE;QAC5C,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAC;KACH;IACD,MAAe,OAAQ,SAAQ,MAAM,CAAC;QACpC,MAAM,EAAE,KAAK;KACd,CAAC;QAKA,YAAY,MAAa;YACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACpB,CAAC;QAED,uDAAuD;QACvD,MAAM,CAAC,YAAY,CAAC,KAAQ;YAC1B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,C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AAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9C;QACH,CAAC;;IA5GM,YAAI,GAAG,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1D,SAAC,GAAW,CAAC,CAAC;IACd,SAAC,GAAW,CAAC,CAAC;IACd,eAAO,GAAW,OAAO,CAAC;IA2GnC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
@@ -1,90 +1,85 @@
|
|
1
|
-
import { Field, Bool } from 'o1js';
|
2
|
-
export declare function PackedBoolFactory(l?: number): {
|
3
|
-
new (packed: import("o1js/dist/node/lib/field.js").Field): {
|
4
|
-
toBooleans(): Array<boolean>;
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
*
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
*
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
packed
|
79
|
-
};
|
80
|
-
|
81
|
-
packed:
|
82
|
-
}) => {
|
83
|
-
packed:
|
84
|
-
};
|
85
|
-
|
86
|
-
packed: string;
|
87
|
-
}) => {
|
88
|
-
packed: import("o1js/dist/node/lib/field.js").Field;
|
89
|
-
};
|
90
|
-
};
|
1
|
+
import { Field, Bool } from 'o1js';
|
2
|
+
export declare function PackedBoolFactory(l?: number): {
|
3
|
+
new (packed: import("o1js/dist/node/lib/field.js").Field): {
|
4
|
+
toBooleans(): Array<boolean>;
|
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: Bool): Field;
|
12
|
+
sizeInBits(): bigint;
|
13
|
+
/**
|
14
|
+
*
|
15
|
+
* @param f Field, packed with the information, as returned by #pack
|
16
|
+
* @returns Array of Bool
|
17
|
+
*/
|
18
|
+
unpack(f: Field): Bool[];
|
19
|
+
/**
|
20
|
+
*
|
21
|
+
* @param bools Array of Bools to be packed
|
22
|
+
* @returns Instance of the implementing class
|
23
|
+
*/
|
24
|
+
fromBools(bools: Array<Bool>): {
|
25
|
+
toBooleans(): Array<boolean>;
|
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 booleans Array of booleans to be packed
|
35
|
+
* @returns Instance of the implementing class
|
36
|
+
*/
|
37
|
+
fromBooleans(booleans: Array<boolean>): {
|
38
|
+
toBooleans(): Array<boolean>;
|
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: import("o1js/dist/node/lib/bool.js").Bool[]): void;
|
53
|
+
pack(unpacked: import("o1js/dist/node/lib/bool.js").Bool[]): 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
|
+
};
|