o1js-pack 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/ci.yml +1 -1
- package/build/src/lib/PackingPlant.d.ts +66 -18
- package/build/src/lib/PackingPlant.js +145 -28
- package/build/src/lib/PackingPlant.js.map +1 -1
- package/build/src/lib/packed-types/PackedBool.d.ts +34 -21
- package/build/src/lib/packed-types/PackedBool.js +35 -34
- package/build/src/lib/packed-types/PackedBool.js.map +1 -1
- package/build/src/lib/packed-types/PackedBool.test.js +5 -5
- package/build/src/lib/packed-types/PackedBool.test.js.map +1 -1
- package/build/src/lib/packed-types/PackedString.d.ts +35 -21
- package/build/src/lib/packed-types/PackedString.js +38 -61
- package/build/src/lib/packed-types/PackedString.js.map +1 -1
- package/build/src/lib/packed-types/PackedString.test.js +6 -6
- package/build/src/lib/packed-types/PackedString.test.js.map +1 -1
- package/build/src/lib/packed-types/PackedUInt32.d.ts +33 -20
- package/build/src/lib/packed-types/PackedUInt32.js +33 -32
- package/build/src/lib/packed-types/PackedUInt32.js.map +1 -1
- package/build/src/lib/packed-types/PackedUInt32.test.js +4 -4
- package/build/src/lib/packed-types/PackedUInt32.test.js.map +1 -1
- package/package.json +1 -1
- package/tests/provable/end_to_end.test.ts +67 -0
- package/tests/provable/example_packed_string_circuit.ts +52 -0
- package/tests/provable/example_packed_uint_circuit.ts +45 -0
package/.github/workflows/ci.yml
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
import { Field, InferProvable } from 'o1js';
|
2
|
-
export declare function PackingPlant<A, T extends InferProvable<A> = InferProvable<A>>(elementType: A, l: number, bitSize: bigint): (abstract new (packed: Field
|
3
|
-
packed: Field;
|
4
|
-
aux: Array<T>;
|
2
|
+
export declare function PackingPlant<A, T extends InferProvable<A> = InferProvable<A>>(elementType: A, l: number, bitSize: bigint): (abstract new (packed: Field) => {
|
5
3
|
bitSize: bigint;
|
6
4
|
assertEquals(other: any): void;
|
5
|
+
packed: import("o1js/dist/node/lib/field").Field;
|
7
6
|
}) & {
|
8
7
|
type: import("o1js/dist/node/bindings/lib/provable-snarky").ProvableExtended<{
|
9
8
|
packed: import("o1js/dist/node/lib/field").Field;
|
@@ -11,15 +10,38 @@ export declare function PackingPlant<A, T extends InferProvable<A> = InferProvab
|
|
11
10
|
packed: string;
|
12
11
|
}>;
|
13
12
|
l: number;
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
extractField(input: T): Field;
|
14
|
+
sizeInBits(): bigint;
|
15
|
+
unpack(f: Field): Array<T>;
|
16
|
+
/**
|
17
|
+
*
|
18
|
+
* @param unpacked Array of the implemented packed type
|
19
|
+
* @throws if the length of the array is longer than the length of the implementing factory config
|
20
|
+
*/
|
21
|
+
checkPack(unpacked: Array<T>): void;
|
22
|
+
/**
|
23
|
+
*
|
24
|
+
* @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
|
25
|
+
* @returns Field, packed with the information from the unpacked input
|
26
|
+
*/
|
27
|
+
pack(unpacked: Array<T>): Field;
|
28
|
+
/**
|
29
|
+
*
|
30
|
+
* @param f Field, packed with the information, as returned by #pack
|
31
|
+
* @returns Array of bigints, which can be decoded by the implementing class into the final type
|
32
|
+
*/
|
33
|
+
unpackToBigints(f: Field): Array<bigint>;
|
34
|
+
_isStruct: true; /**
|
35
|
+
*
|
36
|
+
* @param fields Array of Fields, packed such that each Field has as much information as possible, as returned in #pack
|
37
|
+
* @returns Array of bigints, which can be decoded by the implementing class into the final type
|
38
|
+
*/
|
20
39
|
toFields: (value: {
|
21
40
|
packed: import("o1js/dist/node/lib/field").Field;
|
22
41
|
}) => import("o1js/dist/node/lib/field").Field[];
|
42
|
+
toAuxiliary: (value?: {
|
43
|
+
packed: import("o1js/dist/node/lib/field").Field;
|
44
|
+
} | undefined) => any[];
|
23
45
|
fromFields: (fields: import("o1js/dist/node/lib/field").Field[]) => {
|
24
46
|
packed: import("o1js/dist/node/lib/field").Field;
|
25
47
|
};
|
@@ -44,11 +66,10 @@ export declare function PackingPlant<A, T extends InferProvable<A> = InferProvab
|
|
44
66
|
packed: import("o1js/dist/node/lib/field").Field;
|
45
67
|
};
|
46
68
|
};
|
47
|
-
export declare function MultiPackingPlant<A, T extends InferProvable<A> = InferProvable<A>>(elementType: A, l: number, bitSize: bigint): (abstract new (packed: Array<Field
|
48
|
-
packed: Array<Field>;
|
49
|
-
aux: Array<T>;
|
69
|
+
export declare function MultiPackingPlant<A, T extends InferProvable<A> = InferProvable<A>>(elementType: A, l: number, bitSize: bigint): (abstract new (packed: Array<Field>) => {
|
50
70
|
bitSize: bigint;
|
51
71
|
assertEquals(other: any): void;
|
72
|
+
packed: import("o1js/dist/node/lib/field").Field[];
|
52
73
|
}) & {
|
53
74
|
type: import("o1js/dist/node/bindings/lib/provable-snarky").ProvableExtended<{
|
54
75
|
packed: import("o1js/dist/node/lib/field").Field[];
|
@@ -57,15 +78,42 @@ export declare function MultiPackingPlant<A, T extends InferProvable<A> = InferP
|
|
57
78
|
}>;
|
58
79
|
l: number;
|
59
80
|
n: number;
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
81
|
+
extractField(input: T | undefined): Field;
|
82
|
+
sizeInBits(): bigint;
|
83
|
+
elementsPerField(): number;
|
84
|
+
unpack(fields: Array<Field>): Array<T>;
|
85
|
+
/**
|
86
|
+
*
|
87
|
+
* @param unpacked Array of the implemented packed type
|
88
|
+
* @throws if the length of the array is longer than the length of the implementing factory config
|
89
|
+
*/
|
90
|
+
checkPack(unpacked: Array<T>): void;
|
91
|
+
/**
|
92
|
+
*
|
93
|
+
* @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
|
94
|
+
* @returns Array of Fields, packed such that each Field has as much information as possible
|
95
|
+
*
|
96
|
+
* e.g. 15 Characters pack into 1 Field. 15 or fewer Characters will return an array of 1 Field
|
97
|
+
* 30 of fewer Characters will return an aray of 2 Fields
|
98
|
+
*/
|
99
|
+
pack(unpacked: Array<T>): Array<Field>;
|
100
|
+
/**
|
101
|
+
*
|
102
|
+
* @param fields Array of Fields, packed such that each Field has as much information as possible, as returned in #pack
|
103
|
+
* @returns Array of bigints, which can be decoded by the implementing class into the final type
|
104
|
+
*/
|
105
|
+
unpackToBigints(fields: Array<Field>): Array<bigint>;
|
106
|
+
_isStruct: true; /**
|
107
|
+
*
|
108
|
+
* @param fields Array of Fields, packed such that each Field has as much information as possible, as returned in #pack
|
109
|
+
* @returns Array of bigints, which can be decoded by the implementing class into the final type
|
110
|
+
*/
|
66
111
|
toFields: (value: {
|
67
112
|
packed: import("o1js/dist/node/lib/field").Field[];
|
68
113
|
}) => import("o1js/dist/node/lib/field").Field[];
|
114
|
+
toAuxiliary: (value?: {
|
115
|
+
packed: import("o1js/dist/node/lib/field").Field[];
|
116
|
+
} | undefined) => any[];
|
69
117
|
fromFields: (fields: import("o1js/dist/node/lib/field").Field[]) => {
|
70
118
|
packed: import("o1js/dist/node/lib/field").Field[];
|
71
119
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Field, Struct,
|
1
|
+
import { Field, Struct, provable, Provable, } from 'o1js';
|
2
2
|
const MAX_BITS_PER_FIELD = 254n;
|
3
3
|
export function PackingPlant(elementType, l, bitSize) {
|
4
4
|
if (bitSize * BigInt(l) > MAX_BITS_PER_FIELD) {
|
@@ -7,25 +7,66 @@ export function PackingPlant(elementType, l, bitSize) {
|
|
7
7
|
class Packed_ extends Struct({
|
8
8
|
packed: Field,
|
9
9
|
}) {
|
10
|
-
constructor(packed
|
11
|
-
if (aux.length > l) {
|
12
|
-
throw new Error(`Length of aux data is too long, input of size ${aux.length} is larger than max allowed ${l}`);
|
13
|
-
}
|
10
|
+
constructor(packed) {
|
14
11
|
super({ packed });
|
15
12
|
this.bitSize = bitSize;
|
16
|
-
this.aux = aux;
|
17
13
|
}
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
// Must implement these in type-specific implementation
|
15
|
+
static extractField(input) {
|
16
|
+
throw new Error('Must implement extractField');
|
21
17
|
}
|
22
|
-
static
|
23
|
-
throw new Error('Must implement
|
24
|
-
let f = Field(0);
|
25
|
-
return f;
|
18
|
+
static sizeInBits() {
|
19
|
+
throw new Error('Must implement sizeInBits');
|
26
20
|
}
|
27
21
|
static unpack(f) {
|
28
|
-
|
22
|
+
throw new Error('Must implement unpack');
|
23
|
+
}
|
24
|
+
// End
|
25
|
+
/**
|
26
|
+
*
|
27
|
+
* @param unpacked Array of the implemented packed type
|
28
|
+
* @throws if the length of the array is longer than the length of the implementing factory config
|
29
|
+
*/
|
30
|
+
static checkPack(unpacked) {
|
31
|
+
if (unpacked.length > l) {
|
32
|
+
throw new Error(`Input of size ${unpacked.length} is larger than expected size of ${l}`);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
*
|
37
|
+
* @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
|
38
|
+
* @returns Field, packed with the information from the unpacked input
|
39
|
+
*/
|
40
|
+
static pack(unpacked) {
|
41
|
+
this.checkPack(unpacked);
|
42
|
+
let f = this.extractField(unpacked[0]);
|
43
|
+
const n = Math.min(unpacked.length, l);
|
44
|
+
for (let i = 1; i < n; i++) {
|
45
|
+
const c = Field((2n ** this.sizeInBits()) ** BigInt(i));
|
46
|
+
f = f.add(this.extractField(unpacked[i]).mul(c));
|
47
|
+
}
|
48
|
+
return f;
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
*
|
52
|
+
* @param f Field, packed with the information, as returned by #pack
|
53
|
+
* @returns Array of bigints, which can be decoded by the implementing class into the final type
|
54
|
+
*/
|
55
|
+
static unpackToBigints(f) {
|
56
|
+
let unpacked = new Array(l);
|
57
|
+
unpacked.fill(0n);
|
58
|
+
let packedN;
|
59
|
+
if (f) {
|
60
|
+
packedN = f.toBigInt();
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
throw new Error('No Packed Value Provided');
|
64
|
+
}
|
65
|
+
for (let i = 0; i < l; i++) {
|
66
|
+
unpacked[i] = packedN & ((1n << this.sizeInBits()) - 1n);
|
67
|
+
packedN >>= this.sizeInBits();
|
68
|
+
}
|
69
|
+
return unpacked;
|
29
70
|
}
|
30
71
|
assertEquals(other) {
|
31
72
|
this.packed.assertEquals(other.packed);
|
@@ -43,28 +84,104 @@ export function MultiPackingPlant(elementType, l, bitSize) {
|
|
43
84
|
class Packed_ extends Struct({
|
44
85
|
packed: Provable.Array(Field, n),
|
45
86
|
}) {
|
46
|
-
constructor(packed
|
47
|
-
if (aux.length > l) {
|
48
|
-
throw new Error('Length of aux data is too long');
|
49
|
-
}
|
87
|
+
constructor(packed) {
|
50
88
|
super({ packed });
|
51
89
|
this.bitSize = bitSize;
|
52
|
-
this.aux = aux;
|
53
90
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
91
|
+
// Must implement these in type-specific implementation
|
92
|
+
static extractField(input) {
|
93
|
+
throw new Error('Must implement extractField');
|
57
94
|
}
|
58
|
-
static
|
59
|
-
throw new Error('Must implement
|
60
|
-
|
61
|
-
|
95
|
+
static sizeInBits() {
|
96
|
+
throw new Error('Must implement sizeInBits');
|
97
|
+
}
|
98
|
+
static elementsPerField() {
|
99
|
+
throw new Error('Must implement elementsPerField');
|
62
100
|
}
|
63
101
|
static unpack(fields) {
|
64
|
-
|
102
|
+
throw new Error('Must implement unpack');
|
103
|
+
}
|
104
|
+
// End
|
105
|
+
/**
|
106
|
+
*
|
107
|
+
* @param unpacked Array of the implemented packed type
|
108
|
+
* @throws if the length of the array is longer than the length of the implementing factory config
|
109
|
+
*/
|
110
|
+
static checkPack(unpacked) {
|
111
|
+
if (unpacked.length > l) {
|
112
|
+
throw new Error(`Input of size ${unpacked.length} is larger than expected size of ${l}`);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
*
|
117
|
+
* @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
|
118
|
+
* @returns Array of Fields, packed such that each Field has as much information as possible
|
119
|
+
*
|
120
|
+
* e.g. 15 Characters pack into 1 Field. 15 or fewer Characters will return an array of 1 Field
|
121
|
+
* 30 of fewer Characters will return an aray of 2 Fields
|
122
|
+
*/
|
123
|
+
static pack(unpacked) {
|
124
|
+
this.checkPack(unpacked);
|
125
|
+
let fields = [];
|
126
|
+
let mutableUnpacked = [...unpacked];
|
127
|
+
while (mutableUnpacked.length > 0) {
|
128
|
+
let f = this.extractField(mutableUnpacked.shift());
|
129
|
+
if (!f) {
|
130
|
+
throw new Error('Unexpected Array Length');
|
131
|
+
}
|
132
|
+
// f = f.value is the same as f = 0; f += char.value * c^0;
|
133
|
+
// If f is initialized as 0, then it is a "constant" field and can't be added to a "variable" field in a proof
|
134
|
+
const n = Math.min(mutableUnpacked.length + 1, this.elementsPerField());
|
135
|
+
for (let i = 1; i < n; i++) {
|
136
|
+
let value = this.extractField(mutableUnpacked.shift());
|
137
|
+
if (!value) {
|
138
|
+
throw new Error('Unexpected Array Length');
|
139
|
+
}
|
140
|
+
value = value || Field(0);
|
141
|
+
const c = Field((2n ** this.sizeInBits()) ** BigInt(i));
|
142
|
+
f = f.add(value.mul(c));
|
143
|
+
}
|
144
|
+
fields.push(f);
|
145
|
+
}
|
146
|
+
return fields;
|
147
|
+
}
|
148
|
+
/**
|
149
|
+
*
|
150
|
+
* @param fields Array of Fields, packed such that each Field has as much information as possible, as returned in #pack
|
151
|
+
* @returns Array of bigints, which can be decoded by the implementing class into the final type
|
152
|
+
*/
|
153
|
+
static unpackToBigints(fields) {
|
154
|
+
let uints_ = new Array(l);
|
155
|
+
uints_.fill(0n);
|
156
|
+
let packedNs = new Array(this.n);
|
157
|
+
packedNs.fill(0n);
|
158
|
+
const packedArg = new Array(this.n);
|
159
|
+
packedArg.fill(Field(0), 0, this.n);
|
160
|
+
for (let i = 0; i < this.n; i++) {
|
161
|
+
if (fields[i]) {
|
162
|
+
packedArg[i] = fields[i];
|
163
|
+
}
|
164
|
+
}
|
165
|
+
if (packedArg.length !== this.n) {
|
166
|
+
throw new Error(`Packed value must be exactly ${this.n} in length`);
|
167
|
+
}
|
168
|
+
for (let i = 0; i < this.n; i++) {
|
169
|
+
packedNs[i] = packedArg[i].toConstant().toBigInt();
|
170
|
+
}
|
171
|
+
for (let i = 0; i < packedNs.length; i++) {
|
172
|
+
let packedN = packedNs[i];
|
173
|
+
for (let j = 0; j < this.elementsPerField(); j++) {
|
174
|
+
const k = i * this.elementsPerField() + j;
|
175
|
+
uints_[k] = packedN & ((1n << this.sizeInBits()) - 1n);
|
176
|
+
packedN >>= this.sizeInBits();
|
177
|
+
}
|
178
|
+
}
|
179
|
+
return uints_;
|
65
180
|
}
|
66
181
|
assertEquals(other) {
|
67
|
-
|
182
|
+
for (let x = 0; x < n; x++) {
|
183
|
+
this.packed[x].assertEquals(other.packed[x]);
|
184
|
+
}
|
68
185
|
}
|
69
186
|
}
|
70
187
|
Packed_.type = provable({ packed: Provable.Array(Field, n) }, {});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PackingPlant.js","sourceRoot":"","sources":["../../../src/lib/PackingPlant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,
|
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,CA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,YAAY,CAAC,KAAc;YACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBAC1B,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9C;QACH,CAAC;;IA7GM,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;IA6GvB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
@@ -1,44 +1,52 @@
|
|
1
1
|
import { Field, Bool } from 'o1js';
|
2
|
-
export declare function PackedBoolFactory(l
|
3
|
-
new (packed: import("o1js/dist/node/lib/field.js").Field
|
2
|
+
export declare function PackedBoolFactory(l?: number): {
|
3
|
+
new (packed: import("o1js/dist/node/lib/field.js").Field): {
|
4
4
|
toBooleans(): Array<boolean>;
|
5
|
-
packed: import("o1js/dist/node/lib/field.js").Field;
|
6
|
-
aux: import("o1js/dist/node/lib/bool.js").Bool[];
|
7
5
|
bitSize: bigint;
|
8
6
|
assertEquals(other: {
|
9
|
-
packed: import("o1js/dist/node/lib/field.js").Field;
|
10
|
-
aux: import("o1js/dist/node/lib/bool.js").Bool[];
|
11
7
|
bitSize: bigint;
|
12
8
|
assertEquals(other: any): void;
|
9
|
+
packed: import("o1js/dist/node/lib/field.js").Field;
|
13
10
|
}): void;
|
11
|
+
packed: import("o1js/dist/node/lib/field.js").Field;
|
14
12
|
};
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
extractField(input: Bool): Field;
|
14
|
+
sizeInBits(): bigint;
|
15
|
+
/**
|
16
|
+
*
|
17
|
+
* @param f Field, packed with the information, as returned by #pack
|
18
|
+
* @returns Array of Bool
|
19
|
+
*/
|
20
|
+
unpack(f: Field): Bool[];
|
21
|
+
/**
|
22
|
+
*
|
23
|
+
* @param bools Array of Bools to be packed
|
24
|
+
* @returns Instance of the implementing class
|
25
|
+
*/
|
26
|
+
fromBools(bools: Array<Bool>): {
|
20
27
|
toBooleans(): Array<boolean>;
|
21
|
-
packed: import("o1js/dist/node/lib/field.js").Field;
|
22
|
-
aux: import("o1js/dist/node/lib/bool.js").Bool[];
|
23
28
|
bitSize: bigint;
|
24
29
|
assertEquals(other: {
|
25
|
-
packed: import("o1js/dist/node/lib/field.js").Field;
|
26
|
-
aux: import("o1js/dist/node/lib/bool.js").Bool[];
|
27
30
|
bitSize: bigint;
|
28
31
|
assertEquals(other: any): void;
|
32
|
+
packed: import("o1js/dist/node/lib/field.js").Field;
|
29
33
|
}): void;
|
34
|
+
packed: import("o1js/dist/node/lib/field.js").Field;
|
30
35
|
};
|
31
|
-
|
36
|
+
/**
|
37
|
+
*
|
38
|
+
* @param booleans Array of booleans to be packed
|
39
|
+
* @returns Instance of the implementing class
|
40
|
+
*/
|
41
|
+
fromBooleans(booleans: Array<boolean>): {
|
32
42
|
toBooleans(): Array<boolean>;
|
33
|
-
packed: import("o1js/dist/node/lib/field.js").Field;
|
34
|
-
aux: import("o1js/dist/node/lib/bool.js").Bool[];
|
35
43
|
bitSize: bigint;
|
36
44
|
assertEquals(other: {
|
37
|
-
packed: import("o1js/dist/node/lib/field.js").Field;
|
38
|
-
aux: import("o1js/dist/node/lib/bool.js").Bool[];
|
39
45
|
bitSize: bigint;
|
40
46
|
assertEquals(other: any): void;
|
47
|
+
packed: import("o1js/dist/node/lib/field.js").Field;
|
41
48
|
}): void;
|
49
|
+
packed: import("o1js/dist/node/lib/field.js").Field;
|
42
50
|
};
|
43
51
|
type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
|
44
52
|
packed: import("o1js/dist/node/lib/field.js").Field;
|
@@ -46,11 +54,16 @@ export declare function PackedBoolFactory(l: number): {
|
|
46
54
|
packed: string;
|
47
55
|
}>;
|
48
56
|
l: number;
|
49
|
-
|
57
|
+
checkPack(unpacked: import("o1js/dist/node/lib/bool.js").Bool[]): void;
|
58
|
+
pack(unpacked: import("o1js/dist/node/lib/bool.js").Bool[]): import("o1js/dist/node/lib/field.js").Field;
|
59
|
+
unpackToBigints(f: import("o1js/dist/node/lib/field.js").Field): bigint[];
|
50
60
|
_isStruct: true;
|
51
61
|
toFields: (value: {
|
52
62
|
packed: import("o1js/dist/node/lib/field.js").Field;
|
53
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[];
|
54
67
|
fromFields: (fields: import("o1js/dist/node/lib/field.js").Field[]) => {
|
55
68
|
packed: import("o1js/dist/node/lib/field.js").Field;
|
56
69
|
};
|
@@ -1,43 +1,44 @@
|
|
1
|
-
import {
|
1
|
+
import { Provable, Bool } from 'o1js';
|
2
2
|
import { PackingPlant } from '../PackingPlant.js';
|
3
|
+
const L = 254; // 254 1-bit booleans fit in one Field
|
3
4
|
const SIZE_IN_BITS = 1n;
|
4
|
-
export function PackedBoolFactory(l) {
|
5
|
+
export function PackedBoolFactory(l = L) {
|
5
6
|
class PackedBool_ extends PackingPlant(Bool, l, SIZE_IN_BITS) {
|
6
|
-
static
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
if (value && value.packed) {
|
12
|
-
packedN = value.packed.toBigInt();
|
13
|
-
}
|
14
|
-
else {
|
15
|
-
throw new Error('No Packed Value Provided');
|
16
|
-
}
|
17
|
-
for (let i = 0; i < l; i++) {
|
18
|
-
bools_[i] = packedN & ((1n << SIZE_IN_BITS) - 1n);
|
19
|
-
packedN >>= SIZE_IN_BITS;
|
20
|
-
}
|
21
|
-
return bools_.map((x) => Bool.fromJSON(Boolean(x)));
|
22
|
-
});
|
23
|
-
return auxiliary;
|
7
|
+
static extractField(input) {
|
8
|
+
return input.toField();
|
9
|
+
}
|
10
|
+
static sizeInBits() {
|
11
|
+
return SIZE_IN_BITS;
|
24
12
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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;
|
33
24
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
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);
|
37
33
|
}
|
38
|
-
|
39
|
-
|
40
|
-
|
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);
|
41
42
|
}
|
42
43
|
toBooleans() {
|
43
44
|
return PackedBool_.unpack(this.packed).map((x) => x.toBoolean());
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PackedBool.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedBool.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"PackedBool.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedBool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,IAAI,EAAE,MAAM,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AC,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,10 +1,10 @@
|
|
1
1
|
import { Bool, Provable } from 'o1js';
|
2
2
|
import { PackedBoolFactory } from './PackedBool';
|
3
3
|
describe('PackedBool', () => {
|
4
|
-
class PackedBool extends PackedBoolFactory(254) {
|
5
|
-
}
|
6
4
|
const booleans = new Array(127).fill([true, false]).flat();
|
7
5
|
const bools = booleans.map((x) => Bool(x));
|
6
|
+
class PackedBool extends PackedBoolFactory() {
|
7
|
+
}
|
8
8
|
describe('Outside of the circuit', () => {
|
9
9
|
it('#fromBooleans', () => {
|
10
10
|
const myPackedBool = PackedBool.fromBooleans(booleans);
|
@@ -51,7 +51,7 @@ describe('PackedBool', () => {
|
|
51
51
|
it('Initializes', () => {
|
52
52
|
expect(() => {
|
53
53
|
Provable.runAndCheck(() => {
|
54
|
-
const packedBool = new PackedBool(outsidePackedBool.packed
|
54
|
+
const packedBool = new PackedBool(outsidePackedBool.packed);
|
55
55
|
PackedBool.check({ packed: packedBool.packed });
|
56
56
|
});
|
57
57
|
}).not.toThrow();
|
@@ -59,14 +59,14 @@ describe('PackedBool', () => {
|
|
59
59
|
it('#assertEquals', () => {
|
60
60
|
expect(() => {
|
61
61
|
Provable.runAndCheck(() => {
|
62
|
-
const packedBool = new PackedBool(outsidePackedBool.packed
|
62
|
+
const packedBool = new PackedBool(outsidePackedBool.packed);
|
63
63
|
packedBool.assertEquals(outsidePackedBool);
|
64
64
|
});
|
65
65
|
}).not.toThrow();
|
66
66
|
expect(() => {
|
67
67
|
Provable.runAndCheck(() => {
|
68
68
|
const fakePacked = outsidePackedBool.packed.add(32);
|
69
|
-
const packedBool = new PackedBool(fakePacked
|
69
|
+
const packedBool = new PackedBool(fakePacked);
|
70
70
|
packedBool.assertEquals(outsidePackedBool);
|
71
71
|
});
|
72
72
|
}).toThrow();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PackedBool.test.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedBool.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,
|
1
|
+
{"version":3,"file":"PackedBool.test.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedBool.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3D,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,UAAW,SAAQ,iBAAiB,EAAE;KAAG;IAC/C,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YACvB,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACvD,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,EAAE,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