o1js-pack 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. package/.husky/pre-commit +0 -0
  2. package/README.md +9 -30
  3. package/build/src/index.d.ts +5 -5
  4. package/build/src/index.js +5 -5
  5. package/build/src/lib/PackingPlant.d.ts +132 -140
  6. package/build/src/lib/PackingPlant.js +190 -191
  7. package/build/src/lib/PackingPlant.js.map +1 -1
  8. package/build/src/lib/packed-types/PackedBool.d.ts +85 -90
  9. package/build/src/lib/packed-types/PackedBool.js +49 -48
  10. package/build/src/lib/packed-types/PackedBool.js.map +1 -1
  11. package/build/src/lib/packed-types/PackedBool.test.d.ts +1 -1
  12. package/build/src/lib/packed-types/PackedBool.test.js +75 -75
  13. package/build/src/lib/packed-types/PackedString.d.ts +181 -92
  14. package/build/src/lib/packed-types/PackedString.js +127 -59
  15. package/build/src/lib/packed-types/PackedString.js.map +1 -1
  16. package/build/src/lib/packed-types/PackedString.test.d.ts +1 -1
  17. package/build/src/lib/packed-types/PackedString.test.js +100 -99
  18. package/build/src/lib/packed-types/PackedString.test.js.map +1 -1
  19. package/build/src/lib/packed-types/PackedUInt32.d.ts +85 -90
  20. package/build/src/lib/packed-types/PackedUInt32.js +49 -48
  21. package/build/src/lib/packed-types/PackedUInt32.js.map +1 -1
  22. package/build/src/lib/packed-types/PackedUInt32.test.d.ts +1 -1
  23. package/build/src/lib/packed-types/PackedUInt32.test.js +83 -83
  24. package/package.json +1 -1
  25. package/tests/provable/end_to_end.test.ts +2 -4
  26. package/tests/provable/example_packed_string_circuit.ts +3 -8
  27. package/tests/provable/example_packed_uint_circuit.ts +6 -12
  28. package/build/src/lib/packed-types/PackedCharacter.d.ts +0 -51
  29. package/build/src/lib/packed-types/PackedCharacter.js +0 -34
  30. package/build/src/lib/packed-types/PackedCharacter.js.map +0 -1
  31. package/build/src/lib/packed-types/PackedCharacter.test.d.ts +0 -1
  32. package/build/src/lib/packed-types/PackedCharacter.test.js +0 -31
  33. package/build/src/lib/packed-types/PackedCharacter.test.js.map +0 -1
  34. package/build/src/lib/scratch.d.ts +0 -1
  35. package/build/src/lib/scratch.js +0 -16
  36. package/build/src/lib/scratch.js.map +0 -1
  37. package/build/src/packed-types/PackedBool.d.ts +0 -51
  38. package/build/src/packed-types/PackedBool.js +0 -34
  39. package/build/src/packed-types/PackedBool.js.map +0 -1
  40. package/build/src/packed-types/PackedBool.test.d.ts +0 -1
  41. package/build/src/packed-types/PackedBool.test.js +0 -101
  42. package/build/src/packed-types/PackedBool.test.js.map +0 -1
  43. package/build/src/packed-types/PackedCharacter.d.ts +0 -51
  44. package/build/src/packed-types/PackedCharacter.js +0 -34
  45. package/build/src/packed-types/PackedCharacter.js.map +0 -1
  46. package/build/src/packed-types/PackedCharacter.test.d.ts +0 -1
  47. package/build/src/packed-types/PackedCharacter.test.js +0 -31
  48. package/build/src/packed-types/PackedCharacter.test.js.map +0 -1
  49. package/build/src/packed-types/PackedUInt32.d.ts +0 -51
  50. package/build/src/packed-types/PackedUInt32.js +0 -34
  51. package/build/src/packed-types/PackedUInt32.js.map +0 -1
  52. package/build/src/packed-types/PackedUInt32.test.d.ts +0 -1
  53. package/build/src/packed-types/PackedUInt32.test.js +0 -68
  54. package/build/src/packed-types/PackedUInt32.test.js.map +0 -1
  55. package/build/src/packed-types/PackingPlant.d.ts +0 -54
  56. package/build/src/packed-types/PackingPlant.js +0 -45
  57. package/build/src/packed-types/PackingPlant.js.map +0 -1
  58. package/build/src/packed-types/scratch.d.ts +0 -1
  59. package/build/src/packed-types/scratch.js +0 -5
  60. package/build/src/packed-types/scratch.js.map +0 -1
  61. package/coverage/clover.xml +0 -166
  62. package/coverage/coverage-final.json +0 -5
  63. package/coverage/lcov-report/PackedBool.ts.html +0 -268
  64. package/coverage/lcov-report/PackedUInt32.ts.html +0 -313
  65. package/coverage/lcov-report/base.css +0 -224
  66. package/coverage/lcov-report/block-navigation.js +0 -87
  67. package/coverage/lcov-report/favicon.png +0 -0
  68. package/coverage/lcov-report/index.html +0 -131
  69. package/coverage/lcov-report/lib/PackingPlant.ts.html +0 -478
  70. package/coverage/lcov-report/lib/index.html +0 -116
  71. package/coverage/lcov-report/lib/packed-types/PackedBool.ts.html +0 -238
  72. package/coverage/lcov-report/lib/packed-types/PackedString.ts.html +0 -364
  73. package/coverage/lcov-report/lib/packed-types/PackedUInt32.ts.html +0 -238
  74. package/coverage/lcov-report/lib/packed-types/index.html +0 -146
  75. package/coverage/lcov-report/prettify.css +0 -1
  76. package/coverage/lcov-report/prettify.js +0 -2
  77. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  78. package/coverage/lcov-report/sorter.js +0 -196
  79. package/coverage/lcov.info +0 -282
