o1js-pack 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
package/.eslintrc.cjs CHANGED
@@ -16,7 +16,7 @@ module.exports = {
16
16
  ecmaVersion: 'latest',
17
17
  },
18
18
  plugins: ['@typescript-eslint', 'o1js'],
19
- ignorePatterns: ['README.md'],
19
+ ignorePatterns: ['*.md'],
20
20
  rules: {
21
21
  'no-constant-condition': 'off',
22
22
  'prefer-const': 'off',
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## v0.5
2
+
3
+ - Making PackedString class 31 characters instead of 15
4
+ - This has implications in any source code using the default packed string implementation
5
+ - Unpacked character arrays will now be 31 characters long, so code expecting a 15-character array may break!
@@ -1,13 +1,17 @@
1
1
  import { Field, InferProvable } from 'o1js';
2
2
  export declare function PackingPlant<A, T extends InferProvable<A> = InferProvable<A>>(elementType: A, l: number, bitSize: bigint): (abstract new (packed: Field) => {
3
+ /**
4
+ * @returns array of single Field element which constitute the packed object
5
+ */
6
+ toFields(): Array<Field>;
3
7
  assertEquals(other: any): void;
4
8
  packed: import("o1js/dist/node/lib/field").Field;
5
9
  }) & {
6
- type: import("o1js/dist/node/bindings/lib/provable-snarky").ProvableExtended<{
10
+ type: import("o1js/dist/node/bindings/lib/generic").GenericProvableExtendedPure<{
7
11
  packed: import("o1js/dist/node/lib/field").Field;
8
12
  }, {
9
13
  packed: string;
10
- }>;
14
+ }, import("o1js/dist/node/lib/field").Field>;
11
15
  l: number;
12
16
  bitSize: bigint;
13
17
  extractField(input: T): Field;
@@ -61,16 +65,23 @@ export declare function PackingPlant<A, T extends InferProvable<A> = InferProvab
61
65
  }) => {
62
66
  packed: import("o1js/dist/node/lib/field").Field;
63
67
  };
68
+ empty: () => {
69
+ packed: import("o1js/dist/node/lib/field").Field;
70
+ };
64
71
  };
65
72
  export declare function MultiPackingPlant<A, T extends InferProvable<A> = InferProvable<A>>(elementType: A, l: number, bitSize: bigint): (abstract new (packed: Array<Field>) => {
73
+ /**
74
+ * @returns array of Field elements which constitute the multi-packed object
75
+ */
76
+ toFields(): Array<Field>;
66
77
  assertEquals(other: any): void;
67
78
  packed: import("o1js/dist/node/lib/field").Field[];
68
79
  }) & {
69
- type: import("o1js/dist/node/bindings/lib/provable-snarky").ProvableExtended<{
80
+ type: import("o1js/dist/node/bindings/lib/generic").GenericProvableExtendedPure<{
70
81
  packed: import("o1js/dist/node/lib/field").Field[];
71
82
  }, {
72
83
  packed: string[];
73
- }>;
84
+ }, import("o1js/dist/node/lib/field").Field>;
74
85
  l: number;
75
86
  n: number;
76
87
  bitSize: bigint;
@@ -129,4 +140,7 @@ export declare function MultiPackingPlant<A, T extends InferProvable<A> = InferP
129
140
  }) => {
130
141
  packed: import("o1js/dist/node/lib/field").Field[];
131
142
  };
143
+ empty: () => {
144
+ packed: import("o1js/dist/node/lib/field").Field[];
145
+ };
132
146
  };
@@ -67,6 +67,13 @@ export function PackingPlant(elementType, l, bitSize) {
67
67
  }
68
68
  return unpacked;
69
69
  }
70
+ // NOTE: adding to fields here breaks the proof generation. Probably not overriding it correctly
71
+ /**
72
+ * @returns array of single Field element which constitute the packed object
73
+ */
74
+ toFields() {
75
+ return [this.packed];
76
+ }
70
77
  assertEquals(other) {
71
78
  this.packed.assertEquals(other.packed);
72
79
  }
@@ -176,6 +183,13 @@ export function MultiPackingPlant(elementType, l, bitSize) {
176
183
  }
177
184
  return uints_;
178
185
  }
