o1js-pack 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +24 -0
- package/.gitattributes +3 -0
- package/.github/workflows/ci.yml +26 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +14 -0
- package/.prettierrc +6 -0
- package/LICENSE +199 -0
- package/README.md +59 -0
- package/babel.config.cjs +3 -0
- package/build/src/index.d.ts +5 -0
- package/build/src/index.js +6 -0
- package/build/src/index.js.map +1 -0
- package/build/src/lib/PackingPlant.d.ts +92 -0
- package/build/src/lib/PackingPlant.js +75 -0
- package/build/src/lib/PackingPlant.js.map +1 -0
- package/build/src/lib/packed-types/PackedBool.d.ts +77 -0
- package/build/src/lib/packed-types/PackedBool.js +48 -0
- package/build/src/lib/packed-types/PackedBool.js.map +1 -0
- package/build/src/lib/packed-types/PackedBool.test.d.ts +1 -0
- package/build/src/lib/packed-types/PackedBool.test.js +76 -0
- package/build/src/lib/packed-types/PackedBool.test.js.map +1 -0
- package/build/src/lib/packed-types/PackedCharacter.d.ts +51 -0
- package/build/src/lib/packed-types/PackedCharacter.js +34 -0
- package/build/src/lib/packed-types/PackedCharacter.js.map +1 -0
- package/build/src/lib/packed-types/PackedCharacter.test.d.ts +1 -0
- package/build/src/lib/packed-types/PackedCharacter.test.js +31 -0
- package/build/src/lib/packed-types/PackedCharacter.test.js.map +1 -0
- package/build/src/lib/packed-types/PackedString.d.ts +78 -0
- package/build/src/lib/packed-types/PackedString.js +83 -0
- package/build/src/lib/packed-types/PackedString.js.map +1 -0
- package/build/src/lib/packed-types/PackedString.test.d.ts +1 -0
- package/build/src/lib/packed-types/PackedString.test.js +100 -0
- package/build/src/lib/packed-types/PackedString.test.js.map +1 -0
- package/build/src/lib/packed-types/PackedUInt32.d.ts +77 -0
- package/build/src/lib/packed-types/PackedUInt32.js +48 -0
- package/build/src/lib/packed-types/PackedUInt32.js.map +1 -0
- package/build/src/lib/packed-types/PackedUInt32.test.d.ts +1 -0
- package/build/src/lib/packed-types/PackedUInt32.test.js +84 -0
- package/build/src/lib/packed-types/PackedUInt32.test.js.map +1 -0
- package/build/src/lib/scratch.d.ts +1 -0
- package/build/src/lib/scratch.js +16 -0
- package/build/src/lib/scratch.js.map +1 -0
- package/build/src/packed-types/PackedBool.d.ts +51 -0
- package/build/src/packed-types/PackedBool.js +34 -0
- package/build/src/packed-types/PackedBool.js.map +1 -0
- package/build/src/packed-types/PackedBool.test.d.ts +1 -0
- package/build/src/packed-types/PackedBool.test.js +101 -0
- package/build/src/packed-types/PackedBool.test.js.map +1 -0
- package/build/src/packed-types/PackedCharacter.d.ts +51 -0
- package/build/src/packed-types/PackedCharacter.js +34 -0
- package/build/src/packed-types/PackedCharacter.js.map +1 -0
- package/build/src/packed-types/PackedCharacter.test.d.ts +1 -0
- package/build/src/packed-types/PackedCharacter.test.js +31 -0
- package/build/src/packed-types/PackedCharacter.test.js.map +1 -0
- package/build/src/packed-types/PackedUInt32.d.ts +51 -0
- package/build/src/packed-types/PackedUInt32.js +34 -0
- package/build/src/packed-types/PackedUInt32.js.map +1 -0
- package/build/src/packed-types/PackedUInt32.test.d.ts +1 -0
- package/build/src/packed-types/PackedUInt32.test.js +68 -0
- package/build/src/packed-types/PackedUInt32.test.js.map +1 -0
- package/build/src/packed-types/PackingPlant.d.ts +54 -0
- package/build/src/packed-types/PackingPlant.js +45 -0
- package/build/src/packed-types/PackingPlant.js.map +1 -0
- package/build/src/packed-types/scratch.d.ts +1 -0
- package/build/src/packed-types/scratch.js +5 -0
- package/build/src/packed-types/scratch.js.map +1 -0
- package/config.json +4 -0
- package/coverage/clover.xml +166 -0
- package/coverage/coverage-final.json +5 -0
- package/coverage/lcov-report/PackedBool.ts.html +268 -0
- package/coverage/lcov-report/PackedUInt32.ts.html +313 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/lib/PackingPlant.ts.html +478 -0
- package/coverage/lcov-report/lib/index.html +116 -0
- package/coverage/lcov-report/lib/packed-types/PackedBool.ts.html +238 -0
- package/coverage/lcov-report/lib/packed-types/PackedString.ts.html +364 -0
- package/coverage/lcov-report/lib/packed-types/PackedUInt32.ts.html +238 -0
- package/coverage/lcov-report/lib/packed-types/index.html +146 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +282 -0
- package/jest-resolver.cjs +21 -0
- package/jest.config.js +24 -0
- package/package.json +50 -0
- package/tsconfig.json +23 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
import { Provable, UInt32 } from 'o1js';
|
2
|
+
import { PackedUInt32Factory } from './PackedUInt32';
|
3
|
+
describe('PackedUInt32', () => {
|
4
|
+
class PackedUInt32 extends PackedUInt32Factory(7) {
|
5
|
+
}
|
6
|
+
describe('Outside of the circuit', () => {
|
7
|
+
const bigints = [10n, 2n ** 32n - 1n, 0n, 10n, 2n ** 32n - 100n, 42n, 0n];
|
8
|
+
const uints = bigints.map((x) => UInt32.from(x));
|
9
|
+
it('#fromBigInts', () => {
|
10
|
+
const myPackedUInt32 = PackedUInt32.fromBigInts(bigints);
|
11
|
+
expect(myPackedUInt32.toBigInts()).toMatchObject(bigints);
|
12
|
+
});
|
13
|
+
it('#pack and #unPack', () => {
|
14
|
+
const packed = PackedUInt32.pack(uints);
|
15
|
+
const unpacked = PackedUInt32.unpack(packed);
|
16
|
+
expect(unpacked.length).toBe(uints.length);
|
17
|
+
expect(unpacked).toMatchObject(uints);
|
18
|
+
});
|
19
|
+
});
|
20
|
+
describe('Provable Properties', () => {
|
21
|
+
it('#sizeInFields', () => {
|
22
|
+
class one extends PackedUInt32Factory(1) {
|
23
|
+
}
|
24
|
+
class seven extends PackedUInt32Factory(7) {
|
25
|
+
}
|
26
|
+
expect(one.sizeInFields()).toBe(1);
|
27
|
+
expect(seven.sizeInFields()).toBe(1);
|
28
|
+
});
|
29
|
+
});
|
30
|
+
describe('Defensive Cases', () => {
|
31
|
+
it('throws for input >= 8 uints', () => {
|
32
|
+
expect(() => PackedUInt32Factory(7)).not.toThrow();
|
33
|
+
expect(() => PackedUInt32Factory(8)).toThrow();
|
34
|
+
});
|
35
|
+
it('initalizes with more input than allowed', () => {
|
36
|
+
const bigints = [
|
37
|
+
10n,
|
38
|
+
2n ** 32n - 1n,
|
39
|
+
0n,
|
40
|
+
10n,
|
41
|
+
2n ** 32n - 100n,
|
42
|
+
42n,
|
43
|
+
0n,
|
44
|
+
0n,
|
45
|
+
];
|
46
|
+
expect(() => {
|
47
|
+
PackedUInt32.fromBigInts(bigints);
|
48
|
+
}).toThrow();
|
49
|
+
});
|
50
|
+
it('initalizes with less input than specified', () => {
|
51
|
+
const bigints = [10n];
|
52
|
+
const expected = [10n, 0n, 0n, 0n, 0n, 0n, 0n];
|
53
|
+
expect(PackedUInt32.fromBigInts(bigints).toBigInts()).toMatchObject(expected);
|
54
|
+
});
|
55
|
+
});
|
56
|
+
describe('In the circuit', () => {
|
57
|
+
const bigints = [10n, 2n ** 32n - 1n, 0n, 10n, 2n ** 32n - 100n, 42n, 0n];
|
58
|
+
const outsidePackedUInt = PackedUInt32.fromBigInts(bigints);
|
59
|
+
it('Initializes', () => {
|
60
|
+
expect(() => {
|
61
|
+
Provable.runAndCheck(() => {
|
62
|
+
const packedUInt32 = new PackedUInt32(outsidePackedUInt.packed, outsidePackedUInt.aux);
|
63
|
+
PackedUInt32.check({ packed: packedUInt32.packed });
|
64
|
+
});
|
65
|
+
}).not.toThrow();
|
66
|
+
});
|
67
|
+
it('#assertEquals', () => {
|
68
|
+
expect(() => {
|
69
|
+
Provable.runAndCheck(() => {
|
70
|
+
const packedUInt32 = new PackedUInt32(outsidePackedUInt.packed, outsidePackedUInt.aux);
|
71
|
+
packedUInt32.assertEquals(outsidePackedUInt);
|
72
|
+
});
|
73
|
+
}).not.toThrow();
|
74
|
+
expect(() => {
|
75
|
+
Provable.runAndCheck(() => {
|
76
|
+
const fakePacked = outsidePackedUInt.packed.add(32);
|
77
|
+
const packedUInt32 = new PackedUInt32(fakePacked, outsidePackedUInt.aux);
|
78
|
+
packedUInt32.assertEquals(outsidePackedUInt);
|
79
|
+
});
|
80
|
+
}).toThrow();
|
81
|
+
});
|
82
|
+
});
|
83
|
+
});
|
84
|
+
//# sourceMappingURL=PackedUInt32.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PackedUInt32.test.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedUInt32.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,MAAM,YAAa,SAAQ,mBAAmB,CAAC,CAAC,CAAC;KAAG;IACpD,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,EAAE,IAAI,GAAG,GAAG,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,GAAG,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;QAC1E,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjD,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;YACtB,MAAM,cAAc,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACzD,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mBAAmB,EAAE,GA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C,GAAG,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YACvB,MAAM,CAAC,GAAG,EAAE;gBACV,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE;oBACxB,MAAM,YAAY,GAAG,IAAI,YAAY,CACnC,iBAAiB,CAAC,MAAM,EACxB,iBAAiB,CAAC,GAAG,CACtB,CAAC;oBACF,YAAY,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,CAAC,GAAG,EAAE;gBACV,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE;oBACxB,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBACpD,MAAM,YAAY,GAAG,IAAI,YAAY,CACnC,UAAU,EACV,iBAAiB,CAAC,GAAG,CACtB,CAAC;oBACF,YAAY,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { Character } from 'snarkyjs';
|
2
|
+
import { PackedStringFactory } from './packed-types/PackedString';
|
3
|
+
const main = () => {
|
4
|
+
const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
|
5
|
+
// length = 42 ~ 3 ZkStringFragments
|
6
|
+
console.log(vitalik_dot_eth, vitalik_dot_eth.length);
|
7
|
+
let myCharacters = [];
|
8
|
+
for (let i = 0; i < vitalik_dot_eth.length; i++) {
|
9
|
+
myCharacters.push(Character.fromString(vitalik_dot_eth[i]));
|
10
|
+
}
|
11
|
+
const EthAddressString = PackedStringFactory(42);
|
12
|
+
const myEthAddress = new EthAddressString(EthAddressString.pack(myCharacters), myCharacters);
|
13
|
+
console.log(EthAddressString.unpack(myEthAddress.packed).toString());
|
14
|
+
};
|
15
|
+
main();
|
16
|
+
//# sourceMappingURL=scratch.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"scratch.js","sourceRoot":"","sources":["../../../src/lib/scratch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,IAAI,GAAG,GAAG,EAAE;IAChB,MAAM,eAAe,GAAG,4CAA4C,CAAC;IAErE,oCAAoC;IACpC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAErD,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/C,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7D;IAED,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACjD,MAAM,YAAY,GAAG,IAAI,gBAAgB,CACvC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,EACnC,YAAY,CACb,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AACvE,CAAC,CAAC;AAEF,IAAI,EAAE,CAAC"}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { Field, Bool } from 'snarkyjs';
|
2
|
+
export declare function PackedBoolFactory(l: number): {
|
3
|
+
new (packed: import("snarkyjs/dist/node/lib/field").Field, aux: import("snarkyjs/dist/node/lib/bool").Bool[]): {
|
4
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
5
|
+
aux: import("snarkyjs/dist/node/lib/bool").Bool[];
|
6
|
+
bitSize: bigint;
|
7
|
+
};
|
8
|
+
/**
|
9
|
+
* Unpacks a Field into its component Bool parts
|
10
|
+
* @param value
|
11
|
+
* @returns the unpacked auxilliary data used to pack the value
|
12
|
+
*/
|
13
|
+
toAuxiliary(value?: {
|
14
|
+
packed: Field;
|
15
|
+
} | undefined): Bool[];
|
16
|
+
pack(aux: Bool[]): Field;
|
17
|
+
type: import("snarkyjs/dist/node/bindings/lib/provable-snarky").ProvableExtended<{
|
18
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
19
|
+
}, {
|
20
|
+
packed: string;
|
21
|
+
}>;
|
22
|
+
l: number;
|
23
|
+
unpack(f: import("snarkyjs/dist/node/lib/field").Field): import("snarkyjs/dist/node/lib/bool").Bool[];
|
24
|
+
check(value: {
|
25
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
26
|
+
}): void;
|
27
|
+
_isStruct: true;
|
28
|
+
toFields: (value: {
|
29
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
30
|
+
}) => import("snarkyjs/dist/node/lib/field").Field[];
|
31
|
+
fromFields: (fields: import("snarkyjs/dist/node/lib/field").Field[]) => {
|
32
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
33
|
+
};
|
34
|
+
sizeInFields(): number;
|
35
|
+
toInput: (x: {
|
36
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
37
|
+
}) => {
|
38
|
+
fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
|
39
|
+
packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
|
40
|
+
};
|
41
|
+
toJSON: (x: {
|
42
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
43
|
+
}) => {
|
44
|
+
packed: string;
|
45
|
+
};
|
46
|
+
fromJSON: (x: {
|
47
|
+
packed: string;
|
48
|
+
}) => {
|
49
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
50
|
+
};
|
51
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { Field, Provable, Bool } from 'snarkyjs';
|
2
|
+
import { PackingPlant } from './PackingPlant';
|
3
|
+
const SIZE_IN_BITS = 1n;
|
4
|
+
export function PackedBoolFactory(l) {
|
5
|
+
class PackedBool_ extends PackingPlant(Bool, l, SIZE_IN_BITS) {
|
6
|
+
/**
|
7
|
+
* Unpacks a Field into its component Bool parts
|
8
|
+
* @param value
|
9
|
+
* @returns the unpacked auxilliary data used to pack the value
|
10
|
+
*/
|
11
|
+
static toAuxiliary(value) {
|
12
|
+
const auxiliary = Provable.witness(Provable.Array(Bool, l), () => {
|
13
|
+
let bools_ = [];
|
14
|
+
let packedN = value?.packed.toBigInt() || 0n;
|
15
|
+
for (let i = 0; i < l; i++) {
|
16
|
+
bools_[i] = packedN & ((1n << SIZE_IN_BITS) - 1n);
|
17
|
+
packedN >>= SIZE_IN_BITS;
|
18
|
+
}
|
19
|
+
return bools_.map((x) => Bool.fromJSON(Boolean(x)));
|
20
|
+
});
|
21
|
+
return auxiliary;
|
22
|
+
}
|
23
|
+
static pack(aux) {
|
24
|
+
let f = Field(0);
|
25
|
+
for (let i = 0; i < l; i++) {
|
26
|
+
const c = Field((2n ** SIZE_IN_BITS) ** BigInt(i));
|
27
|
+
f = f.add(aux[i].toField().mul(c));
|
28
|
+
}
|
29
|
+
return f;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return PackedBool_;
|
33
|
+
}
|
34
|
+
//# sourceMappingURL=PackedBool.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PackedBool.js","sourceRoot":"","sources":["../../../src/packed-types/PackedBool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MA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GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aACpC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;KACF;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,101 @@
|
|
1
|
+
import { Bool } from 'snarkyjs';
|
2
|
+
import { PackedBoolFactory } from './PackedBool';
|
3
|
+
describe('PackedBool', () => {
|
4
|
+
it('packs and unpacks 2 Bool values', async () => {
|
5
|
+
const myBooleans = [false, true];
|
6
|
+
const myBools = myBooleans.map((b) => Bool(b));
|
7
|
+
const PackedBool_2 = PackedBoolFactory(2);
|
8
|
+
const packedBool_2 = new PackedBool_2(PackedBool_2.pack(myBools), myBools);
|
9
|
+
const f = packedBool_2.packed;
|
10
|
+
const unpacked = PackedBool_2.unpack(f);
|
11
|
+
expect(unpacked[0].toBoolean()).toBe(false);
|
12
|
+
expect(unpacked[1].toBoolean()).toBe(true);
|
13
|
+
expect(unpacked[0].toBoolean()).toBe(packedBool_2.aux[0].toBoolean());
|
14
|
+
expect(unpacked[1].toBoolean()).toBe(packedBool_2.aux[1].toBoolean());
|
15
|
+
});
|
16
|
+
it('packs and unpacks 50 Bool values', async () => {
|
17
|
+
const myBooleans = [
|
18
|
+
true,
|
19
|
+
true,
|
20
|
+
false,
|
21
|
+
false,
|
22
|
+
true,
|
23
|
+
false,
|
24
|
+
true,
|
25
|
+
true,
|
26
|
+
true,
|
27
|
+
false,
|
28
|
+
true,
|
29
|
+
true,
|
30
|
+
false,
|
31
|
+
false,
|
32
|
+
true,
|
33
|
+
false,
|
34
|
+
true,
|
35
|
+
true,
|
36
|
+
true,
|
37
|
+
false,
|
38
|
+
true,
|
39
|
+
true,
|
40
|
+
false,
|
41
|
+
false,
|
42
|
+
true,
|
43
|
+
false,
|
44
|
+
true,
|
45
|
+
true,
|
46
|
+
true,
|
47
|
+
false,
|
48
|
+
true,
|
49
|
+
true,
|
50
|
+
false,
|
51
|
+
false,
|
52
|
+
true,
|
53
|
+
false,
|
54
|
+
true,
|
55
|
+
true,
|
56
|
+
true,
|
57
|
+
false,
|
58
|
+
true,
|
59
|
+
true,
|
60
|
+
false,
|
61
|
+
false,
|
62
|
+
true,
|
63
|
+
false,
|
64
|
+
true,
|
65
|
+
true,
|
66
|
+
true,
|
67
|
+
false,
|
68
|
+
];
|
69
|
+
const myBools = myBooleans.map((b) => Bool(b));
|
70
|
+
const PackedBool_50 = PackedBoolFactory(50);
|
71
|
+
const packedBool_50 = new PackedBool_50(PackedBool_50.pack(myBools), myBools);
|
72
|
+
const f = packedBool_50.packed;
|
73
|
+
const unpacked = PackedBool_50.unpack(f);
|
74
|
+
expect(unpacked[0].toBoolean()).toBe(myBooleans[0]);
|
75
|
+
expect(unpacked[1].toBoolean()).toBe(myBooleans[1]);
|
76
|
+
expect(unpacked[15].toBoolean()).toBe(myBooleans[15]);
|
77
|
+
expect(unpacked[20].toBoolean()).toBe(myBooleans[20]);
|
78
|
+
expect(unpacked[35].toBoolean()).toBe(myBooleans[35]);
|
79
|
+
expect(unpacked[49].toBoolean()).toBe(myBooleans[49]);
|
80
|
+
});
|
81
|
+
it('mixes and matches class types', () => {
|
82
|
+
const myBooleans = [true, true, false, false, true, false];
|
83
|
+
const myBools = myBooleans.map((b) => Bool(b));
|
84
|
+
const PackedBool_2 = PackedBoolFactory(2);
|
85
|
+
const PackedBool_50 = PackedBoolFactory(50);
|
86
|
+
const packedBool_2 = new PackedBool_2(PackedBool_2.pack(myBools), myBools);
|
87
|
+
const packedBool_50 = new PackedBool_50(PackedBool_2.pack(myBools), myBools);
|
88
|
+
// TODO: Is this desired behavior?
|
89
|
+
console.log(PackedBool_2.toAuxiliary({ packed: packedBool_2.packed }).toString());
|
90
|
+
// > console.log
|
91
|
+
// > true,true
|
92
|
+
console.log(PackedBool_50.toAuxiliary({ packed: packedBool_50.packed }).toString());
|
93
|
+
// > console.log
|
94
|
+
// > true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false
|
95
|
+
});
|
96
|
+
it('throws for input >= 255 bools', () => {
|
97
|
+
expect(() => PackedBoolFactory(254)).not.toThrow();
|
98
|
+
expect(() => PackedBoolFactory(255)).toThrow();
|
99
|
+
});
|
100
|
+
});
|
101
|
+
//# sourceMappingURL=PackedBool.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PackedBool.test.js","sourceRoot":"","sources":["../../../src/packed-types/PackedBool.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,YAAY,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAE1C,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QAC3E,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;QAC9B,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAExC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,CAAC,Q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AAC,CAAC,CAAC,CAAC;QAC/C,MAAM,YAAY,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,aAAa,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;QAE5C,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QAC3E,MAAM,aAAa,GAAG,IAAI,aAAa,CACrC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAC1B,OAAO,CACR,CAAC;QAEF,kCAAkC;QAClC,OAAO,CAAC,GAAG,CACT,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CACrE,CAAC;QACF,gBAAgB;QAChB,cAAc;QACd,OAAO,CAAC,GAAG,CACT,aAAa,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CACvE,CAAC;QACF,gBAAgB;QAChB,8SAA8S;IAChT,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACnD,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { Field, Character } from 'snarkyjs';
|
2
|
+
export declare function PackedCharacterFactory(l: number): {
|
3
|
+
new (packed: import("snarkyjs/dist/node/lib/field.js").Field, aux: Character[]): {
|
4
|
+
packed: import("snarkyjs/dist/node/lib/field.js").Field;
|
5
|
+
aux: Character[];
|
6
|
+
bitSize: bigint;
|
7
|
+
};
|
8
|
+
/**
|
9
|
+
* Unpacks a Field into its component Character parts
|
10
|
+
* @param value
|
11
|
+
* @returns the unpacked auxilliary data used to pack the value
|
12
|
+
*/
|
13
|
+
toAuxiliary(value?: {
|
14
|
+
packed: Field;
|
15
|
+
} | undefined): Character[];
|
16
|
+
pack(aux: Character[]): Field;
|
17
|
+
type: import("snarkyjs/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
|
18
|
+
packed: import("snarkyjs/dist/node/lib/field.js").Field;
|
19
|
+
}, {
|
20
|
+
packed: string;
|
21
|
+
}>;
|
22
|
+
l: number;
|
23
|
+
unpack(f: import("snarkyjs/dist/node/lib/field.js").Field): Character[];
|
24
|
+
check(value: {
|
25
|
+
packed: import("snarkyjs/dist/node/lib/field.js").Field;
|
26
|
+
}): void;
|
27
|
+
_isStruct: true;
|
28
|
+
toFields: (value: {
|
29
|
+
packed: import("snarkyjs/dist/node/lib/field.js").Field;
|
30
|
+
}) => import("snarkyjs/dist/node/lib/field.js").Field[];
|
31
|
+
fromFields: (fields: import("snarkyjs/dist/node/lib/field.js").Field[]) => {
|
32
|
+
packed: import("snarkyjs/dist/node/lib/field.js").Field;
|
33
|
+
};
|
34
|
+
sizeInFields(): number;
|
35
|
+
toInput: (x: {
|
36
|
+
packed: import("snarkyjs/dist/node/lib/field.js").Field;
|
37
|
+
}) => {
|
38
|
+
fields?: import("snarkyjs/dist/node/lib/field.js").Field[] | undefined;
|
39
|
+
packed?: [import("snarkyjs/dist/node/lib/field.js").Field, number][] | undefined;
|
40
|
+
};
|
41
|
+
toJSON: (x: {
|
42
|
+
packed: import("snarkyjs/dist/node/lib/field.js").Field;
|
43
|
+
}) => {
|
44
|
+
packed: string;
|
45
|
+
};
|
46
|
+
fromJSON: (x: {
|
47
|
+
packed: string;
|
48
|
+
}) => {
|
49
|
+
packed: import("snarkyjs/dist/node/lib/field.js").Field;
|
50
|
+
};
|
51
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { Field, Provable, Character } from 'snarkyjs';
|
2
|
+
import { PackingPlant } from './PackingPlant.js';
|
3
|
+
const SIZE_IN_BITS = 16n;
|
4
|
+
export function PackedCharacterFactory(l) {
|
5
|
+
class PackedCharacter_ extends PackingPlant(Character, l, SIZE_IN_BITS) {
|
6
|
+
/**
|
7
|
+
* Unpacks a Field into its component Character parts
|
8
|
+
* @param value
|
9
|
+
* @returns the unpacked auxilliary data used to pack the value
|
10
|
+
*/
|
11
|
+
static toAuxiliary(value) {
|
12
|
+
const auxiliary = Provable.witness(Provable.Array(Character, l), () => {
|
13
|
+
let uints_ = [];
|
14
|
+
let packedN = value?.packed.toBigInt() || 0n;
|
15
|
+
for (let i = 0; i < l; i++) {
|
16
|
+
uints_[i] = packedN & ((1n << SIZE_IN_BITS) - 1n);
|
17
|
+
packedN >>= SIZE_IN_BITS;
|
18
|
+
}
|
19
|
+
return uints_.map((x) => Character.fromString(String.fromCharCode(Number(x))));
|
20
|
+
});
|
21
|
+
return auxiliary;
|
22
|
+
}
|
23
|
+
static pack(aux) {
|
24
|
+
let f = Field(0);
|
25
|
+
for (let i = 0; i < l; i++) {
|
26
|
+
const c = Field((2n ** SIZE_IN_BITS) ** BigInt(i));
|
27
|
+
f = f.add(aux[i].value.mul(c));
|
28
|
+
}
|
29
|
+
return f;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return PackedCharacter_;
|
33
|
+
}
|
34
|
+
//# sourceMappingURL=PackedCharacter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PackedCharacter.js","sourceRoot":"","sources":["../../../src/packed-types/PackedCharacter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,MAAM,UAAU,sBAAsB,CAAC,CAAS;IAC9C,MAAM,gBAAi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C,CAAC;QACX,CAAC;KACF;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Character } from 'snarkyjs';
|
2
|
+
import { PackedCharacterFactory } from './PackedCharacter';
|
3
|
+
describe('PackedCharacter', () => {
|
4
|
+
it('packs and unpacks a string of length < 16', async () => {
|
5
|
+
const myString = 'This is a test!';
|
6
|
+
let myCharacters = [];
|
7
|
+
for (let i = 0; i < myString.length; i++) {
|
8
|
+
myCharacters.push(Character.fromString(myString[i]));
|
9
|
+
}
|
10
|
+
const PackedCharacter_15 = PackedCharacterFactory(15);
|
11
|
+
const packedCharacter_15 = new PackedCharacter_15(PackedCharacter_15.pack(myCharacters), myCharacters);
|
12
|
+
const f = packedCharacter_15.packed;
|
13
|
+
const unpacked = PackedCharacter_15.unpack(f);
|
14
|
+
const unpackedStr = unpacked.map((x) => x.toString()).join('');
|
15
|
+
expect(unpackedStr).toBe(myString);
|
16
|
+
});
|
17
|
+
it('is one field in size', async () => {
|
18
|
+
const myString = 'This is a test!';
|
19
|
+
let myCharacters = [];
|
20
|
+
for (let i = 0; i < myString.length; i++) {
|
21
|
+
myCharacters.push(Character.fromString(myString[i]));
|
22
|
+
}
|
23
|
+
const PackedCharacter_15 = PackedCharacterFactory(15);
|
24
|
+
expect(PackedCharacter_15.sizeInFields()).toBe(1);
|
25
|
+
});
|
26
|
+
it('throws for input >= 16 chars', () => {
|
27
|
+
expect(() => PackedCharacterFactory(15)).not.toThrow();
|
28
|
+
expect(() => PackedCharacterFactory(16)).toThrow();
|
29
|
+
});
|
30
|
+
});
|
31
|
+
//# sourceMappingURL=PackedCharacter.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PackedCharacter.test.js","sourceRoot":"","sources":["../../../src/packed-types/PackedCharacter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,C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,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACtD;QAED,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,EAAE,CAAC,CAAC;QAEtD,MAAM,CAAC,kBAAkB,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACvD,MAAM,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { Field, UInt32 } from 'snarkyjs';
|
2
|
+
export declare function PackedUInt32Factory(l: number): {
|
3
|
+
new (packed: import("snarkyjs/dist/node/lib/field").Field, aux: UInt32[]): {
|
4
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
5
|
+
aux: UInt32[];
|
6
|
+
bitSize: bigint;
|
7
|
+
};
|
8
|
+
/**
|
9
|
+
* Unpacks a Field into its component UInt32 parts
|
10
|
+
* @param value
|
11
|
+
* @returns the unpacked auxilliary data used to pack the value
|
12
|
+
*/
|
13
|
+
toAuxiliary(value?: {
|
14
|
+
packed: Field;
|
15
|
+
} | undefined): UInt32[];
|
16
|
+
pack(aux: UInt32[]): Field;
|
17
|
+
type: import("snarkyjs/dist/node/bindings/lib/provable-snarky").ProvableExtended<{
|
18
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
19
|
+
}, {
|
20
|
+
packed: string;
|
21
|
+
}>;
|
22
|
+
l: number;
|
23
|
+
unpack(f: import("snarkyjs/dist/node/lib/field").Field): UInt32[];
|
24
|
+
check(value: {
|
25
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
26
|
+
}): void;
|
27
|
+
_isStruct: true;
|
28
|
+
toFields: (value: {
|
29
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
30
|
+
}) => import("snarkyjs/dist/node/lib/field").Field[];
|
31
|
+
fromFields: (fields: import("snarkyjs/dist/node/lib/field").Field[]) => {
|
32
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
33
|
+
};
|
34
|
+
sizeInFields(): number;
|
35
|
+
toInput: (x: {
|
36
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
37
|
+
}) => {
|
38
|
+
fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
|
39
|
+
packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
|
40
|
+
};
|
41
|
+
toJSON: (x: {
|
42
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
43
|
+
}) => {
|
44
|
+
packed: string;
|
45
|
+
};
|
46
|
+
fromJSON: (x: {
|
47
|
+
packed: string;
|
48
|
+
}) => {
|
49
|
+
packed: import("snarkyjs/dist/node/lib/field").Field;
|
50
|
+
};
|
51
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { Field, Provable, UInt32 } from 'snarkyjs';
|
2
|
+
import { PackingPlant } from './PackingPlant';
|
3
|
+
const SIZE_IN_BITS = 32n;
|
4
|
+
export function PackedUInt32Factory(l) {
|
5
|
+
class PackedUInt32_ extends PackingPlant(UInt32, l, SIZE_IN_BITS) {
|
6
|
+
/**
|
7
|
+
* Unpacks a Field into its component UInt32 parts
|
8
|
+
* @param value
|
9
|
+
* @returns the unpacked auxilliary data used to pack the value
|
10
|
+
*/
|
11
|
+
static toAuxiliary(value) {
|
12
|
+
const auxiliary = Provable.witness(Provable.Array(UInt32, l), () => {
|
13
|
+
let uints_ = [];
|
14
|
+
let packedN = value?.packed.toBigInt() || 0n;
|
15
|
+
for (let i = 0; i < l; i++) {
|
16
|
+
uints_[i] = packedN & ((1n << SIZE_IN_BITS) - 1n);
|
17
|
+
packedN >>= SIZE_IN_BITS;
|
18
|
+
}
|
19
|
+
return uints_.map((x) => UInt32.from(x));
|
20
|
+
});
|
21
|
+
return auxiliary;
|
22
|
+
}
|
23
|
+
static pack(aux) {
|
24
|
+
let f = Field(0);
|
25
|
+
for (let i = 0; i < l; i++) {
|
26
|
+
const c = Field((2n ** SIZE_IN_BITS) ** BigInt(i));
|
27
|
+
f = f.add(aux[i].value.mul(c));
|
28
|
+
}
|
29
|
+
return f;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return PackedUInt32_;
|
33
|
+
}
|
34
|
+
//# sourceMappingURL=PackedUInt32.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PackedUInt32.js","sourceRoot":"","sources":["../../../src/packed-types/PackedUInt32.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,MAAM,UAAU,mBAAmB,CAAC,CAAS;IAC3C,MAAM,aAAc,SAAQ,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,YAAY,CAAC;QAC/D;;;;WAIG;QACH,MAAM,CAAC,WAAW,CAAC,KAAqC;YACtD,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE;gBACjE,IAAI,MAAM,GAAa,EAAE,CAAC;gBAC1B,IAAI,OAAO,GAAG,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;gBAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;oBAC1B,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,EAAE,IAAI,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;oBAClD,OAAO,KAAK,YAAY,CAAC;iBAC1B;gBACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;YACH,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,GAAa;YACvB,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBAC1B,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,IAAI,YAAY,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBACnD,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aAChC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;KACF;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { Provable, UInt32 } from 'snarkyjs';
|
2
|
+
import { PackedUInt32Factory } from './PackedUInt32';
|
3
|
+
describe('PackedUInt32', () => {
|
4
|
+
it('packs and unpacks 2 UInt32 values', async () => {
|
5
|
+
const uints = [UInt32.from(67), UInt32.from(2n ** 32n - 1n)];
|
6
|
+
const PackedUInt32_2 = PackedUInt32Factory(2);
|
7
|
+
const packedUInt32_2 = new PackedUInt32_2(PackedUInt32_2.pack(uints), uints);
|
8
|
+
const f = packedUInt32_2.packed;
|
9
|
+
const unpacked = PackedUInt32_2.unpack(f);
|
10
|
+
expect(unpacked[0].toBigint()).toBe(67n);
|
11
|
+
expect(unpacked[1].toBigint()).toBe(2n ** 32n - 1n);
|
12
|
+
expect(unpacked[0].toBigint()).toBe(packedUInt32_2.aux[0].toBigint());
|
13
|
+
expect(unpacked[1].toBigint()).toBe(packedUInt32_2.aux[1].toBigint());
|
14
|
+
});
|
15
|
+
it('packs and unpacks 5 UInt32 values', async () => {
|
16
|
+
const uints = [
|
17
|
+
UInt32.from(67),
|
18
|
+
UInt32.from(2n ** 32n - 1n),
|
19
|
+
UInt32.from(0),
|
20
|
+
UInt32.from(0),
|
21
|
+
UInt32.from(128),
|
22
|
+
];
|
23
|
+
const PackedUInt32_5 = PackedUInt32Factory(5);
|
24
|
+
const packedUInt32_5 = new PackedUInt32_5(PackedUInt32_5.pack(uints), uints);
|
25
|
+
const f = packedUInt32_5.packed;
|
26
|
+
const unpacked = PackedUInt32_5.unpack(f);
|
27
|
+
expect(unpacked[0].toBigint()).toBe(67n);
|
28
|
+
expect(unpacked[1].toBigint()).toBe(2n ** 32n - 1n);
|
29
|
+
expect(unpacked[2].toBigint()).toBe(0n);
|
30
|
+
expect(unpacked[3].toBigint()).toBe(0n);
|
31
|
+
expect(unpacked[4].toBigint()).toBe(128n);
|
32
|
+
expect(unpacked[0].toBigint()).toBe(packedUInt32_5.aux[0].toBigint());
|
33
|
+
expect(unpacked[1].toBigint()).toBe(packedUInt32_5.aux[1].toBigint());
|
34
|
+
expect(unpacked[2].toBigint()).toBe(packedUInt32_5.aux[2].toBigint());
|
35
|
+
expect(unpacked[3].toBigint()).toBe(packedUInt32_5.aux[3].toBigint());
|
36
|
+
expect(unpacked[4].toBigint()).toBe(packedUInt32_5.aux[4].toBigint());
|
37
|
+
});
|
38
|
+
it('Validates with #check', () => {
|
39
|
+
const uints = [
|
40
|
+
UInt32.from(67),
|
41
|
+
UInt32.from(2n ** 32n - 1n),
|
42
|
+
UInt32.from(0),
|
43
|
+
UInt32.from(0),
|
44
|
+
UInt32.from(128),
|
45
|
+
];
|
46
|
+
const PackedUInt32_5 = PackedUInt32Factory(5);
|
47
|
+
Provable.runAndCheck(() => {
|
48
|
+
const packedUInt32_5 = new PackedUInt32_5(PackedUInt32_5.pack(uints), uints);
|
49
|
+
});
|
50
|
+
});
|
51
|
+
it('Is one field in size', () => {
|
52
|
+
const uints = [
|
53
|
+
UInt32.from(67),
|
54
|
+
UInt32.from(2n ** 32n - 1n),
|
55
|
+
UInt32.from(0),
|
56
|
+
UInt32.from(0),
|
57
|
+
UInt32.from(128),
|
58
|
+
];
|
59
|
+
const PackedUInt32_5 = PackedUInt32Factory(5);
|
60
|
+
expect(PackedUInt32_5.sizeInFields()).toBe(1);
|
61
|
+
expect(PackedUInt32_5.toFields({ packed: PackedUInt32_5.pack(uints) }).toString()).toBe([PackedUInt32_5.pack(uints)].toString());
|
62
|
+
});
|
63
|
+
it('throws for input >= 8 uints', () => {
|
64
|
+
expect(() => PackedUInt32Factory(7)).not.toThrow();
|
65
|
+
expect(() => PackedUInt32Factory(8)).toThrow();
|
66
|
+
});
|
67
|
+
});
|
68
|
+
//# sourceMappingURL=PackedUInt32.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PackedUInt32.test.js","sourceRoot":"","sources":["../../../src/packed-types/PackedUInt32.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAU,MAAM,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;QAC7D,MAAM,cAAc,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAE9C,MAAM,cAAc,GAAG,IAAI,cAAc,CACvC,cAAc,CAAC,IAAI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