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.
Files changed (82) hide show
  1. package/.github/workflows/ci.yml +1 -1
  2. package/.husky/pre-commit +0 -0
  3. package/README.md +9 -30
  4. package/build/src/index.d.ts +5 -5
  5. package/build/src/index.js +5 -5
  6. package/build/src/lib/PackingPlant.d.ts +132 -92
  7. package/build/src/lib/PackingPlant.js +190 -74
  8. package/build/src/lib/PackingPlant.js.map +1 -1
  9. package/build/src/lib/packed-types/PackedBool.d.ts +85 -77
  10. package/build/src/lib/packed-types/PackedBool.js +49 -47
  11. package/build/src/lib/packed-types/PackedBool.js.map +1 -1
  12. package/build/src/lib/packed-types/PackedBool.test.d.ts +1 -1
  13. package/build/src/lib/packed-types/PackedBool.test.js +75 -75
  14. package/build/src/lib/packed-types/PackedBool.test.js.map +1 -1
  15. package/build/src/lib/packed-types/PackedString.d.ts +181 -78
  16. package/build/src/lib/packed-types/PackedString.js +127 -82
  17. package/build/src/lib/packed-types/PackedString.js.map +1 -1
  18. package/build/src/lib/packed-types/PackedString.test.d.ts +1 -1
  19. package/build/src/lib/packed-types/PackedString.test.js +100 -99
  20. package/build/src/lib/packed-types/PackedString.test.js.map +1 -1
  21. package/build/src/lib/packed-types/PackedUInt32.d.ts +85 -77
  22. package/build/src/lib/packed-types/PackedUInt32.js +49 -47
  23. package/build/src/lib/packed-types/PackedUInt32.js.map +1 -1
  24. package/build/src/lib/packed-types/PackedUInt32.test.d.ts +1 -1
  25. package/build/src/lib/packed-types/PackedUInt32.test.js +83 -83
  26. package/build/src/lib/packed-types/PackedUInt32.test.js.map +1 -1
  27. package/package.json +1 -1
  28. package/tests/provable/end_to_end.test.ts +65 -0
  29. package/tests/provable/example_packed_string_circuit.ts +47 -0
  30. package/tests/provable/example_packed_uint_circuit.ts +39 -0
  31. package/build/src/lib/packed-types/PackedCharacter.d.ts +0 -51
  32. package/build/src/lib/packed-types/PackedCharacter.js +0 -34
  33. package/build/src/lib/packed-types/PackedCharacter.js.map +0 -1
  34. package/build/src/lib/packed-types/PackedCharacter.test.d.ts +0 -1
  35. package/build/src/lib/packed-types/PackedCharacter.test.js +0 -31
  36. package/build/src/lib/packed-types/PackedCharacter.test.js.map +0 -1
  37. package/build/src/lib/scratch.d.ts +0 -1
  38. package/build/src/lib/scratch.js +0 -16
  39. package/build/src/lib/scratch.js.map +0 -1
  40. package/build/src/packed-types/PackedBool.d.ts +0 -51
  41. package/build/src/packed-types/PackedBool.js +0 -34
  42. package/build/src/packed-types/PackedBool.js.map +0 -1
  43. package/build/src/packed-types/PackedBool.test.d.ts +0 -1
  44. package/build/src/packed-types/PackedBool.test.js +0 -101
  45. package/build/src/packed-types/PackedBool.test.js.map +0 -1
  46. package/build/src/packed-types/PackedCharacter.d.ts +0 -51
  47. package/build/src/packed-types/PackedCharacter.js +0 -34
  48. package/build/src/packed-types/PackedCharacter.js.map +0 -1
  49. package/build/src/packed-types/PackedCharacter.test.d.ts +0 -1
  50. package/build/src/packed-types/PackedCharacter.test.js +0 -31
  51. package/build/src/packed-types/PackedCharacter.test.js.map +0 -1
  52. package/build/src/packed-types/PackedUInt32.d.ts +0 -51
  53. package/build/src/packed-types/PackedUInt32.js +0 -34
  54. package/build/src/packed-types/PackedUInt32.js.map +0 -1
  55. package/build/src/packed-types/PackedUInt32.test.d.ts +0 -1
  56. package/build/src/packed-types/PackedUInt32.test.js +0 -68
  57. package/build/src/packed-types/PackedUInt32.test.js.map +0 -1
  58. package/build/src/packed-types/PackingPlant.d.ts +0 -54
  59. package/build/src/packed-types/PackingPlant.js +0 -45
  60. package/build/src/packed-types/PackingPlant.js.map +0 -1
  61. package/build/src/packed-types/scratch.d.ts +0 -1
  62. package/build/src/packed-types/scratch.js +0 -5
  63. package/build/src/packed-types/scratch.js.map +0 -1
  64. package/coverage/clover.xml +0 -166
  65. package/coverage/coverage-final.json +0 -5
  66. package/coverage/lcov-report/PackedBool.ts.html +0 -268
  67. package/coverage/lcov-report/PackedUInt32.ts.html +0 -313
  68. package/coverage/lcov-report/base.css +0 -224
  69. package/coverage/lcov-report/block-navigation.js +0 -87
  70. package/coverage/lcov-report/favicon.png +0 -0
  71. package/coverage/lcov-report/index.html +0 -131
  72. package/coverage/lcov-report/lib/PackingPlant.ts.html +0 -478
  73. package/coverage/lcov-report/lib/index.html +0 -116
  74. package/coverage/lcov-report/lib/packed-types/PackedBool.ts.html +0 -238
  75. package/coverage/lcov-report/lib/packed-types/PackedString.ts.html +0 -364
  76. package/coverage/lcov-report/lib/packed-types/PackedUInt32.ts.html +0 -238
  77. package/coverage/lcov-report/lib/packed-types/index.html +0 -146
  78. package/coverage/lcov-report/prettify.css +0 -1
  79. package/coverage/lcov-report/prettify.js +0 -2
  80. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  81. package/coverage/lcov-report/sorter.js +0 -196
  82. package/coverage/lcov.info +0 -282