186
+ // NOTE: adding to fields here breaks the proof generation. Probably not overriding it correctly
187
+ /**
188
+ * @returns array of Field elements which constitute the multi-packed object
189
+ */
190
+ toFields() {
191
+ return this.packed;
192
+ }
179
193
  assertEquals(other) {
180
194
  for (let x = 0; x < n; x++) {
181
195
  this.packed[x].assertEquals(other.packed[x]);
@@ -1 +1 @@
1
- {"version":3,"file":"PackingPlant.js","sourceRoot":"","sources":["../../../src/lib/PackingPlant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EAEN,QAAQ,EAER,QAAQ,GACT,MAAM,MA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C;oBAC1C,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;oBACvD,OAAO,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;iBAC/B;aACF;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,iGAAiG;QACjG;;WAEG;QACH,QAAQ;YACN,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;QAED,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;;IApHM,YAAI,GAAG,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1D,SAAC,GAAW,CAAC,CAAC;IACd,SAAC,GAAW,CAAC,CAAC;IACd,eAAO,GAAW,OAAO,CAAC;IAmHnC,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -2,7 +2,9 @@ import { Field, Bool } from 'o1js';
2
2
  export declare function PackedBoolFactory(l?: number): {
3
3
  new (packed: import("o1js/dist/node/lib/field.js").Field): {
4
4
  toBooleans(): Array<boolean>;
5
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
5
6
  assertEquals(other: {
7
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
6
8
  assertEquals(other: any): void;
7
9
  packed: import("o1js/dist/node/lib/field.js").Field;
8
10
  }): void;
@@ -23,7 +25,9 @@ export declare function PackedBoolFactory(l?: number): {
23
25
  */
24
26
  fromBools(bools: Array<Bool>): {
25
27
  toBooleans(): Array<boolean>;
28
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
26
29
  assertEquals(other: {
30
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
27
31
  assertEquals(other: any): void;
28
32
  packed: import("o1js/dist/node/lib/field.js").Field;
29
33
  }): void;
@@ -36,17 +40,19 @@ export declare function PackedBoolFactory(l?: number): {
36
40
  */
37
41
  fromBooleans(booleans: Array<boolean>): {
38
42
  toBooleans(): Array<boolean>;
43
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
39
44
  assertEquals(other: {
45
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
40
46
  assertEquals(other: any): void;
41
47
  packed: import("o1js/dist/node/lib/field.js").Field;
42
48
  }): void;
43
49
  packed: import("o1js/dist/node/lib/field.js").Field;
44
50
  };
45
- type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
51
+ type: import("o1js/dist/node/bindings/lib/generic.js").GenericProvableExtendedPure<{
46
52
  packed: import("o1js/dist/node/lib/field.js").Field;
47
53
  }, {
48
54
  packed: string;
49
- }>;
55
+ }, import("o1js/dist/node/lib/field.js").Field>;
50
56
  l: number;
51
57
  bitSize: bigint;
52
58
  checkPack(unpacked: import("o1js/dist/node/lib/bool.js").Bool[]): void;
@@ -82,4 +88,7 @@ export declare function PackedBoolFactory(l?: number): {
82
88
  }) => {
83
89
  packed: import("o1js/dist/node/lib/field.js").Field;
84
90
  };
91
+ empty: () => {
92
+ packed: import("o1js/dist/node/lib/field.js").Field;
93
+ };
85
94
  };
@@ -2,7 +2,9 @@ import { Field, Character } from 'o1js';
2
2
  export declare function PackedStringFactory(l?: number): {
3
3
  new (packed: import("o1js/dist/node/lib/field.js").Field): {
4
4
  toString(): string;
5
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
5
6
  assertEquals(other: {
7
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
6
8
  assertEquals(other: any): void;
7
9
  packed: import("o1js/dist/node/lib/field.js").Field;
8
10
  }): void;
@@ -23,7 +25,9 @@ export declare function PackedStringFactory(l?: number): {
23
25
  */
24
26
  fromCharacters(input: Array<Character>): {
25
27
  toString(): string;
28
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
26
29
  assertEquals(other: {
30
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
27
31
  assertEquals(other: any): void;
28
32
  packed: import("o1js/dist/node/lib/field.js").Field;
29
33
  }): void;
@@ -36,7 +40,9 @@ export declare function PackedStringFactory(l?: number): {
36
40
  */
37
41
  fromString(str: string): {
38
42
  toString(): string;
43
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
39
44
  assertEquals(other: {
45
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
40
46
  assertEquals(other: any): void;
41
47
  packed: import("o1js/dist/node/lib/field.js").Field;
42
48
  }): void;
@@ -47,11 +53,11 @@ export declare function PackedStringFactory(l?: number): {
47
53
  * @param f Field, packed with the information, as returned by #pack
48
54
  * @returns Array of Character
49
55
  */
50
- type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
56
+ type: import("o1js/dist/node/bindings/lib/generic.js").GenericProvableExtendedPure<{
51
57
  packed: import("o1js/dist/node/lib/field.js").Field;
52
58
  }, {
53
59
  packed: string;
54
- }>;
60
+ }, import("o1js/dist/node/lib/field.js").Field>;
55
61
  l: number;
56
62
  bitSize: bigint;
57
63
  checkPack(unpacked: Character[]): void;
@@ -87,6 +93,9 @@ export declare function PackedStringFactory(l?: number): {
87
93
  }) => {
88
94
  packed: import("o1js/dist/node/lib/field.js").Field;
89
95
  };
96
+ empty: () => {
97
+ packed: import("o1js/dist/node/lib/field.js").Field;
98
+ };
90
99
  };
91
100
  /**
92
101
  *
@@ -96,7 +105,9 @@ export declare function PackedStringFactory(l?: number): {
96
105
  export declare function MultiPackedStringFactory(n?: number): {
97
106
  new (packed: import("o1js/dist/node/lib/field.js").Field[]): {
98
107
  toString(): string;
108
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
99
109
  assertEquals(other: {
110
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
100
111
  assertEquals(other: any): void;
101
112
  packed: import("o1js/dist/node/lib/field.js").Field[];
102
113
  }): void;
@@ -118,7 +129,9 @@ export declare function MultiPackedStringFactory(n?: number): {
118
129
  */
119
130
  fromCharacters(input: Array<Character>): {
120
131
  toString(): string;
132
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
121
133
  assertEquals(other: {
134
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
122
135
  assertEquals(other: any): void;
123
136
  packed: import("o1js/dist/node/lib/field.js").Field[];
124
137
  }): void;
@@ -131,17 +144,19 @@ export declare function MultiPackedStringFactory(n?: number): {
131
144
  */
132
145
  fromString(str: string): {
133
146
  toString(): string;
147
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
134
148
  assertEquals(other: {
149
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
135
150
  assertEquals(other: any): void;
136
151
  packed: import("o1js/dist/node/lib/field.js").Field[];
137
152
  }): void;
138
153
  packed: import("o1js/dist/node/lib/field.js").Field[];
139
154
  };
140
- type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
155
+ type: import("o1js/dist/node/bindings/lib/generic.js").GenericProvableExtendedPure<{
141
156
  packed: import("o1js/dist/node/lib/field.js").Field[];
142
157
  }, {
143
158
  packed: string[];
144
- }>;
159
+ }, import("o1js/dist/node/lib/field.js").Field>;
145
160
  l: number;
146
161
  n: number;
147
162
  bitSize: bigint;
@@ -178,4 +193,7 @@ export declare function MultiPackedStringFactory(n?: number): {
178
193
  }) => {
179
194
  packed: import("o1js/dist/node/lib/field.js").Field[];
180
195
  };
196
+ empty: () => {
197
+ packed: import("o1js/dist/node/lib/field.js").Field[];
198
+ };
181
199
  };
@@ -1,8 +1,8 @@
1
1
  import { Field, Provable, Character, Poseidon } from 'o1js';
2
2
  import { PackingPlant, MultiPackingPlant } from '../PackingPlant.js';
3
- const SIZE_IN_BITS = 16n;
4
- const L = 15; // Default to one-field worth of characters
5
- const CHARS_PER_FIELD = 15;
3
+ const SIZE_IN_BITS = 8n;
4
+ const L = 31; // Default to one-field worth of characters
5
+ const CHARS_PER_FIELD = 31;
6
6
  export function PackedStringFactory(l = L) {
7
7
  class PackedString_ extends PackingPlant(Character, l, SIZE_IN_BITS) {
8
8
  static extractField(input) {
@@ -1 +1 @@
1
- {"version":3,"file":"PackedString.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAErE,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,2CAA2C;AACzD,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,UAAU,mBAAmB,CAAC,IAAY,CAAC;IAC/C,MAAM,aAAc,SAAQ,YAAY,CAAC,SAAS,EAAE,CAAC,EAAE,YAAY,CAAC;QAClE,MAAM,CAAC,YAAY,CAAC,KAAgB;YAClC,OAAO,KAAK,CAAC,KAAK,CAAC;QACrB,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,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE;gBACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;gBACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACxB,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CACrD,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C;iBAC1C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,QAAQ,CAAC;iBACxC,IAAI,CAAC,EAAE,CAAC,CAAC;QACd,CAAC;KACF;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -1,9 +1,9 @@
1
- import { Character, Provable } from 'o1js';
1
+ import { Character, Field, Provable } from 'o1js';
2
2
  import { PackedStringFactory, MultiPackedStringFactory } from './PackedString';
3
3
  describe('PackedString', () => {
4
4
  describe('Outside of the Circuit', () => {
5
5
  const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
6
- class EthAddressString extends MultiPackedStringFactory(3) {
6
+ class EthAddressString extends MultiPackedStringFactory(2) {
7
7
  }
8
8
  let characters = [];
9
9
  beforeEach(() => {
@@ -23,15 +23,34 @@ describe('PackedString', () => {
23
23
  it('#pack and #unPack', () => {
24
24
  const unpacked = EthAddressString.unpack(EthAddressString.fromCharacters(characters).packed);
25
25
  const packed = EthAddressString.pack(unpacked);
26
- expect(packed.length).toBe(Math.ceil(vitalik_dot_eth.length / 15));
26
+ expect(packed.length).toBe(Math.ceil(vitalik_dot_eth.length / 31));
27
27
  expect(unpacked.length).toBe(EthAddressString.l);
28
- expect(unpacked.length).toBe(45);
28
+ expect(unpacked.length).toBe(62);
29
29
  expect(unpacked.slice(0, characters.length).toString()).toBe(characters.toString());
30
30
  });
31
+ it('#toFields', () => {
32
+ class Single extends PackedStringFactory() {
33
+ }
34
+ class Double extends MultiPackedStringFactory(2) {
35
+ }
36
+ const abbaPacked = '1633837665';
37
+ expect(Single.fromString('abba').toFields().toString()).toBe([Single.fromString('abba').packed].toString());
38
+ expect(Single.fromString('abba').toFields().toString()).toBe(abbaPacked);
39
+ expect(Single.unpack(Field(abbaPacked)).slice(0, 4).join('').toString()).toBe('abba');
40
+ const abbaAlot = 'abba'.repeat(10);
41
+ const abbaAlotPacked1 = '173830008860859097861870638220020642754739197069143560335286125952244015713';
42
+ const abbaAlotPacked2 = '1796423510984151425377';
43
+ expect(Double.fromString(abbaAlot).toFields().toString()).toBe([Double.fromString(abbaAlot).packed].toString());
44
+ expect(Double.fromString(abbaAlot).toFields().toString()).toBe(abbaAlotPacked1 + ',' + abbaAlotPacked2);
45
+ expect(Double.unpack([Field(abbaAlotPacked1), Field(abbaAlotPacked2)])
46
+ .slice(0, 40)
47
+ .join('')
48
+ .toString()).toBe(abbaAlot);
49
+ });
31
50
  });
32
51
  describe('Provable Properties', () => {
33
52
  it('#sizeInFields', () => {
34
- class one extends PackedStringFactory(15) {
53
+ class one extends PackedStringFactory(31) {
35
54
  }
36
55
  class two extends MultiPackedStringFactory(2) {
37
56
  }
@@ -59,7 +78,7 @@ describe('PackedString', () => {
59
78
  }).toThrow();
60
79
  });
61
80
  it('Exceeds maximum size string', () => {
62
- const tooLong = 'too long!'.repeat(20);
81
+ const tooLong = 'too long!'.repeat(50);
63
82
  class MaxString extends MultiPackedStringFactory(8) {
64
83
  }
65
84
  expect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"PackedString.test.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedString.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,QAAQ,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/E,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,eAAe,GAAG,4CAA4C,CAAC;QACrE,MAAM,gBAAiB,SAAQ,wBAAwB,CAAC,CAAC,CAAC;SAAG;QAC7D,IAAI,UAAU,GAAqB,EAAE,CAAC;QAEtC,UAAU,CAAC,GAAG,EAAE;YACd,UAAU,GAAG,EAAE,CAAC;YAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC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BAAiB,CAAC,MAAM,CAAC,CAAC;oBAEpE,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC1D,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YACvB,MAAM,CAAC,GAAG,EAAE;gBACV,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE;oBACxB,MAAM,YAAY,GAAG,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBAEpE,YAAY,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YAEjB,MAAM,CAAC,GAAG,EAAE;gBACV,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE;oBACxB,MAAM,UAAU,GAAG,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBACjD,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACrC,MAAM,YAAY,GAAG,IAAI,gBAAgB,CAAC,UAAU,CAAC,CAAC;oBAEtD,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"}
@@ -2,7 +2,9 @@ import { Field, UInt32 } from 'o1js';
2
2
  export declare function PackedUInt32Factory(l?: number): {
3
3
  new (packed: import("o1js/dist/node/lib/field.js").Field): {
4
4
  toBigInts(): Array<bigint>;
5
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
5
6
  assertEquals(other: {
7
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
6
8
  assertEquals(other: any): void;
7
9
  packed: import("o1js/dist/node/lib/field.js").Field;
8
10
  }): void;
@@ -23,7 +25,9 @@ export declare function PackedUInt32Factory(l?: number): {
23
25
  */
24
26
  fromUInt32s(uint32s: Array<UInt32>): {
25
27
  toBigInts(): Array<bigint>;
28
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
26
29
  assertEquals(other: {
30
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
27
31
  assertEquals(other: any): void;
28
32
  packed: import("o1js/dist/node/lib/field.js").Field;
29
33
  }): void;
@@ -36,17 +40,19 @@ export declare function PackedUInt32Factory(l?: number): {
36
40
  */
37
41
  fromBigInts(bigints: Array<bigint>): {
38
42
  toBigInts(): Array<bigint>;
43
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
39
44
  assertEquals(other: {
45
+ toFields(): import("o1js/dist/node/lib/field.js").Field[];
40
46
  assertEquals(other: any): void;
41
47
  packed: import("o1js/dist/node/lib/field.js").Field;
42
48
  }): void;
43
49
  packed: import("o1js/dist/node/lib/field.js").Field;
44
50
  };
45
- type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
51
+ type: import("o1js/dist/node/bindings/lib/generic.js").GenericProvableExtendedPure<{
46
52
  packed: import("o1js/dist/node/lib/field.js").Field;
47
53
  }, {
48
54
  packed: string;
49
- }>;
55
+ }, import("o1js/dist/node/lib/field.js").Field>;
50
56
  l: number;
51
57
  bitSize: bigint;
52
58
  checkPack(unpacked: UInt32[]): void;
@@ -82,4 +88,7 @@ export declare function PackedUInt32Factory(l?: number): {
82
88
  }) => {
83
89
  packed: import("o1js/dist/node/lib/field.js").Field;
84
90
  };
91
+ empty: () => {
92
+ packed: import("o1js/dist/node/lib/field.js").Field;
93
+ };
85
94
  };
@@ -0,0 +1,7 @@
1
+ ## Using Tokens as State Smart Contract
2
+
3
+ Using o1js-pack, a token can actually be a packed value. Token balances are natively a `UInt64`, so there is not as much room as a full `Field`, but we can still pack 2 `UInt32`, or we could pack 8 characters, or 64 booleans.
4
+
5
+ The `mint` and `burn` mechanisms are used like an unspent transaction output system. The state going in is always burnt, and the state coming out is unrelated numerically. In the example in `run.ts`, the token balance is set to 5 when the state is (5, 0). But when the state is (5, 10), the token balance becomes 42949672965.
6
+
7
+ This can be useful for per-user state in a zkapp. Booleans could be used to track feature flags or whether or not a user account is active, in good standing, etc... Characters could be used to store shore strings on a per-user basis, perhaps a country code? UInts can be used like in this example to track the first and last time a user has used an app. Or you could use half of the state to track an actual user balance, and the other half to track another number like number of token transactions.
@@ -0,0 +1,62 @@
1
+ import {
2
+ SmartContract,
3
+ state,
4
+ State,
5
+ method,
6
+ UInt32,
7
+ UInt64,
8
+ Account,
9
+ Provable,
10
+ } from 'o1js';
11
+ import { PackedUInt32Factory } from '../../../src/index.js';
12
+
13
+ /**
14
+ * 2 UInt32s representing the first-joined block and the last-updated block
15
+ * Could be used in conjunction with some other app logic to ensure only active users can access some resource, or similar
16
+ */
17
+ export class UserBlockStamps extends PackedUInt32Factory(2) {}
18
+
19
+ export class UserBlockStampsToken extends SmartContract {
20
+ /**
21
+ * Initializes the user state by setting the first-joined blockstamp to the current blockheight
22
+ */
23
+ @method
24
+ joinSystem() {
25
+ const account = Account(this.sender, this.token.id);
26
+ const currentTokenBalance = account.balance.getAndAssertEquals();
27
+ currentTokenBalance.assertEquals(UInt64.from(0));
28
+
29
+ const userBlockStamps = UserBlockStamps.fromUInt32s([
30
+ this.network.blockchainLength.getAndAssertEquals(),
31
+ UInt32.from(0),
32
+ ]);
33
+ this.token.mint({
34
+ address: this.sender,
35
+ amount: UInt64.from(userBlockStamps.packed),
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Updates the user state by setting the last-updated blockstamp to the current blockheight
41
+ */
42
+ @method
43
+ interactWithSystem() {
44
+ const account = Account(this.sender, this.token.id);
45
+ const currentTokenBalance = account.balance.getAndAssertEquals();
46
+ const existingUserBlockstamps = UserBlockStamps.unpack(
47
+ currentTokenBalance.value
48
+ );
49
+
50
+ this.token.burn({
51
+ address: this.sender,
52
+ amount: currentTokenBalance,
53
+ });
54
+
55
+ existingUserBlockstamps[1] =
56
+ this.network.blockchainLength.getAndAssertEquals();
57
+ this.token.mint({
58
+ address: this.sender,
59
+ amount: UInt64.from(UserBlockStamps.pack(existingUserBlockstamps)),
60
+ });
61
+ }
62
+ }
@@ -0,0 +1,71 @@
1
+ import { AccountUpdate, Mina, PrivateKey, UInt32 } from 'o1js';
2
+ import { UserBlockStamps, UserBlockStampsToken } from './contract.js';
3
+
4
+ let Local = Mina.LocalBlockchain({ proofsEnabled: true });
5
+ Mina.setActiveInstance(Local);
6
+
7
+ // a test account that pays all the fees, and puts additional funds into the zkapp
8
+ let { privateKey: senderKey, publicKey: sender } = Local.testAccounts[0];
9
+
10
+ // the zkapp account
11
+ let zkappKey = PrivateKey.random();
12
+ let zkappAddress = zkappKey.toPublicKey();
13
+
14
+ // a special account that is allowed to pull out half of the zkapp balance, once
15
+ let privilegedKey = PrivateKey.random();
16
+ let privilegedAddress = privilegedKey.toPublicKey();
17
+
18
+ let initialBalance = 10_000_000_000;
19
+ let zkapp = new UserBlockStampsToken(zkappAddress);
20
+
21
+ console.time('compile');
22
+ await UserBlockStampsToken.compile();
23
+ console.timeEnd('compile');
24
+
25
+ console.time('deploy');
26
+ let tx = await Mina.transaction(sender, () => {
27
+ let senderUpdate = AccountUpdate.fundNewAccount(sender);
28
+ senderUpdate.send({ to: zkappAddress, amount: initialBalance });
29
+ zkapp.deploy({ zkappKey });
30
+ });
31
+ await tx.prove();
32
+ await tx.sign([senderKey]).send();
33
+ console.timeEnd('deploy');
34
+
35
+ Local.setBlockchainLength(UInt32.from(5));
36
+
37
+ console.time('join system');
38
+ tx = await Mina.transaction(sender, () => {
39
+ AccountUpdate.fundNewAccount(sender);
40
+ zkapp.joinSystem();
41
+ });
42
+ await tx.prove();
43
+ await tx.sign([senderKey]).send();
44
+ console.timeEnd('join system');
45
+
46
+ let tokenBalance = Mina.getBalance(sender, zkapp.token.id);
47
+ console.log(tokenBalance.toString());
48
+ console.log(UserBlockStamps.unpack(tokenBalance.value).toString());
49
+
50
+ Local.setBlockchainLength(UInt32.from(10));
51
+
52
+ console.time('interact with system');
53
+ tx = await Mina.transaction(sender, () => {
54
+ zkapp.interactWithSystem();
55
+ });
56
+ await tx.prove();
57
+ await tx.sign([senderKey]).send();
58
+ console.timeEnd('interact with system');
59
+
60
+ tokenBalance = Mina.getBalance(sender, zkapp.token.id);
61
+ console.log(tokenBalance.toString());
62
+ console.log(UserBlockStamps.unpack(tokenBalance.value).toString());
63
+
64
+ // compile: 1.818s
65
+ // deploy: 615.559ms
66
+ // join system: 23.085s
67
+ // 5
68
+ // 5,0
69
+ // interact with system: 15.263s
70
+ // 42949672965
71
+ // 5,10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "o1js-pack",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "author": "45930",
6
6
  "license": "Apache-2.0",
@@ -40,7 +40,7 @@
40
40
  "husky": "^7.0.1",
41
41
  "jest": "^27.3.1",
42
42
  "lint-staged": "^11.0.1",
43
- "o1js": "^0.14.*",
43
+ "o1js": "^0.15.1",
44
44
  "prettier": "^2.3.2",
45
45
  "ts-jest": "^27.0.7",
46
46
  "typescript": "^4.7.2"
@@ -1,16 +1,17 @@
1
1
  import {
2
- Experimental,
2
+ ZkProgram,
3
3
  SelfProof,
4
4
  Character,
5
5
  Poseidon,
6
6
  Provable,
7
7
  Field,
8
8
  } from 'o1js';
9
- import { MultiPackedStringFactory } from '../../src/lib/packed-types/PackedString';
9
+ import { PackedStringFactory } from '../../src/lib/packed-types/PackedString';
10
10
 
11
- export class TextInput extends MultiPackedStringFactory(3) {}
11
+ export class TextInput extends PackedStringFactory() {}
12
12
 
13
- export const TextInputProgram = Experimental.ZkProgram({
13
+ export const TextInputProgram = ZkProgram({
14
+ name: 'TextInputProgram',
14
15
  publicInput: TextInput,
15
16
 
16
17
  methods: {
@@ -22,7 +23,7 @@ export const TextInputProgram = Experimental.ZkProgram({
22
23
  },
23
24
  },
24
25
  changeFirstLetter: {
25
- privateInputs: [SelfProof, Provable.Array(Character, 45), Character],
26
+ privateInputs: [SelfProof, Provable.Array(Character, 31), Character],
26
27
  method(
27
28
  newState: TextInput,
28
29
  oldProof: SelfProof<TextInput, TextInput>,
@@ -43,5 +44,5 @@ export const TextInputProgram = Experimental.ZkProgram({
43
44
  },
44
45
  });
45
46
 
46
- export let TextInputProof_ = Experimental.ZkProgram.Proof(TextInputProgram);
47
+ export let TextInputProof_ = ZkProgram.Proof(TextInputProgram);
47
48
  export class TextInputProof extends TextInputProof_ {}
@@ -1,9 +1,10 @@
1
- import { Experimental, SelfProof } from 'o1js';
1
+ import { ZkProgram, SelfProof } from 'o1js';
2
2
  import { PackedUInt32Factory } from '../../src/lib/packed-types/PackedUInt32';
3
3
 
4
4
  export class Votes extends PackedUInt32Factory() {}
5
5
 
6
- export const VotesProgram = Experimental.ZkProgram({
6
+ export const VotesProgram = ZkProgram({
7
+ name: 'VotesProgram',
7
8
  publicInput: Votes,
8
9
 
9
10
  methods: {
@@ -35,5 +36,5 @@ export const VotesProgram = Experimental.ZkProgram({
35
36
  },
36
37
  });
37
38
 
38
- export let VotesProof_ = Experimental.ZkProgram.Proof(VotesProgram);
39
+ export let VotesProof_ = ZkProgram.Proof(VotesProgram);
39
40
  export class VotesProof extends VotesProof_ {}