o1js-pack 0.3.1 → 0.4.1
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/.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 -92
- package/build/src/lib/PackingPlant.js +190 -74
- package/build/src/lib/PackingPlant.js.map +1 -1
- package/build/src/lib/packed-types/PackedBool.d.ts +85 -77
- package/build/src/lib/packed-types/PackedBool.js +49 -47
- 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/PackedBool.test.js.map +1 -1
- package/build/src/lib/packed-types/PackedString.d.ts +181 -78
- package/build/src/lib/packed-types/PackedString.js +127 -82
- 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 -77
- package/build/src/lib/packed-types/PackedUInt32.js +49 -47
- 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/build/src/lib/packed-types/PackedUInt32.test.js.map +1 -1
- package/package.json +1 -1
- package/tests/provable/end_to_end.test.ts +65 -0
- package/tests/provable/example_packed_string_circuit.ts +47 -0
- package/tests/provable/example_packed_uint_circuit.ts +39 -0
- 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,77 +1,85 @@
|
|
1
|
-
import { Field, Bool } from 'o1js';
|
2
|
-
export declare function PackedBoolFactory(l
|
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
|
-
}): void;
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
assertEquals(other: any): void;
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
packed:
|
47
|
-
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
packed:
|
71
|
-
}
|
72
|
-
|
73
|
-
packed
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
}
|
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
|
+
};
|
@@ -1,48 +1,50 @@
|
|
1
|
-
import {
|
2
|
-
import { PackingPlant } from '../PackingPlant.js';
|
3
|
-
const
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
return
|
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
|
-
}
|
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
|
+
}
|
48
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,
|
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,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,sCAAsC;AACrD,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,UAAU,iBAAiB,CAAC,IAAY,CAAC;IAC7C,MAAM,WAAY,SAAQ,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC;QAC3D,MAAM,CAAC,YAAY,CAAC,KAAW;YAC7B,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;QAED,MAAM,CAAC,UAAU;YACf,OAAO,YAAY,CAAC;QACtB,CAAC;QAED;;;;WAIG;QACH,MAAM,CAAC,MAAM,CAAC,CAAQ;YACpB,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE;gBAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;gBACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3C,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
|
-
|
5
|
-
|
6
|
-
|
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 +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,MA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