@@ -1,101 +0,0 @@
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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AC1B,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"}
@@ -1,51 +0,0 @@
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
- };
@@ -1,34 +0,0 @@
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
@@ -1 +0,0 @@
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,gBAAiB,SAAQ,YAAY,CAAC,SAAS,EAAE,CAAC,EAAE,YAAY,CAAC;QACrE;;;;WAIG;QACH,MAAM,CAAC,WAAW,CAAC,KAAqC;YACtD,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE;gBACpE,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,CACtB,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CACrD,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,GAAgB;YAC1B,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,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,31 +0,0 @@
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=Pack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GAAG,EAAE,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,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"}
@@ -1,51 +0,0 @@
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
- };
@@ -1,34 +0,0 @@
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 PackedUIn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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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,68 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"PackedUInt32.test.js","sourceRoot":"","sources":["../../../src/packed-types/PackedUInt32.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAU,MAAM,EAAE,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9B,MAAM,KAAK,GAAG;YACZ,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,GAAG,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACd,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;SACjB,CAAC;QACF,MAAM,cAAc,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAE9C,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,CACJ,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAC3E,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACnD,MAAM,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,54 +0,0 @@
1
- import { Field, InferProvable } from 'snarkyjs';
2
- export declare function PackingPlant<A, T extends InferProvable<A> = InferProvable<A>>(elementType: A, l: number, bitSize: bigint): (abstract new (packed: Field, aux: Array<T>) => {
3
- packed: Field;
4
- aux: Array<T>;
5
- bitSize: bigint;
6
- }) & {
7
- type: import("snarkyjs/dist/node/bindings/lib/provable-snarky").ProvableExtended<{
8
- packed: import("snarkyjs/dist/node/lib/field").Field;
9
- }, {
10
- packed: string;
11
- }>;
12
- l: number;
13
- /**
14
- * Unpacks a Field into its component parts
15
- *
16
- * @param value
17
- * @returns the unpacked auxilliary data used to pack the value
18
- */
19
- toAuxiliary(value?: {
20
- packed: Field;
21
- } | undefined): Array<T>;
22
- pack(aux: Array<T>): Field;
23
- unpack(f: Field): T[];
24
- /**
25
- * In-Circuit verifiaction of the packed Field
26
- */
27
- check(value: {
28
- packed: Field;
29
- }): void;
30
- _isStruct: true;
31
- toFields: (value: {
32
- packed: import("snarkyjs/dist/node/lib/field").Field;
33
- }) => import("snarkyjs/dist/node/lib/field").Field[];
34
- fromFields: (fields: import("snarkyjs/dist/node/lib/field").Field[]) => {
35
- packed: import("snarkyjs/dist/node/lib/field").Field;
36
- };
37
- sizeInFields(): number;
38
- toInput: (x: {
39
- packed: import("snarkyjs/dist/node/lib/field").Field;
40
- }) => {
41
- fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
42
- packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
43
- };
44
- toJSON: (x: {
45
- packed: import("snarkyjs/dist/node/lib/field").Field;
46
- }) => {
47
- packed: string;
48
- };
49
- fromJSON: (x: {
50
- packed: string;
51
- }) => {
52
- packed: import("snarkyjs/dist/node/lib/field").Field;
53
- };
54
- };
@@ -1,45 +0,0 @@
1
- import { Field, Struct, provable } from 'snarkyjs';
2
- export function PackingPlant(elementType, l, bitSize) {
3
- if (bitSize * BigInt(l) >= 255n) {
4
- throw new Error(`The Packing Plant is only accepting orders that can fit into a single Field`);
5
- }
6
- class Packed_ extends Struct({
7
- packed: Field,
8
- }) {
9
- constructor(packed, aux) {
10
- super({ packed });
11
- this.bitSize = bitSize;
12
- this.aux = aux;
13
- }
14
- /**
15
- * Unpacks a Field into its component parts
16
- *
17
- * @param value
18
- * @returns the unpacked auxilliary data used to pack the value
19
- */
20
- static toAuxiliary(value) {
21
- throw new Error('Must implement toAuxiliary');
22
- return [];
23
- }
24
- static pack(aux) {
25
- throw new Error('Must implement pack');
26
- let f = Field(0);
27
- return f;
28
- }
29
- static unpack(f) {
30
- return this.toAuxiliary({ packed: f });
31
- }
32
- /**
33
- * In-Circuit verifiaction of the packed Field
34
- */
35
- static check(value) {
36
- const unpacked = this.toAuxiliary({ packed: value.packed });
37
- const packed = this.pack(unpacked);
38
- packed.assertEquals(value.packed);
39
- }
40
- }
41
- Packed_.type = provable({ packed: Field }, {});
42
- Packed_.l = l;
43
- return Packed_;
44
- }
45
- //# sourceMappingURL=PackingPlant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PackingPlant.js","sourceRoot":"","sources":["../../../src/packed-types/PackingPlant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAiB,MAAM,UAAU,CAAC;AAElE,MAAM,UAAU,YAAY,CAC1B,WAAc,EACd,CAAS,EACT,OAAe;IAEf,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;QAC/B,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;KACH;IACD,MAAe,OAAQ,SAAQ,MAAM,CAAC;QACpC,MAAM,EAAE,KAAK;KACd,CAAC;QAOA,YAAY,MAAa,EAAE,GAAa;YACtC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAHpB,YAAO,GAAW,OAAO,CAAC;YAIxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACjB,CAAC;QAED;;;;;WAKG;QACH,MAAM,CAAC,WAAW,CAAC,KAAqC;YACtD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,GAAa;YACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACvC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,CAAQ;YACpB,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;QACzC,CAAC;QAED;;WAEG;QACH,MAAM,CAAC,KAAK,CAAC,KAAwB;YACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YAC5D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;;IAvCM,YAAI,GAAG,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,SAAC,GAAW,CAAC,CAAC;IAwCvB,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { PackedCharacterFactory } from "./PackedCharacter.js";
2
- const ZkStringFragment = PackedCharacterFactory(15);
3
- const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
4
- console.log(vitalik_dot_eth, vitalik_dot_eth.length);
5
- //# sourceMappingURL=scratch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scratch.js","sourceRoot":"","sources":["../../../src/packed-types/scratch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,EAAE,CAAC,CAAC;AACpD,MAAM,eAAe,GAAG,4CAA4C,CAAC;AAErE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC"}