o1js-pack 0.4.4 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +1 -1
- package/CHANGELOG.md +5 -0
- package/build/src/lib/PackingPlant.d.ts +8 -0
- package/build/src/lib/PackingPlant.js +14 -0
- package/build/src/lib/PackingPlant.js.map +1 -1
- package/build/src/lib/packed-types/PackedBool.d.ts +6 -0
- package/build/src/lib/packed-types/PackedString.d.ts +17 -6
- package/build/src/lib/packed-types/PackedString.js +3 -3
- package/build/src/lib/packed-types/PackedString.js.map +1 -1
- package/build/src/lib/packed-types/PackedString.test.js +25 -6
- package/build/src/lib/packed-types/PackedString.test.js.map +1 -1
- package/build/src/lib/packed-types/PackedUInt32.d.ts +6 -0
- package/package.json +2 -2
- package/tests/provable/example_packed_string_circuit.ts +3 -3
package/.eslintrc.cjs
CHANGED
package/CHANGELOG.md
ADDED
@@ -1,5 +1,9 @@
|
|
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
|
}) & {
|
@@ -66,6 +70,10 @@ export declare function PackingPlant<A, T extends InferProvable<A> = InferProvab
|
|
66
70
|
};
|
67
71
|
};
|
68
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>;
|
69
77
|
assertEquals(other: any): void;
|
70
78
|
packed: import("o1js/dist/node/lib/field").Field[];
|
71
79
|
}) & {
|
@@ -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,
|
1
|
+
{"version":3,"file":"PackingPlant.js","sourceRoot":"","sources":["../../../src/lib/PackingPlant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EAEN,QAAQ,EAER,QAAQ,GAET,MAAM,MAAM,CAAC;AAEd,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,MAAM,UAAU,YAAY,CAC1B,WAAc,EACd,CAAS,EACT,OAAe;IAEf,IAAI,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,kBAAkB,EAAE;QAC5C,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAC;KACH;IACD,MAAe,OAAQ,SAAQ,MAAM,CAAC;QACpC,MAAM,EAAE,KAAK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AAE,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,7 +40,9 @@ 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;
|
@@ -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,17 +40,14 @@ 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;
|
43
49
|
packed: import("o1js/dist/node/lib/field.js").Field;
|
44
50
|
};
|
45
|
-
/**
|
46
|
-
*
|
47
|
-
* @param f Field, packed with the information, as returned by #pack
|
48
|
-
* @returns Array of Character
|
49
|
-
*/
|
50
51
|
type: import("o1js/dist/node/bindings/lib/generic.js").GenericProvableExtendedPure<{
|
51
52
|
packed: import("o1js/dist/node/lib/field.js").Field;
|
52
53
|
}, {
|
@@ -56,7 +57,11 @@ export declare function PackedStringFactory(l?: number): {
|
|
56
57
|
bitSize: bigint;
|
57
58
|
checkPack(unpacked: Character[]): void;
|
58
59
|
pack(unpacked: Character[]): import("o1js/dist/node/lib/field.js").Field;
|
59
|
-
unpackToBigints(f: import("o1js/dist/node/lib/field.js").Field): bigint[];
|
60
|
+
unpackToBigints(f: import("o1js/dist/node/lib/field.js").Field): bigint[]; /**
|
61
|
+
*
|
62
|
+
* @param fields Array of Fields, containing packed Characters
|
63
|
+
* @returns Array of Character
|
64
|
+
*/
|
60
65
|
_isStruct: true;
|
61
66
|
toFields: (value: {
|
62
67
|
packed: import("o1js/dist/node/lib/field.js").Field;
|
@@ -99,7 +104,9 @@ export declare function PackedStringFactory(l?: number): {
|
|
99
104
|
export declare function MultiPackedStringFactory(n?: number): {
|
100
105
|
new (packed: import("o1js/dist/node/lib/field.js").Field[]): {
|
101
106
|
toString(): string;
|
107
|
+
toFields(): import("o1js/dist/node/lib/field.js").Field[];
|
102
108
|
assertEquals(other: {
|
109
|
+
toFields(): import("o1js/dist/node/lib/field.js").Field[];
|
103
110
|
assertEquals(other: any): void;
|
104
111
|
packed: import("o1js/dist/node/lib/field.js").Field[];
|
105
112
|
}): void;
|
@@ -121,7 +128,9 @@ export declare function MultiPackedStringFactory(n?: number): {
|
|
121
128
|
*/
|
122
129
|
fromCharacters(input: Array<Character>): {
|
123
130
|
toString(): string;
|
131
|
+
toFields(): import("o1js/dist/node/lib/field.js").Field[];
|
124
132
|
assertEquals(other: {
|
133
|
+
toFields(): import("o1js/dist/node/lib/field.js").Field[];
|
125
134
|
assertEquals(other: any): void;
|
126
135
|
packed: import("o1js/dist/node/lib/field.js").Field[];
|
127
136
|
}): void;
|
@@ -134,7 +143,9 @@ export declare function MultiPackedStringFactory(n?: number): {
|
|
134
143
|
*/
|
135
144
|
fromString(str: string): {
|
136
145
|
toString(): string;
|
146
|
+
toFields(): import("o1js/dist/node/lib/field.js").Field[];
|
137
147
|
assertEquals(other: {
|
148
|
+
toFields(): import("o1js/dist/node/lib/field.js").Field[];
|
138
149
|
assertEquals(other: any): void;
|
139
150
|
packed: import("o1js/dist/node/lib/field.js").Field[];
|
140
151
|
}): void;
|
@@ -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 =
|
4
|
-
const L =
|
5
|
-
const CHARS_PER_FIELD =
|
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,
|
1
|
+
{"version":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|
|
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(
|
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 /
|
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(
|
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(
|
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(
|
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,
|
1
|
+
{"version":3,"file":"PackedString.test.js","sourceRoot":"","sources":["../../../../src/lib/packed-types/PackedString.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,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,CAA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UInt32Factory(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,7 +40,9 @@ 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;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "o1js-pack",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.1",
|
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.
|
43
|
+
"o1js": "^0.16.0",
|
44
44
|
"prettier": "^2.3.2",
|
45
45
|
"ts-jest": "^27.0.7",
|
46
46
|
"typescript": "^4.7.2"
|
@@ -6,9 +6,9 @@ import {
|
|
6
6
|
Provable,
|
7
7
|
Field,
|
8
8
|
} from 'o1js';
|
9
|
-
import {
|
9
|
+
import { PackedStringFactory } from '../../src/lib/packed-types/PackedString';
|
10
10
|
|
11
|
-
export class TextInput extends
|
11
|
+
export class TextInput extends PackedStringFactory() {}
|
12
12
|
|
13
13
|
export const TextInputProgram = ZkProgram({
|
14
14
|
name: 'TextInputProgram',
|
@@ -23,7 +23,7 @@ export const TextInputProgram = ZkProgram({
|
|
23
23
|
},
|
24
24
|
},
|
25
25
|
changeFirstLetter: {
|
26
|
-
privateInputs: [SelfProof, Provable.Array(Character,
|
26
|
+
privateInputs: [SelfProof, Provable.Array(Character, 31), Character],
|
27
27
|
method(
|
28
28
|
newState: TextInput,
|
29
29
|
oldProof: SelfProof<TextInput, TextInput>,
|