@@ -1,60 +1,128 @@
1
- import { Field, Provable, Character } from 'o1js';
2
- import { 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;
6
- export function PackedStringFactory(l = L) {
7
- class PackedString_ extends MultiPackingPlant(Character, l, SIZE_IN_BITS) {
8
- static extractField(input) {
9
- return input.value;
10
- }
11
- static sizeInBits() {
12
- return SIZE_IN_BITS;
13
- }
14
- static elementsPerField() {
15
- return CHARS_PER_FIELD;
16
- }
17
- /**
18
- *
19
- * @param fields Array of Fields, containing packed Characters
20
- * @returns Array of Character
21
- */
22
- static unpack(fields) {
23
- const unpacked = Provable.witness(Provable.Array(Character, l), () => {
24
- let unpacked = this.unpackToBigints(fields);
25
- return unpacked.map((x) => Character.fromString(String.fromCharCode(Number(x))));
26
- });
27
- return unpacked;
28
- }
29
- /**
30
- *
31
- * @param characters Array of Character to be packed
32
- * @returns Instance of the implementing class
33
- */
34
- static fromCharacters(characters) {
35
- const packed = this.pack(characters);
36
- return new PackedString_(packed);
37
- }
38
- /**
39
- *
40
- * @param str string to be packed
41
- * @returns Instance of the implementing class
42
- */
43
- static fromString(str) {
44
- let characters = new Array(l);
45
- characters.fill(new Character(Field(0)), 0, l);
46
- for (let i = 0; i < str.length; i++) {
47
- characters[i] = Character.fromString(str[i]);
48
- }
49
- return this.fromCharacters(characters);
50
- }
51
- toString() {
52
- const nullChar = String.fromCharCode(0);
53
- return PackedString_.unpack(this.packed)
54
- .filter((c) => c.toString() !== nullChar)
55
- .join('');
56
- }
57
- }
58
- return PackedString_;
59
- }
1
+ import { Field, Provable, Character, Poseidon } from 'o1js';
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;
6
+ export function PackedStringFactory(l = L) {
7
+ class PackedString_ extends PackingPlant(Character, l, SIZE_IN_BITS) {
8
+ static extractField(input) {
9
+ return input.value;
10
+ }
11
+ static sizeInBits() {
12
+ return SIZE_IN_BITS;
13
+ }
14
+ /**
15
+ *
16
+ * @param f Field, packed with the information, as returned by #pack
17
+ * @returns Array of Character
18
+ */
19
+ static unpack(f) {
20
+ const unpacked = Provable.witness(Provable.Array(Character, l), () => {
21
+ const unpacked = this.unpackToBigints(f);
22
+ return unpacked.map((x) => Character.fromString(String.fromCharCode(Number(x))));
23
+ });
24
+ f.assertEquals(PackedString_.pack(unpacked));
25
+ return unpacked;
26
+ }
27
+ /**
28
+ *
29
+ * @param characters Array of Character to be packed
30
+ * @returns Instance of the implementing class
31
+ */
32
+ static fromCharacters(input) {
33
+ let characters = new Array(this.l);
34
+ characters.fill(new Character(Field(0)), 0, this.l);
35
+ for (let i = 0; i < input.length; i++) {
36
+ characters[i] = input[i];
37
+ }
38
+ const packed = this.pack(characters);
39
+ return new PackedString_(packed);
40
+ }
41
+ /**
42
+ *
43
+ * @param str string to be packed
44
+ * @returns Instance of the implementing class
45
+ */
46
+ static fromString(str) {
47
+ let characters = new Array(this.l);
48
+ characters.fill(new Character(Field(0)), 0, this.l);
49
+ for (let i = 0; i < str.length; i++) {
50
+ characters[i] = Character.fromString(str[i]);
51
+ }
52
+ return this.fromCharacters(characters);
53
+ }
54
+ toString() {
55
+ const nullChar = String.fromCharCode(0);
56
+ return PackedString_.unpack(this.packed)
57
+ .filter((c) => c.toString() !== nullChar)
58
+ .join('');
59
+ }
60
+ }
61
+ return PackedString_;
62
+ }
63
+ /**
64
+ *
65
+ * @param n number of fields to employ to store the string
66
+ * @returns MultiPackedString_ class with length of n * CHARS_PER_FIELD
67
+ */
68
+ export function MultiPackedStringFactory(n = 8) {
69
+ class MultiPackedString_ extends MultiPackingPlant(Character, n * CHARS_PER_FIELD, SIZE_IN_BITS) {
70
+ static extractField(input) {
71
+ return input.value;
72
+ }
73
+ static sizeInBits() {
74
+ return SIZE_IN_BITS;
75
+ }
76
+ static elementsPerField() {
77
+ return CHARS_PER_FIELD;
78
+ }
79
+ /**
80
+ *
81
+ * @param fields Array of Fields, containing packed Characters
82
+ * @returns Array of Character
83
+ */
84
+ static unpack(fields) {
85
+ const unpacked = Provable.witness(Provable.Array(Character, this.l), () => {
86
+ let unpacked = this.unpackToBigints(fields);
87
+ return unpacked.map((x) => Character.fromString(String.fromCharCode(Number(x))));
88
+ });
89
+ Poseidon.hash(fields).assertEquals(Poseidon.hash(MultiPackedString_.pack(unpacked)));
90
+ return unpacked;
91
+ }
92
+ /**
93
+ *
94
+ * @param characters Array of Character to be packed
95
+ * @returns Instance of the implementing class
96
+ */
97
+ static fromCharacters(input) {
98
+ let characters = new Array(this.l);
99
+ characters.fill(new Character(Field(0)), 0, this.l);
100
+ for (let i = 0; i < input.length; i++) {
101
+ characters[i] = input[i];
102
+ }
103
+ const packed = this.pack(characters);
104
+ return new MultiPackedString_(packed);
105
+ }
106
+ /**
107
+ *
108
+ * @param str string to be packed
109
+ * @returns Instance of the implementing class
110
+ */
111
+ static fromString(str) {
112
+ let characters = new Array(this.l);
113
+ characters.fill(new Character(Field(0)), 0, this.l);
114
+ for (let i = 0; i < str.length; i++) {
115
+ characters[i] = Character.fromString(str[i]);
116
+ }
117
+ return this.fromCharacters(characters);
118
+ }
119
+ toString() {
120
+ const nullChar = String.fromCharCode(0);
121
+ return MultiPackedString_.unpack(this.packed)
122
+ .filter((c) => c.toString() !== nullChar)
123
+ .join('');
124
+ }
125
+ }
126
+ return MultiPackedString_;
127
+ }
60
128
  //# sourceMappingURL=PackedString.js.map
@@ -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,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,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,iBAAiB,CAAC,SAAS,EAAE,CAAC,EAAE,YAAY,CAAC;QACvE,MAAM,CAAC,YAAY,CAAC,KAAgB;YAClC,OAAO,KAAK,CAAC,KAAK,CAAC;QACrB,CAAC;QAED,MAAM,CAAC,UAAU;YACf,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,MAAM,CAAC,gBAAgB;YACrB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED;;;;WAIG;QACH,MAAM,CAAC,MAAM,CAAC,MAAe;YAC3B,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE;gBACnE,IAAI,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;gBAC5C,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,C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ACrC,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;aAC1B;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACrC,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QAED;;;;WAIG;QACH,MAAM,CAAC,UAAU,CAAC,GAAW;YAC3B,IAAI,UAAU,GAAqB,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACrD,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;YACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACnC,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9C;YACD,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;QAED,QAAQ;YACN,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACxC,OAAO,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;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 +1 @@
1
- export {};
1
+ export {};
@@ -1,100 +1,101 @@
1
- import { Character, Provable } from 'o1js';
2
- import { PackedStringFactory } from './PackedString';
3
- describe('PackedString', () => {
4
- describe('Outside of the Circuit', () => {
5
- const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
6
- class EthAddressString extends PackedStringFactory(42) {
7
- }
8
- let characters = [];
9
- beforeEach(() => {
10
- characters = [];
11
- for (let i = 0; i < vitalik_dot_eth.length; i++) {
12
- characters.push(Character.fromString(vitalik_dot_eth[i]));
13
- }
14
- });
15
- it('#fromString', () => {
16
- const myEthAddress = EthAddressString.fromString(vitalik_dot_eth);
17
- expect(myEthAddress.toString()).toBe(vitalik_dot_eth);
18
- });
19
- it('#fromCharacters', () => {
20
- const myEthAddress = EthAddressString.fromCharacters(characters);
21
- expect(myEthAddress.toString()).toBe(vitalik_dot_eth);
22
- });
23
- it('#pack and #unPack', () => {
24
- const packed = EthAddressString.pack(characters);
25
- const unpacked = EthAddressString.unpack(packed);
26
- expect(packed.length).toBe(Math.ceil(vitalik_dot_eth.length / 15));
27
- expect(unpacked.length).toBe(vitalik_dot_eth.length);
28
- expect(unpacked.toString()).toBe(characters.toString());
29
- });
30
- });
31
- describe('Provable Properties', () => {
32
- it('#sizeInFields', () => {
33
- class one extends PackedStringFactory(15) {
34
- }
35
- class two extends PackedStringFactory(16) {
36
- }
37
- class three extends PackedStringFactory(40) {
38
- }
39
- expect(one.sizeInFields()).toBe(1);
40
- expect(two.sizeInFields()).toBe(2);
41
- expect(three.sizeInFields()).toBe(3);
42
- });
43
- });
44
- describe('Defensive Cases', () => {
45
- it('Initializes a class with fewer than allowed characters', () => {
46
- class String10 extends PackedStringFactory(10) {
47
- }
48
- const string0 = String10.fromString('');
49
- const string2 = String10.fromString('ab');
50
- expect(string0.toString()).toBe('');
51
- expect(string2.toString()).toBe('ab');
52
- });
53
- it('Initializes a class with more than allowed characters', () => {
54
- class String10 extends PackedStringFactory(10) {
55
- }
56
- expect(() => {
57
- String10.fromString('abcdefghijk');
58
- }).toThrow();
59
- });
60
- it('Exceeds maximum size string', () => {
61
- const tooLong = 'too long!'.repeat(20);
62
- class MaxString extends PackedStringFactory(120) {
63
- }
64
- expect(() => {
65
- MaxString.fromString(tooLong);
66
- }).toThrow();
67
- });
68
- });
69
- describe('In the circuit', () => {
70
- const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
71
- class EthAddressString extends PackedStringFactory(42) {
72
- }
73
- const outsideEthAddress = EthAddressString.fromString(vitalik_dot_eth);
74
- it('Initializes a string', () => {
75
- expect(() => {
76
- Provable.runAndCheck(() => {
77
- const myEthAddress = new EthAddressString(outsideEthAddress.packed);
78
- EthAddressString.check({ packed: myEthAddress.packed });
79
- });
80
- }).not.toThrow();
81
- });
82
- it('#assertEquals', () => {
83
- expect(() => {
84
- Provable.runAndCheck(() => {
85
- const myEthAddress = new EthAddressString(outsideEthAddress.packed);
86
- myEthAddress.assertEquals(outsideEthAddress);
87
- });
88
- }).not.toThrow();
89
- expect(() => {
90
- Provable.runAndCheck(() => {
91
- const fakePacked = [...outsideEthAddress.packed];
92
- fakePacked[0] = fakePacked[0].add(1);
93
- const myEthAddress = new EthAddressString(fakePacked);
94
- myEthAddress.assertEquals(outsideEthAddress);
95
- });
96
- }).toThrow();
97
- });
98
- });
99
- });
1
+ import { Character, Provable } from 'o1js';
2
+ import { PackedStringFactory, MultiPackedStringFactory } from './PackedString';
3
+ describe('PackedString', () => {
4
+ describe('Outside of the Circuit', () => {
5
+ const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
6
+ class EthAddressString extends MultiPackedStringFactory(3) {
7
+ }
8
+ let characters = [];
9
+ beforeEach(() => {
10
+ characters = [];
11
+ for (let i = 0; i < vitalik_dot_eth.length; i++) {
12
+ characters.push(Character.fromString(vitalik_dot_eth[i]));
13
+ }
14
+ });
15
+ it('#fromString', () => {
16
+ const myEthAddress = EthAddressString.fromString(vitalik_dot_eth);
17
+ expect(myEthAddress.toString()).toBe(vitalik_dot_eth);
18
+ });
19
+ it('#fromCharacters', () => {
20
+ const myEthAddress = EthAddressString.fromCharacters(characters);
21
+ expect(myEthAddress.toString()).toBe(vitalik_dot_eth);
22
+ });
23
+ it('#pack and #unPack', () => {
24
+ const unpacked = EthAddressString.unpack(EthAddressString.fromCharacters(characters).packed);
25
+ const packed = EthAddressString.pack(unpacked);
26
+ expect(packed.length).toBe(Math.ceil(vitalik_dot_eth.length / 15));
27
+ expect(unpacked.length).toBe(EthAddressString.l);
28
+ expect(unpacked.length).toBe(45);
29
+ expect(unpacked.slice(0, characters.length).toString()).toBe(characters.toString());
30
+ });
31
+ });
32
+ describe('Provable Properties', () => {
33
+ it('#sizeInFields', () => {
34
+ class one extends PackedStringFactory(15) {
35
+ }
36
+ class two extends MultiPackedStringFactory(2) {
37
+ }
38
+ class three extends MultiPackedStringFactory(3) {
39
+ }
40
+ expect(one.sizeInFields()).toBe(1);
41
+ expect(two.sizeInFields()).toBe(2);
42
+ expect(three.sizeInFields()).toBe(3);
43
+ });
44
+ });
45
+ describe('Defensive Cases', () => {
46
+ it('Initializes a class with fewer than allowed characters', () => {
47
+ class String10 extends PackedStringFactory(10) {
48
+ }
49
+ const string0 = String10.fromString('');
50
+ const string2 = String10.fromString('ab');
51
+ expect(string0.toString()).toBe('');
52
+ expect(string2.toString()).toBe('ab');
53
+ });
54
+ it('Initializes a class with more than allowed characters', () => {
55
+ class String10 extends PackedStringFactory(10) {
56
+ }
57
+ expect(() => {
58
+ String10.fromString('abcdefghijk');
59
+ }).toThrow();
60
+ });
61
+ it('Exceeds maximum size string', () => {
62
+ const tooLong = 'too long!'.repeat(20);
63
+ class MaxString extends MultiPackedStringFactory(8) {
64
+ }
65
+ expect(() => {
66
+ MaxString.fromString(tooLong);
67
+ }).toThrow();
68
+ });
69
+ });
70
+ describe('In the circuit', () => {
71
+ const vitalik_dot_eth = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
72
+ class EthAddressString extends MultiPackedStringFactory(3) {
73
+ }
74
+ const outsideEthAddress = EthAddressString.fromString(vitalik_dot_eth);
75
+ it('Initializes a string', () => {
76
+ expect(() => {
77
+ Provable.runAndCheck(() => {
78
+ const myEthAddress = new EthAddressString(outsideEthAddress.packed);
79
+ EthAddressString.check({ packed: myEthAddress.packed });
80
+ });
81
+ }).not.toThrow();
82
+ });
83
+ it('#assertEquals', () => {
84
+ expect(() => {
85
+ Provable.runAndCheck(() => {
86
+ const myEthAddress = new EthAddressString(outsideEthAddress.packed);
87
+ myEthAddress.assertEquals(outsideEthAddress);
88
+ });
89
+ }).not.toThrow();
90
+ expect(() => {
91
+ Provable.runAndCheck(() => {
92
+ const fakePacked = [...outsideEthAddress.packed];
93
+ fakePacked[0] = fakePacked[0].add(1);
94
+ const myEthAddress = new EthAddressString(fakePacked);
95
+ myEthAddress.assertEquals(outsideEthAddress);
96
+ });
97
+ }).toThrow();
98
+ });
99
+ });
100
+ });
100
101
  //# sourceMappingURL=PackedString.test.js.map
@@ -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,MAAM,gBAAgB,CAAC;AAErD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,eAAe,GAAG,4CAA4C,CAAC;QACrE,MAAM,gBAAiB,SAAQ,mBAAmB,CAAC,EAAE,CAAC;SAAG;QACzD,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,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC/C,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3D;QACH,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,aAAa,EA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,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"}
@@ -1,90 +1,85 @@
1
- import { Field, UInt32 } from 'o1js';
2
- export declare function PackedUInt32Factory(l?: number): {
3
- new (packed: import("o1js/dist/node/lib/field.js").Field): {
4
- toBigInts(): Array<bigint>;
5
- bitSize: bigint;
6
- assertEquals(other: {
7
- bitSize: bigint;
8
- assertEquals(other: any): void;
9
- packed: import("o1js/dist/node/lib/field.js").Field;
10
- }): void;
11
- packed: import("o1js/dist/node/lib/field.js").Field;
12
- };
13
- extractField(input: UInt32): Field;
14
- sizeInBits(): bigint;
15
- /**
16
- *
17
- * @param f Field, packed with the information, as returned by #pack
18
- * @returns Array of UInt32
19
- */
20
- unpack(f: Field): UInt32[];
21
- /**
22
- *
23
- * @param uint32s Array of UInt32s to be packed
24
- * @returns Instance of the implementing class
25
- */
26
- fromUInt32s(uint32s: Array<UInt32>): {
27
- toBigInts(): Array<bigint>;
28
- bitSize: bigint;
29
- assertEquals(other: {
30
- bitSize: bigint;
31
- assertEquals(other: any): void;
32
- packed: import("o1js/dist/node/lib/field.js").Field;
33
- }): void;
34
- packed: import("o1js/dist/node/lib/field.js").Field;
35
- };
36
- /**
37
- *
38
- * @param bigints Array of bigints to be packed
39
- * @returns Instance of the implementing class
40
- */
41
- fromBigInts(bigints: Array<bigint>): {
42
- toBigInts(): Array<bigint>;
43
- bitSize: bigint;
44
- assertEquals(other: {
45
- bitSize: bigint;
46
- assertEquals(other: any): void;
47
- packed: import("o1js/dist/node/lib/field.js").Field;
48
- }): void;
49
- packed: import("o1js/dist/node/lib/field.js").Field;
50
- };
51
- type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
52
- packed: import("o1js/dist/node/lib/field.js").Field;
53
- }, {
54
- packed: string;
55
- }>;
56
- l: number;
57
- checkPack(unpacked: UInt32[]): void;
58
- pack(unpacked: UInt32[]): import("o1js/dist/node/lib/field.js").Field;
59
- unpackToBigints(f: import("o1js/dist/node/lib/field.js").Field): bigint[];
60
- _isStruct: true;
61
- toFields: (value: {
62
- packed: import("o1js/dist/node/lib/field.js").Field;
63
- }) => import("o1js/dist/node/lib/field.js").Field[];
64
- toAuxiliary: (value?: {
65
- packed: import("o1js/dist/node/lib/field.js").Field;
66
- } | undefined) => any[];
67
- fromFields: (fields: import("o1js/dist/node/lib/field.js").Field[]) => {
68
- packed: import("o1js/dist/node/lib/field.js").Field;
69
- };
70
- sizeInFields(): number;
71
- check: (value: {
72
- packed: import("o1js/dist/node/lib/field.js").Field;
73
- }) => void;
74
- toInput: (x: {
75
- packed: import("o1js/dist/node/lib/field.js").Field;
76
- }) => {
77
- fields?: import("o1js/dist/node/lib/field.js").Field[] | undefined;
78
- packed?: [import("o1js/dist/node/lib/field.js").Field, number][] | undefined;
79
- };
80
- toJSON: (x: {
81
- packed: import("o1js/dist/node/lib/field.js").Field;
82
- }) => {
83
- packed: string;
84
- };
85
- fromJSON: (x: {
86
- packed: string;
87
- }) => {
88
- packed: import("o1js/dist/node/lib/field.js").Field;
89
- };
90
- };
1
+ import { Field, UInt32 } from 'o1js';
2
+ export declare function PackedUInt32Factory(l?: number): {
3
+ new (packed: import("o1js/dist/node/lib/field.js").Field): {
4
+ toBigInts(): Array<bigint>;
5
+ assertEquals(other: {
6
+ assertEquals(other: any): void;
7
+ packed: import("o1js/dist/node/lib/field.js").Field;
8
+ }): void;
9
+ packed: import("o1js/dist/node/lib/field.js").Field;
10
+ };
11
+ extractField(input: UInt32): Field;
12
+ sizeInBits(): bigint;
13
+ /**
14
+ *
15
+ * @param f Field, packed with the information, as returned by #pack
16
+ * @returns Array of UInt32
17
+ */
18
+ unpack(f: Field): UInt32[];
19
+ /**
20
+ *
21
+ * @param uint32s Array of UInt32s to be packed
22
+ * @returns Instance of the implementing class
23
+ */
24
+ fromUInt32s(uint32s: Array<UInt32>): {
25
+ toBigInts(): Array<bigint>;
26
+ assertEquals(other: {
27
+ assertEquals(other: any): void;
28
+ packed: import("o1js/dist/node/lib/field.js").Field;
29
+ }): void;
30
+ packed: import("o1js/dist/node/lib/field.js").Field;
31
+ };
32
+ /**
33
+ *
34
+ * @param bigints Array of bigints to be packed
35
+ * @returns Instance of the implementing class
36
+ */
37
+ fromBigInts(bigints: Array<bigint>): {
38
+ toBigInts(): Array<bigint>;
39
+ assertEquals(other: {
40
+ assertEquals(other: any): void;
41
+ packed: import("o1js/dist/node/lib/field.js").Field;
42
+ }): void;
43
+ packed: import("o1js/dist/node/lib/field.js").Field;
44
+ };
45
+ type: import("o1js/dist/node/bindings/lib/provable-snarky.js").ProvableExtended<{
46
+ packed: import("o1js/dist/node/lib/field.js").Field;
47
+ }, {
48
+ packed: string;
49
+ }>;
50
+ l: number;
51
+ bitSize: bigint;
52
+ checkPack(unpacked: UInt32[]): void;
53
+ pack(unpacked: UInt32[]): import("o1js/dist/node/lib/field.js").Field;
54
+ unpackToBigints(f: import("o1js/dist/node/lib/field.js").Field): bigint[];
55
+ _isStruct: true;
56
+ toFields: (value: {
57
+ packed: import("o1js/dist/node/lib/field.js").Field;
58
+ }) => import("o1js/dist/node/lib/field.js").Field[];
59
+ toAuxiliary: (value?: {
60
+ packed: import("o1js/dist/node/lib/field.js").Field;
61
+ } | undefined) => any[];
62
+ fromFields: (fields: import("o1js/dist/node/lib/field.js").Field[]) => {
63
+ packed: import("o1js/dist/node/lib/field.js").Field;
64
+ };
65
+ sizeInFields(): number;
66
+ check: (value: {
67
+ packed: import("o1js/dist/node/lib/field.js").Field;
68
+ }) => void;
69
+ toInput: (x: {
70
+ packed: import("o1js/dist/node/lib/field.js").Field;
71
+ }) => {
72
+ fields?: import("o1js/dist/node/lib/field.js").Field[] | undefined;
73
+ packed?: [import("o1js/dist/node/lib/field.js").Field, number][] | undefined;
74
+ };
75
+ toJSON: (x: {
76
+ packed: import("o1js/dist/node/lib/field.js").Field;
77
+ }) => {
78
+ packed: string;
79
+ };
80
+ fromJSON: (x: {
81
+ packed: string;
82
+ }) => {
83
+ packed: import("o1js/dist/node/lib/field.js").Field;
84
+ };
85
+ };