kiosk-pow-cuckoo 0.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +106 -0
- data/LICENSE.txt +202 -0
- data/README.md +214 -0
- data/lib/kiosk/pow/cuckoo/sip_hash.rb +48 -0
- data/lib/kiosk/pow/cuckoo/version.rb +9 -0
- data/lib/kiosk/pow/cuckoo.rb +113 -0
- data/requirements.txt +1 -0
- data/solve_cuckoo.py +435 -0
- metadata +84 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3ee38fdb1050afecc47067237db209eb98f648e5b57936098e3e4fa2b8f45175
|
|
4
|
+
data.tar.gz: 78e5c7cf7f2fbf198e26e9345d34b56fa58190d1b67f08b398fc6c8405a7b099
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a171853ddb0e41273bf6fd6856b5082a29110a8e8de852d3e984520fb86bf088e2008617b4d747be94ebd4bcc5d7b9fc4cc23111d74b3fbae6ff0a301d084d8a
|
|
7
|
+
data.tar.gz: 373d473dc85980ccb8c5402c0b7c42aa2ea9a2be08ae87edff957821725a20ef3d618e5de852acfbf812598d443eea7e270ecc0a6b1e65944268a97db37deaa4
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
How to write an entry, and what a release section means: `CHANGELOG-RULE.md` at
|
|
4
|
+
the root of this repository —
|
|
5
|
+
<https://github.com/kiosk-hq/kiosk/blob/main/CHANGELOG-RULE.md>. In short: under
|
|
6
|
+
200 characters, one or two sentences, the essence rather than the content; write it
|
|
7
|
+
under `## [Unreleased]`; a cut renames that heading to
|
|
8
|
+
`## [MAJOR.MINOR.PATCH] — <date>` and opens a fresh empty one above it; nothing
|
|
9
|
+
already written is edited.
|
|
10
|
+
|
|
11
|
+
## [Unreleased]
|
|
12
|
+
|
|
13
|
+
## [0.5.20] — 2026-10-20
|
|
14
|
+
|
|
15
|
+
- 2026-10-20: Version 0.5.20, the tree cut that matches skill 0.5.20.
|
|
16
|
+
|
|
17
|
+
## [0.5.19] — 2026-10-20
|
|
18
|
+
|
|
19
|
+
- 2026-10-20: Version 0.5.19, the tree cut that matches skill 0.5.19.
|
|
20
|
+
|
|
21
|
+
## [0.5.18] — 2026-10-18
|
|
22
|
+
|
|
23
|
+
- 2026-10-18: Version 0.5.18, the tree cut that matches skill 0.5.18.
|
|
24
|
+
|
|
25
|
+
## [0.5.17] — 2026-10-18
|
|
26
|
+
|
|
27
|
+
- 2026-10-18: The README gives the bundled solver's memory as measured, ~118 bytes per edge (~59 GiB at edgebits=29), and names no native-solver figure.
|
|
28
|
+
- 2026-10-18: The solver's memory guard predicts the measured peak, 120 bytes per edge, so edgebits 24 is refused under the default 1.5 GiB cap.
|
|
29
|
+
|
|
30
|
+
## [0.5.16] — 2026-10-18
|
|
31
|
+
|
|
32
|
+
- 2026-10-18: Built on kiosk-pow: BLAKE2b-256 is `Kiosk::Pow::Blake2b.digest256`, and `Cuckoo.blake2b256` is gone. Verify results are byte-for-byte the same.
|
|
33
|
+
|
|
34
|
+
## [0.5.15] — 2026-10-18
|
|
35
|
+
|
|
36
|
+
- 2026-10-18: Version 0.5.15, the tree cut that matches skill 0.5.15.
|
|
37
|
+
|
|
38
|
+
## [0.5.14] — 2026-10-18
|
|
39
|
+
|
|
40
|
+
- 2026-10-18: Version 0.5.14, the tree cut that matches skill 0.5.14; this gem's surface is unchanged.
|
|
41
|
+
|
|
42
|
+
## [0.5.13] — 2026-10-11
|
|
43
|
+
|
|
44
|
+
- 2026-10-11: Version 0.5.13, the tree cut that matches skill 0.5.13; this gem's surface is unchanged.
|
|
45
|
+
|
|
46
|
+
## [0.5.12] — 2026-10-08
|
|
47
|
+
|
|
48
|
+
- 2026-10-08: Version 0.5.12, the tree cut that matches skill 0.5.12; this gem's surface is unchanged.
|
|
49
|
+
|
|
50
|
+
## [0.5.11] — 2026-10-08
|
|
51
|
+
|
|
52
|
+
- 2026-10-08: Version 0.5.11, the tree cut that matches skill 0.5.11; this gem's surface is unchanged.
|
|
53
|
+
|
|
54
|
+
## [0.5.10] — 2026-10-08
|
|
55
|
+
|
|
56
|
+
- 2026-10-08: Version 0.5.10, the tree cut that matches skill 0.5.10; this gem's surface is unchanged.
|
|
57
|
+
|
|
58
|
+
## [0.5.9] — 2026-10-08
|
|
59
|
+
|
|
60
|
+
- 2026-10-08: Version 0.5.9, the tree cut that matches skill 0.5.9; this gem's surface is unchanged.
|
|
61
|
+
|
|
62
|
+
## [0.5.8] — 2026-10-07
|
|
63
|
+
|
|
64
|
+
- 2026-10-07: Version 0.5.8, the tree cut that matches skill 0.5.8; this gem's surface is unchanged.
|
|
65
|
+
|
|
66
|
+
## [0.5.7] — 2026-10-07
|
|
67
|
+
|
|
68
|
+
- 2026-10-07: Version 0.5.7, the tree cut that matches skill 0.5.7; this gem's surface is unchanged.
|
|
69
|
+
|
|
70
|
+
## [0.5.6] — 2026-10-07
|
|
71
|
+
|
|
72
|
+
- 2026-10-07: Version 0.5.6, the tree cut that matches skill 0.5.6; this gem's surface is unchanged.
|
|
73
|
+
|
|
74
|
+
## [0.5.5] — 2026-10-07
|
|
75
|
+
|
|
76
|
+
- 2026-10-07: Version 0.5.5, the tree cut that matches skill 0.5.5; this gem's surface is unchanged.
|
|
77
|
+
|
|
78
|
+
## [0.5.4] — 2026-10-07
|
|
79
|
+
|
|
80
|
+
- 2026-10-07: Version 0.5.4, the tree cut that matches skill 0.5.4; this gem's surface is unchanged.
|
|
81
|
+
|
|
82
|
+
## [0.5.3] — 2026-10-06
|
|
83
|
+
|
|
84
|
+
- 2026-10-06: Version 0.5.3, the tree cut that matches skill 0.5.3; this gem's surface is unchanged.
|
|
85
|
+
|
|
86
|
+
## [0.5.2] — 2026-10-06
|
|
87
|
+
|
|
88
|
+
- 2026-10-06: Version 0.5.2, the tree cut that matches skill 0.5.2; this gem's surface is unchanged.
|
|
89
|
+
|
|
90
|
+
## [0.5.0] — 2026-09-26
|
|
91
|
+
|
|
92
|
+
### Changed
|
|
93
|
+
|
|
94
|
+
- **Three sentences priced the toy solve at «~1 second» with no machine named (K-1698).** The figure is gone; `rake solve_parity` prints its own timing.
|
|
95
|
+
- **The packaged solver drops a scalar SipHash and a parameter nothing called, and stops narrating a version that no longer exists (K-1685, K-1686).**
|
|
96
|
+
- **Two comments stated a salt length the base64 literal beside them refutes (K-1684).** The numbers are removed rather than corrected.
|
|
97
|
+
- **`verify` answers false for seven more malformed-input shapes where it used to raise (K-1683).** Its own comment and the sibling Equihash backend already promised that.
|
|
98
|
+
- The gemspec stops labelling itself with private roadmap phases (T1, T2/T3) that nothing an adopter can open resolves.
|
|
99
|
+
|
|
100
|
+
### Added
|
|
101
|
+
- Clean-room Cuckatoo-Cycle verifier
|
|
102
|
+
- Pure-Ruby BLAKE2b-256 (from public-domain BLAKE2 spec)
|
|
103
|
+
- Pure-Ruby SipHash-2-4 with Cuckatoo non-standard initialization
|
|
104
|
+
- Cuckatoo cycle walk verifier
|
|
105
|
+
- Optional blake2b-256 difficulty target check
|
|
106
|
+
- Validated against Grin's Cuckatoo29 CI known-answer vector (nonce=20)
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# kiosk-pow-cuckoo
|
|
2
|
+
|
|
3
|
+
Cuckatoo-Cycle proof-of-work backend for [Kiosk](https://kiosk.tech).
|
|
4
|
+
|
|
5
|
+
> **Shelved / optional.** The shipped default PoW backend is
|
|
6
|
+
> [`kiosk-pow-equihash`](https://github.com/kiosk-hq/kiosk/tree/main/kiosk-pow-equihash) — one PoW backend, Equihash.
|
|
7
|
+
> Cuckatoo meets the asymmetric-verify bar, but its production parameters need
|
|
8
|
+
> a native solver (this gem ships only a toy solver),
|
|
9
|
+
> so it is not the default. It stays in the repo as an opt-in backend and may
|
|
10
|
+
> return as a first-class extension; no demo, harness or deploy runbook wires it.
|
|
11
|
+
|
|
12
|
+
## What this is
|
|
13
|
+
|
|
14
|
+
An optional (shelved) PoW backend with a large solve:verify asymmetry — solving
|
|
15
|
+
requires finding a cycle in a large random bipartite graph (gigabytes of RAM,
|
|
16
|
+
seconds of CPU), while verifying is a handful of operations: `proofsize` SipHash
|
|
17
|
+
evaluations plus a cycle-walk (no wall-clock verify figure is benchmarked here).
|
|
18
|
+
|
|
19
|
+
**This gem ships the VERIFIER only.** The verifier is production-correct,
|
|
20
|
+
validated against Grin's Cuckatoo29 L=42 known-answer test vector.
|
|
21
|
+
|
|
22
|
+
The included Python solver (`solve_cuckoo.py`) is a **REFERENCE/TOY solver**
|
|
23
|
+
for small edgebits and reduced proofsize only — see Solver section below.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
> **Not on RubyGems yet** — so every `gem` line below carries `github: "kiosk-hq/kiosk"`, which is what makes it copy-pasteable today. Publication status and the canonical install are stated once, in the monorepo README's [Install](https://github.com/kiosk-hq/kiosk#install) section.
|
|
28
|
+
|
|
29
|
+
This backend is shelved and opt-in (see the note at the top): nothing installs
|
|
30
|
+
it for you.
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
gem "kiosk-pow-cuckoo", github: "kiosk-hq/kiosk"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The verifier is pure Ruby. Its one runtime dependency is `kiosk-pow`, the
|
|
37
|
+
pure-Ruby base that holds BLAKE2b-256. It needs no `kiosk-core`, no Rails and no
|
|
38
|
+
native extension. Requiring it defines the backend; registering
|
|
39
|
+
it is a separate, explicit step, because no PoW gem self-registers on require.
|
|
40
|
+
The registry lives in `kiosk-reputation`, which an origin adds to its Gemfile
|
|
41
|
+
the same way:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
require "kiosk/pow/cuckoo"
|
|
45
|
+
|
|
46
|
+
# Kiosk::Pow::Cuckoo::NAME == "cuckatoo"
|
|
47
|
+
Kiosk::Reputation::Backends.register(Kiosk::Pow::Cuckoo::NAME, Kiosk::Pow::Cuckoo)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The reference solver `solve_cuckoo.py` ships inside the package and is the one
|
|
51
|
+
part with a prerequisite outside Ruby: **`python3` with `numpy`**
|
|
52
|
+
(`pip install -r requirements.txt`, which ships beside it). A provider only
|
|
53
|
+
ever verifies, so a provider never needs it — read the Solver section below
|
|
54
|
+
for what that solver can and cannot do before you reach for it.
|
|
55
|
+
|
|
56
|
+
## Algorithm: Cuckatoo Cycle
|
|
57
|
+
|
|
58
|
+
- Graph size: `N = 2^edgebits` edges in a random bipartite graph
|
|
59
|
+
- Edge `i` connects `U(i) = siphash(2i) mod N` to `V(i) = siphash(2i+1) mod N`
|
|
60
|
+
- Proof: `proofsize` strictly-ascending edge indices forming a single cycle
|
|
61
|
+
on node-pairs (`node >> 1`)
|
|
62
|
+
- Keys: `blake2b-256(salt ‖ LE32(header_nonce))` split into four LE-u64 words
|
|
63
|
+
|
|
64
|
+
SipHash uses Cuckatoo's **non-standard initialization** (keys feed directly into
|
|
65
|
+
`v0..v3` without XOR-ing the 0x736f6d65... magic constants from the standard
|
|
66
|
+
SipHash spec).
|
|
67
|
+
|
|
68
|
+
## Implementation
|
|
69
|
+
|
|
70
|
+
- **BLAKE2b-256**: `Kiosk::Pow::Blake2b` from `kiosk-pow`, pure Ruby from the public-domain [BLAKE2 spec](https://www.blake2.net/blake2.pdf).
|
|
71
|
+
- **SipHash-2-4**: pure Ruby from the [public-domain SipHash spec](https://131002.net/siphash/siphash.pdf),
|
|
72
|
+
with Cuckatoo's non-standard init.
|
|
73
|
+
- No native extensions, no GPL code, no Tromp repository code.
|
|
74
|
+
- License: Apache-2.0.
|
|
75
|
+
|
|
76
|
+
## Known-answer validation
|
|
77
|
+
|
|
78
|
+
The verifier is validated against Grin's Cuckatoo29 CI test vector:
|
|
79
|
+
- `edgebits=29`, header = 80 zero bytes keyed with `nonce=20`, `proofsize=42`
|
|
80
|
+
- 42-cycle accepted; five categories of bad inputs rejected
|
|
81
|
+
|
|
82
|
+
Run: `bundle exec rspec` — all green.
|
|
83
|
+
|
|
84
|
+
## API
|
|
85
|
+
|
|
86
|
+
```ruby
|
|
87
|
+
# Challenge params (proofsize defaults to 42; pass proofsize: 12 for the toy demo)
|
|
88
|
+
params = Kiosk::Pow::Cuckoo.params(edgebits: 29, proofsize: 42)
|
|
89
|
+
# => { edgebits: 29, proofsize: 42, target: nil }
|
|
90
|
+
|
|
91
|
+
# Verify a proof (composite nonce: header_nonce + cycle)
|
|
92
|
+
# -- This is the ONE deviation from kiosk-pow-argon2id's scalar nonce: --
|
|
93
|
+
# The wire proof is { header_nonce: <u32>, cycle: [proofsize ints, ascending] }
|
|
94
|
+
# kiosk-reputation passes this composite object unchanged to .verify.
|
|
95
|
+
Kiosk::Pow::Cuckoo.verify(
|
|
96
|
+
salt: raw_salt_bytes,
|
|
97
|
+
params: params,
|
|
98
|
+
nonce: { header_nonce: 20, cycle: [e0, e1, ..., e41] }
|
|
99
|
+
)
|
|
100
|
+
# => true / false
|
|
101
|
+
|
|
102
|
+
# Lower-level: verify cycle with pre-derived keys
|
|
103
|
+
keys = Kiosk::Pow::Blake2b.digest256(header).unpack("Q<4")
|
|
104
|
+
Kiosk::Pow::Cuckoo.verify_cycle(keys: keys, edgebits: 29, cycle: cycle, proofsize: 42)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Wire interface: composite nonce
|
|
108
|
+
|
|
109
|
+
Unlike `kiosk-pow-argon2id` (Argon2id, scalar nonce), Cuckatoo proofs are composite:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"challenge": { "id": "...", "alg": "cuckatoo", "params": {...}, "salt": "...", "exp": ..., "sig": "..." },
|
|
114
|
+
"nonce": { "header_nonce": 1, "cycle": [12, 362, 383, ...] }
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`kiosk-server`'s PoW gate passes the proof's `nonce` object unchanged to
|
|
119
|
+
`kiosk-reputation`'s `Challenge.verify`. `Challenge.verify` passes it unchanged
|
|
120
|
+
to the backend's `.verify(salt:, params:, nonce:)`. So `nonce` is an object,
|
|
121
|
+
not a String.
|
|
122
|
+
|
|
123
|
+
## Solver
|
|
124
|
+
|
|
125
|
+
### Shipped Python solver (`solve_cuckoo.py`) — REFERENCE/TOY ONLY
|
|
126
|
+
|
|
127
|
+
`solve_cuckoo.py` is a **pure-Python + numpy reference solver for small
|
|
128
|
+
edgebits and reduced proofsize only**.
|
|
129
|
+
|
|
130
|
+
| Property | Value |
|
|
131
|
+
|----------|-------|
|
|
132
|
+
| Language | Python 3 + numpy |
|
|
133
|
+
| Status | Reference/toy — NOT production |
|
|
134
|
+
| Purpose | Mechanism demonstration at small sizes |
|
|
135
|
+
| Tested at | edgebits=10, proofsize=12 |
|
|
136
|
+
| Memory guard | Built-in `_enforce_memory_budget`: refuses oversized edgebits |
|
|
137
|
+
| Safety wrapper | `KIOSK_POW_MAX_BYTES=536870912 timeout 30 nice -n 19 python3 solve_cuckoo.py` |
|
|
138
|
+
|
|
139
|
+
**Why edgebits=10 for proofsize=12:**
|
|
140
|
+
A valid Cuckatoo proofsize=12 cycle exists in the bipartite pair-graph only when
|
|
141
|
+
the pair-graph girth ≤ 12. With N/2 = 2^(edgebits-1) pair values per side and
|
|
142
|
+
mean pair-degree 2, the expected girth is approximately log₂(N/2). For
|
|
143
|
+
proofsize=12, this requires edgebits ≤ 12-13. At edgebits=10 (N/2=512) cycles
|
|
144
|
+
exist and the bundled `solve_cuckoo.py` finds them. At edgebits ≥ 14,
|
|
145
|
+
12-cycles essentially vanish.
|
|
146
|
+
|
|
147
|
+
**Cannot solve production Cuckatoo** (L=42, edgebits≥29). Pure Python cannot
|
|
148
|
+
hold the graph: the bundled solver uses ~118 bytes per edge (peak RSS at
|
|
149
|
+
edgebits 22 and 24, one Apple M3 core), so edgebits=29 needs ~59 GiB, and its
|
|
150
|
+
memory guard refuses it. Production requires a native solver (C/C++ like
|
|
151
|
+
Tromp's `lean`/`mean` miner). No native solver's memory is measured here.
|
|
152
|
+
|
|
153
|
+
### Cross-impl parity gate
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
cd kiosk-pow-cuckoo
|
|
157
|
+
bundle exec rake solve_parity
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Runs `solve_cuckoo.py` at the toy demo params (edgebits=10, proofsize=12) under
|
|
161
|
+
the safety wrapper, then calls the Ruby `Kiosk::Pow::Cuckoo.verify` and asserts
|
|
162
|
+
the proof is accepted. This proves solver output is accepted by the validated
|
|
163
|
+
verifier.
|
|
164
|
+
|
|
165
|
+
### Production solver (out of scope for this gem)
|
|
166
|
+
|
|
167
|
+
Production Cuckatoo (edgebits≥29, proofsize=42) requires clients with a native
|
|
168
|
+
solver. Options:
|
|
169
|
+
- **Tromp's C miner** (`lean`/`mean`, `simple`): fast, FAIR-MINING/GPLv2+ license
|
|
170
|
+
- **GPU solvers**: faster still; CUDA-only
|
|
171
|
+
- Provider mandates the algorithm; clients that cannot solve are denied
|
|
172
|
+
|
|
173
|
+
## Difficulty target
|
|
174
|
+
|
|
175
|
+
An optional `target` (Integer, 256-bit) can be added to params to tighten
|
|
176
|
+
difficulty beyond the base cycle requirement:
|
|
177
|
+
|
|
178
|
+
```ruby
|
|
179
|
+
params = Kiosk::Pow::Cuckoo.params(edgebits: 29, target: (2**256 - 1) / 100)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
When set, the verifier additionally checks:
|
|
183
|
+
```
|
|
184
|
+
blake2b-256(sorted_cycle_edges_as_LE_u64) < target
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Toy mechanism demo
|
|
188
|
+
|
|
189
|
+
**TOY MECHANISM DEMO — proofsize 12 at edgebits 10; NOT production difficulty.**
|
|
190
|
+
|
|
191
|
+
No demo app wires Cuckatoo. The solve → verify loop at the
|
|
192
|
+
toy params is exercised by this gem's cross-impl parity gate (see the Solver
|
|
193
|
+
section above):
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
cd kiosk-pow-cuckoo
|
|
197
|
+
bundle exec rake solve_parity
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Runs the Python reference solver, then asserts the Ruby verifier accepts its
|
|
201
|
+
proof.
|
|
202
|
+
|
|
203
|
+
## Caveats
|
|
204
|
+
|
|
205
|
+
- Cuckatoo is NOT ASIC-proof (1 GB-SRAM ASICs exist for edgebits=31+). The
|
|
206
|
+
provider mandates it; clients that cannot solve are denied. This is
|
|
207
|
+
intentional: it raises the cost of abuse.
|
|
208
|
+
- **Equihash** (`kiosk-pow-equihash`) is the shipped default.
|
|
209
|
+
Argon2id (`kiosk-pow-argon2id`) remains as a legacy backend. Use Cuckatoo only when the
|
|
210
|
+
extreme solve:verify asymmetry (GB-RAM solver vs. a few-hash verifier) is
|
|
211
|
+
specifically required.
|
|
212
|
+
- `proofsize < 42` is a deviation from production Cuckatoo (L=42 per Grin/Tromp
|
|
213
|
+
spec). The toy demo (L=12) demonstrates the mechanism only.
|
|
214
|
+
- `edgebits < 29` is suitable only for testing; production Grin uses edgebits 29.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Kiosk
|
|
4
|
+
module Pow
|
|
5
|
+
module Cuckoo
|
|
6
|
+
# SipHash-2-4 as Cuckatoo uses it: the four keys are NOT XORed with the
|
|
7
|
+
# standard magic constants.
|
|
8
|
+
module SipHash
|
|
9
|
+
MASK64 = (1 << 64) - 1
|
|
10
|
+
private_constant :MASK64
|
|
11
|
+
|
|
12
|
+
def self.digest(keys, nonce)
|
|
13
|
+
state = keys.dup
|
|
14
|
+
state[3] ^= nonce
|
|
15
|
+
2.times { round(state) }
|
|
16
|
+
state[0] ^= nonce
|
|
17
|
+
state[2] ^= 0xff
|
|
18
|
+
4.times { round(state) }
|
|
19
|
+
state.reduce(:^)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# One SipRound as two half rounds. Each half updates two independent
|
|
23
|
+
# lane pairs: (a, b) and (c, d).
|
|
24
|
+
def self.round(state)
|
|
25
|
+
half_round(state, [0, 1, 2, 3], 13, 16)
|
|
26
|
+
half_round(state, [2, 1, 0, 3], 17, 21)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.half_round(state, lanes, rotate_b, rotate_d)
|
|
30
|
+
a, b, c, d = lanes
|
|
31
|
+
add_rotate_xor(state, a, b, rotate_b)
|
|
32
|
+
state[a] = rotl64(state[a], 32)
|
|
33
|
+
add_rotate_xor(state, c, d, rotate_d)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Adds lane `src` into lane `dst`, then rotates `src` and XORs `dst` into it.
|
|
37
|
+
def self.add_rotate_xor(state, dst, src, bits)
|
|
38
|
+
state[dst] = (state[dst] + state[src]) & MASK64
|
|
39
|
+
state[src] = rotl64(state[src], bits) ^ state[dst]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.rotl64(word, bits) = ((word << bits) | (word >> (64 - bits))) & MASK64
|
|
43
|
+
|
|
44
|
+
private_class_method :round, :half_round, :add_rotate_xor, :rotl64
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'kiosk/pow'
|
|
4
|
+
require 'kiosk/pow/cuckoo/version'
|
|
5
|
+
require 'kiosk/pow/cuckoo/sip_hash'
|
|
6
|
+
|
|
7
|
+
module Kiosk
|
|
8
|
+
module Pow
|
|
9
|
+
# Cuckatoo Cycle proof-of-work verifier, clean-room from Tromp's spec.
|
|
10
|
+
# The proof `nonce` is { header_nonce: <u32>, cycle: [42 ascending edge indices] };
|
|
11
|
+
# the solver is `solve_cuckoo.py`, packaged beside this file.
|
|
12
|
+
module Cuckoo
|
|
13
|
+
NAME = 'cuckatoo'
|
|
14
|
+
|
|
15
|
+
def self.siphash(key0, key1, key2, key3, nonce)
|
|
16
|
+
SipHash.digest([key0, key1, key2, key3], nonce)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.verify_cycle(keys:, edgebits:, cycle:, proofsize: 42) # rubocop:disable Naming/PredicateMethod -- public verifier step, named like the PoW backend interface method verify.
|
|
20
|
+
return false unless cycle.length == proofsize
|
|
21
|
+
|
|
22
|
+
uvs = endpoints(keys, edgebits, cycle)
|
|
23
|
+
!uvs.nil? && closed_walk_length(uvs) == proofsize
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# `target` is a 256-bit Integer the sorted cycle's BLAKE2b-256 must stay below; nil accepts any cycle.
|
|
27
|
+
def self.params(edgebits:, proofsize: 42, target: nil)
|
|
28
|
+
{ edgebits:, proofsize:, target: }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.verify(salt:, params:, nonce:)
|
|
32
|
+
proof = coerce_proof(nonce)
|
|
33
|
+
edgebits, proofsize, target = coerce_params(params)
|
|
34
|
+
return false if proof.nil? || edgebits.nil?
|
|
35
|
+
|
|
36
|
+
header_nonce, cycle = proof
|
|
37
|
+
keys = Blake2b.digest256(salt.b + [header_nonce].pack('V')).unpack('Q<4')
|
|
38
|
+
verify_cycle(keys:, edgebits:, cycle:, proofsize:) && below_target?(cycle, target)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The two node endpoints of each edge, in cycle order. Nil when an edge is
|
|
42
|
+
# not an Integer, is out of range, or breaks the ascending order.
|
|
43
|
+
def self.endpoints(keys, edgebits, cycle)
|
|
44
|
+
n_nodes = 1 << edgebits
|
|
45
|
+
return nil unless ascending_edges?(cycle, n_nodes)
|
|
46
|
+
|
|
47
|
+
mask = n_nodes - 1
|
|
48
|
+
cycle.flat_map { |edge| [siphash(*keys, 2 * edge) & mask, siphash(*keys, (2 * edge) + 1) & mask] }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.ascending_edges?(cycle, limit)
|
|
52
|
+
cycle.each_with_index.all? do |edge, index|
|
|
53
|
+
edge.is_a?(Integer) && edge < limit && (index.zero? || edge > cycle[index - 1])
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Walks the cycle from endpoint 0: go to the one other same-parity
|
|
58
|
+
# endpoint on the same node (>> 1), cross that edge (j ^ 1), and count the
|
|
59
|
+
# steps back to 0. Nil when an endpoint has no partner or more than one.
|
|
60
|
+
def self.closed_walk_length(uvs)
|
|
61
|
+
i = 0
|
|
62
|
+
steps = 0
|
|
63
|
+
loop do
|
|
64
|
+
j = partner(uvs, i)
|
|
65
|
+
return nil if j.nil? || uvs[j] == uvs[i]
|
|
66
|
+
|
|
67
|
+
i = j ^ 1
|
|
68
|
+
steps += 1
|
|
69
|
+
return steps if i.zero?
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.partner(uvs, from)
|
|
74
|
+
node = uvs[from] >> 1
|
|
75
|
+
matches = (1...(uvs.size / 2)).map { |step| (from + (2 * step)) % uvs.size }
|
|
76
|
+
.select { |k| (uvs[k] >> 1) == node }
|
|
77
|
+
matches.one? ? matches.first : nil
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# [header_nonce, cycle] from a proof Hash; nil when it is unreadable.
|
|
81
|
+
def self.coerce_proof(nonce)
|
|
82
|
+
return nil unless nonce.is_a?(Hash)
|
|
83
|
+
|
|
84
|
+
header_nonce = Pow.param(nonce, :header_nonce)
|
|
85
|
+
cycle = Pow.param(nonce, :cycle)
|
|
86
|
+
return nil if header_nonce.nil? || !cycle.is_a?(Array)
|
|
87
|
+
|
|
88
|
+
[Integer(header_nonce), cycle]
|
|
89
|
+
rescue ArgumentError, TypeError
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# All-nil when unreadable, so {.verify} answers false instead of raising.
|
|
94
|
+
def self.coerce_params(params)
|
|
95
|
+
return [nil, nil, nil] unless params.is_a?(Hash)
|
|
96
|
+
|
|
97
|
+
target = Pow.param(params, :target)
|
|
98
|
+
[Integer(Pow.param(params, :edgebits)), Integer(Pow.param(params, :proofsize) || 42), target && Integer(target)]
|
|
99
|
+
rescue ArgumentError, TypeError
|
|
100
|
+
[nil, nil, nil]
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# The sorted cycle's BLAKE2b-256, read as a big-endian integer, must be
|
|
104
|
+
# below `target`. A nil target accepts any cycle.
|
|
105
|
+
def self.below_target?(cycle, target)
|
|
106
|
+
target.nil? || Blake2b.digest256(cycle.sort.pack('Q<*')).unpack1('H*').to_i(16) < target
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
private_class_method :endpoints, :ascending_edges?, :closed_walk_length, :partner,
|
|
110
|
+
:coerce_proof, :coerce_params, :below_target?
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
data/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
numpy
|
data/solve_cuckoo.py
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Clean-room Cuckatoo-Cycle proof-of-work solver.
|
|
4
|
+
CPU-only, pure Python + numpy (no GPU, no CUDA, no C/C++ toolchain required).
|
|
5
|
+
Runs in an assistant sandbox (Mac mini / DigitalOcean VDS / AWS EC2).
|
|
6
|
+
|
|
7
|
+
Dependencies: numpy (pip install numpy)
|
|
8
|
+
|
|
9
|
+
Algorithm: Cuckatoo variant of Cuckoo Cycle by John Tromp.
|
|
10
|
+
Clean-room implementation from the public algorithm spec — no GPL/FAIR-MINING
|
|
11
|
+
source code copied or adapted.
|
|
12
|
+
|
|
13
|
+
SipHash-2-4 non-standard init (Cuckatoo variant):
|
|
14
|
+
v0=k0, v1=k1, v2=k2, v3=k3^nonce
|
|
15
|
+
SIPROUND×2; v0^=nonce; v2^=0xff; SIPROUND×4
|
|
16
|
+
return (v0^v1)^(v2^v3)
|
|
17
|
+
|
|
18
|
+
Keys: blake2b-256(header) → 4 LE-u64 words.
|
|
19
|
+
Header: salt_bytes ‖ struct.pack("<I", header_nonce)
|
|
20
|
+
|
|
21
|
+
Edge endpoints (N = 1<<edgebits, mask = N-1):
|
|
22
|
+
U(i) = siphash(2*i) & mask
|
|
23
|
+
V(i) = siphash(2*i+1) & mask
|
|
24
|
+
|
|
25
|
+
A valid proof is 42 strictly-ascending edge indices forming a single 42-cycle
|
|
26
|
+
on node-pairs (node>>1), accepted by Kiosk::Pow::Cuckoo.verify.
|
|
27
|
+
|
|
28
|
+
Key implementation note:
|
|
29
|
+
Cuckatoo trimming operates on NODE-PAIRS (node >> 1), NOT raw node values.
|
|
30
|
+
Each of the N=2^edgebits edges has U[e]∈[0,N-1]; U-pair = U[e]>>1 ∈ [0,N/2-1].
|
|
31
|
+
Mean pair degree = N / (N/2) = 2, which keeps ~20% of edges after trimming.
|
|
32
|
+
Using raw-node trimming instead (mean degree 1) incorrectly destroys all cycles.
|
|
33
|
+
|
|
34
|
+
Usage:
|
|
35
|
+
python3 solve_cuckoo.py '<challenge json>'
|
|
36
|
+
python3 solve_cuckoo.py # reads from stdin
|
|
37
|
+
|
|
38
|
+
Challenge JSON:
|
|
39
|
+
{"salt": "<base64>", "params": {"edgebits": <int>, "proofsize": 42, "target": null}}
|
|
40
|
+
|
|
41
|
+
Output (one JSON line):
|
|
42
|
+
{"header_nonce": <int>, "cycle": [42 ints ascending]}
|
|
43
|
+
|
|
44
|
+
Honest performance note (edgebits and proofsize are coupled):
|
|
45
|
+
A proofsize=L cycle only exists once the pair-graph girth ≤ L, and the
|
|
46
|
+
expected girth is ~log2(N/2) = edgebits-1. So the solvable pairing is a
|
|
47
|
+
proofsize matched to the graph size, NOT edgebits varied under the
|
|
48
|
+
default proofsize=42:
|
|
49
|
+
edgebits=10, proofsize=12 → ~1 s on a modern CPU (demo-safe; the
|
|
50
|
+
tested / parity-gate combo)
|
|
51
|
+
edgebits=12, proofsize=12 → ~seconds (12-cycles thin out by edgebits 14)
|
|
52
|
+
The default proofsize=42 needs girth ~42 (edgebits ~43): at production
|
|
53
|
+
edgebits (29+) with proofsize=42 the graph is far too large for pure
|
|
54
|
+
numpy, and at small edgebits a 42-cycle essentially never exists. Either
|
|
55
|
+
way, proofsize=42 is infeasible here and requires a native C miner.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
import base64
|
|
59
|
+
import hashlib
|
|
60
|
+
import json
|
|
61
|
+
import os
|
|
62
|
+
import struct
|
|
63
|
+
import sys
|
|
64
|
+
from collections import defaultdict
|
|
65
|
+
|
|
66
|
+
# Keep numpy single-threaded — this solver is elementwise uint64, not BLAS, and
|
|
67
|
+
# uncapped threads were part of the runaway that pinned all cores. Set BEFORE numpy.
|
|
68
|
+
for _v in ("OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS", "MKL_NUM_THREADS",
|
|
69
|
+
"VECLIB_MAXIMUM_THREADS", "NUMEXPR_NUM_THREADS"):
|
|
70
|
+
os.environ.setdefault(_v, "1")
|
|
71
|
+
|
|
72
|
+
import numpy as np
|
|
73
|
+
|
|
74
|
+
# ---------------------------------------------------------------------------
|
|
75
|
+
# HARD memory guard (safety-critical).
|
|
76
|
+
#
|
|
77
|
+
# The measured peak (ru_maxrss, build and trim) is 104, 119 and 118 bytes per
|
|
78
|
+
# edge at edgebits 20, 22 and 24. An uncapped run at high edgebits can exhaust
|
|
79
|
+
# memory and swap. macOS ignores `ulimit -v`, so the solver limits itself: it
|
|
80
|
+
# predicts the peak from edgebits and REFUSES before it allocates.
|
|
81
|
+
#
|
|
82
|
+
# Cap is configurable via KIOSK_POW_MAX_BYTES (default 1.5 GiB). This makes the
|
|
83
|
+
# solver safe to invoke at ANY edgebits regardless of how it's called.
|
|
84
|
+
# ---------------------------------------------------------------------------
|
|
85
|
+
_BYTES_PER_EDGE_PEAK = 120 # measured numpy peak, rounded up
|
|
86
|
+
_DEFAULT_MAX_BYTES = 1536 * 1024 * 1024 # 1.5 GiB
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _max_bytes() -> int:
|
|
90
|
+
raw = os.environ.get("KIOSK_POW_MAX_BYTES")
|
|
91
|
+
return int(raw) if raw else _DEFAULT_MAX_BYTES
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _predicted_peak_bytes(edgebits: int) -> int:
|
|
95
|
+
return _BYTES_PER_EDGE_PEAK * (1 << edgebits)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _enforce_memory_budget(edgebits: int) -> None:
|
|
99
|
+
predicted = _predicted_peak_bytes(edgebits)
|
|
100
|
+
cap = _max_bytes()
|
|
101
|
+
if predicted > cap:
|
|
102
|
+
msg = (
|
|
103
|
+
f"refusing edgebits={edgebits}: predicted peak "
|
|
104
|
+
f"~{predicted / 1024 / 1024:.0f} MiB exceeds cap "
|
|
105
|
+
f"{cap / 1024 / 1024:.0f} MiB (set KIOSK_POW_MAX_BYTES to override). "
|
|
106
|
+
f"This pure-numpy reference solver is for small/demo edgebits only; "
|
|
107
|
+
f"production sizes (29+) need a native solver."
|
|
108
|
+
)
|
|
109
|
+
print(json.dumps({"error": "edgebits_too_large", "message": msg}))
|
|
110
|
+
sys.exit(2)
|
|
111
|
+
# Best-effort OS guard on top (often a no-op on macOS, real on Linux).
|
|
112
|
+
try:
|
|
113
|
+
import resource
|
|
114
|
+
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
|
|
115
|
+
want = cap + 256 * 1024 * 1024 # cap + headroom
|
|
116
|
+
new_hard = want if hard == resource.RLIM_INFINITY else min(hard, want)
|
|
117
|
+
resource.setrlimit(resource.RLIMIT_AS, (want, new_hard))
|
|
118
|
+
except (ImportError, ValueError, OSError):
|
|
119
|
+
pass
|
|
120
|
+
|
|
121
|
+
# ---------------------------------------------------------------------------
|
|
122
|
+
# Constants (numpy uint64)
|
|
123
|
+
# ---------------------------------------------------------------------------
|
|
124
|
+
ROT13 = np.uint64(13)
|
|
125
|
+
ROT16 = np.uint64(16)
|
|
126
|
+
ROT17 = np.uint64(17)
|
|
127
|
+
ROT21 = np.uint64(21)
|
|
128
|
+
ROT32 = np.uint64(32)
|
|
129
|
+
XFF = np.uint64(0xFF)
|
|
130
|
+
ONE = np.uint64(1)
|
|
131
|
+
|
|
132
|
+
# ---------------------------------------------------------------------------
|
|
133
|
+
# Vectorized SipHash-2-4 (Cuckatoo non-standard init) via numpy.
|
|
134
|
+
# Speed-critical: computes all N edge endpoints in parallel.
|
|
135
|
+
# ---------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
def _rotl64_vec(x, n):
|
|
138
|
+
return (x << n) | (x >> (np.uint64(64) - n))
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _sipround_vec(v0, v1, v2, v3):
|
|
142
|
+
v0 = v0 + v1
|
|
143
|
+
v1 = _rotl64_vec(v1, ROT13) ^ v0
|
|
144
|
+
v0 = _rotl64_vec(v0, ROT32)
|
|
145
|
+
v2 = v2 + v3
|
|
146
|
+
v3 = _rotl64_vec(v3, ROT16) ^ v2
|
|
147
|
+
v0 = v0 + v3
|
|
148
|
+
v3 = _rotl64_vec(v3, ROT21) ^ v0
|
|
149
|
+
v2 = v2 + v1
|
|
150
|
+
v1 = _rotl64_vec(v1, ROT17) ^ v2
|
|
151
|
+
v2 = _rotl64_vec(v2, ROT32)
|
|
152
|
+
return v0, v1, v2, v3
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def siphash_vec(k0: int, k1: int, k2: int, k3: int, nonces: np.ndarray) -> np.ndarray:
|
|
156
|
+
"""
|
|
157
|
+
Vectorized Cuckatoo SipHash-2-4.
|
|
158
|
+
nonces: 1-D numpy array of dtype uint64.
|
|
159
|
+
Returns: uint64 array of same length.
|
|
160
|
+
"""
|
|
161
|
+
K0 = np.uint64(k0)
|
|
162
|
+
K1 = np.uint64(k1)
|
|
163
|
+
K2 = np.uint64(k2)
|
|
164
|
+
K3 = np.uint64(k3)
|
|
165
|
+
|
|
166
|
+
v0 = np.full(len(nonces), K0, dtype=np.uint64)
|
|
167
|
+
v1 = np.full(len(nonces), K1, dtype=np.uint64)
|
|
168
|
+
v2 = np.full(len(nonces), K2, dtype=np.uint64)
|
|
169
|
+
v3 = np.full(len(nonces), K3, dtype=np.uint64) ^ nonces
|
|
170
|
+
|
|
171
|
+
v0, v1, v2, v3 = _sipround_vec(v0, v1, v2, v3)
|
|
172
|
+
v0, v1, v2, v3 = _sipround_vec(v0, v1, v2, v3)
|
|
173
|
+
|
|
174
|
+
v0 ^= nonces
|
|
175
|
+
v2 ^= XFF
|
|
176
|
+
|
|
177
|
+
for _ in range(4):
|
|
178
|
+
v0, v1, v2, v3 = _sipround_vec(v0, v1, v2, v3)
|
|
179
|
+
|
|
180
|
+
return (v0 ^ v1) ^ (v2 ^ v3)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# ---------------------------------------------------------------------------
|
|
184
|
+
# Key derivation
|
|
185
|
+
# ---------------------------------------------------------------------------
|
|
186
|
+
|
|
187
|
+
def derive_keys(header: bytes):
|
|
188
|
+
digest = hashlib.blake2b(header, digest_size=32).digest()
|
|
189
|
+
k0, k1, k2, k3 = struct.unpack_from("<QQQQ", digest)
|
|
190
|
+
return k0, k1, k2, k3
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
# ---------------------------------------------------------------------------
|
|
194
|
+
# Build all edge endpoints (vectorized, the speed-critical step).
|
|
195
|
+
# Returns U[N] and V[N] as uint64 arrays (values masked to edgebits).
|
|
196
|
+
# ---------------------------------------------------------------------------
|
|
197
|
+
|
|
198
|
+
def build_endpoints(k0, k1, k2, k3, edgebits: int):
|
|
199
|
+
N = 1 << edgebits
|
|
200
|
+
mask = np.uint64(N - 1)
|
|
201
|
+
i = np.arange(N, dtype=np.uint64)
|
|
202
|
+
U = siphash_vec(k0, k1, k2, k3, np.uint64(2) * i) & mask
|
|
203
|
+
V = siphash_vec(k0, k1, k2, k3, np.uint64(2) * i + np.uint64(1)) & mask
|
|
204
|
+
return U, V
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
# ---------------------------------------------------------------------------
|
|
208
|
+
# Edge trimming via numpy bincount — Cuckatoo-correct version.
|
|
209
|
+
#
|
|
210
|
+
# CRITICAL: degree is counted on NODE-PAIRS (node >> 1), not raw node values.
|
|
211
|
+
#
|
|
212
|
+
# Why: a valid Cuckatoo 42-cycle has 42 UNIQUE U-endpoints (raw degree 1 each)
|
|
213
|
+
# but 21 UNIQUE U-PAIRS (pair degree 2 each). Raw-degree trimming destroys
|
|
214
|
+
# all valid cycles at the first round; pair-degree trimming preserves them.
|
|
215
|
+
# Mean pair degree = N / (N/2) = 2, so ~20% of edges survive after trimming.
|
|
216
|
+
# ---------------------------------------------------------------------------
|
|
217
|
+
|
|
218
|
+
def trim_edges(U: np.ndarray, V: np.ndarray, edgebits: int, rounds: int = 20) -> np.ndarray:
|
|
219
|
+
N = 1 << edgebits
|
|
220
|
+
NPAIRS = N >> 1 # number of node-pair values per side
|
|
221
|
+
alive = np.ones(len(U), dtype=bool)
|
|
222
|
+
|
|
223
|
+
# Pre-compute pair arrays (they don't change, only alive changes).
|
|
224
|
+
UP = (U >> ONE).astype(np.intp) # U-pair indices
|
|
225
|
+
VP = (V >> ONE).astype(np.intp) # V-pair indices
|
|
226
|
+
|
|
227
|
+
for _ in range(rounds):
|
|
228
|
+
prev_count = alive.sum()
|
|
229
|
+
|
|
230
|
+
deg_up = np.bincount(UP[alive], minlength=NPAIRS)
|
|
231
|
+
alive &= deg_up[UP] >= 2
|
|
232
|
+
|
|
233
|
+
deg_vp = np.bincount(VP[alive], minlength=NPAIRS)
|
|
234
|
+
alive &= deg_vp[VP] >= 2
|
|
235
|
+
|
|
236
|
+
if alive.sum() == prev_count:
|
|
237
|
+
break
|
|
238
|
+
|
|
239
|
+
return alive
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
# ---------------------------------------------------------------------------
|
|
243
|
+
# Cuckatoo cycle verifier — Python mirror of the Ruby verifier (cuckoo.rb).
|
|
244
|
+
#
|
|
245
|
+
# Agreement here ↔ Ruby verify() returns true.
|
|
246
|
+
# Takes sorted cycle_edges (list of edge indices, length proofsize).
|
|
247
|
+
# ---------------------------------------------------------------------------
|
|
248
|
+
|
|
249
|
+
def verify_cuckatoo_cycle(U_arr, V_arr, cycle_edges) -> bool:
|
|
250
|
+
"""Returns True iff cycle_edges is a valid Cuckatoo proofsize-cycle.
|
|
251
|
+
|
|
252
|
+
Works for any proofsize (not just 42). The cycle-walk algorithm is
|
|
253
|
+
identical regardless of length; only `ps` changes.
|
|
254
|
+
"""
|
|
255
|
+
ps = len(cycle_edges)
|
|
256
|
+
if ps < 2:
|
|
257
|
+
return False # degenerate: need at least 2 edges for a cycle
|
|
258
|
+
|
|
259
|
+
uvs = []
|
|
260
|
+
for ei in cycle_edges:
|
|
261
|
+
uvs.append(int(U_arr[ei]))
|
|
262
|
+
uvs.append(int(V_arr[ei]))
|
|
263
|
+
|
|
264
|
+
uvs_size = 2 * ps
|
|
265
|
+
i = 0
|
|
266
|
+
n = 0
|
|
267
|
+
|
|
268
|
+
while True:
|
|
269
|
+
j = i
|
|
270
|
+
k = i
|
|
271
|
+
branch = False
|
|
272
|
+
|
|
273
|
+
while True:
|
|
274
|
+
k = (k + 2) % uvs_size
|
|
275
|
+
if k == i:
|
|
276
|
+
break
|
|
277
|
+
if (uvs[k] >> 1) == (uvs[i] >> 1):
|
|
278
|
+
if j != i:
|
|
279
|
+
branch = True
|
|
280
|
+
break
|
|
281
|
+
j = k
|
|
282
|
+
|
|
283
|
+
if branch:
|
|
284
|
+
return False
|
|
285
|
+
if j == i:
|
|
286
|
+
return False
|
|
287
|
+
if uvs[j] == uvs[i]:
|
|
288
|
+
return False
|
|
289
|
+
|
|
290
|
+
i = j ^ 1
|
|
291
|
+
n += 1
|
|
292
|
+
if i == 0:
|
|
293
|
+
break
|
|
294
|
+
if n > ps:
|
|
295
|
+
return False
|
|
296
|
+
|
|
297
|
+
return n == ps
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
# ---------------------------------------------------------------------------
|
|
301
|
+
# Cycle finder using recursive DFS on the quotient (node-pair) graph.
|
|
302
|
+
#
|
|
303
|
+
# After pair-degree trimming, surviving nodes have pair-degree ≥ 2.
|
|
304
|
+
# We run a recursive DFS that correctly backtracks (path_depth is cleaned up
|
|
305
|
+
# on every unwind), so back-edge depths are exact. When a back-edge closes
|
|
306
|
+
# a cycle of EXACTLY proofsize edges we validate it with verify_cuckatoo_cycle
|
|
307
|
+
# and return immediately.
|
|
308
|
+
#
|
|
309
|
+
# Depth is bounded at proofsize so recursion never exceeds proofsize frames
|
|
310
|
+
# (≤ 42 for production, ≤ 12 for the toy demo) — safe against Python's
|
|
311
|
+
# recursion limit. We restart DFS from each node so every component is
|
|
312
|
+
# searched even when part of it was visited on a non-cycle path earlier.
|
|
313
|
+
#
|
|
314
|
+
# Each node leaves path_depth exactly on unwind, so the depth recorded for a
|
|
315
|
+
# node is always its depth on the CURRENT path — a stale depth left behind by
|
|
316
|
+
# an abandoned branch would corrupt every cycle length computed after it.
|
|
317
|
+
# ---------------------------------------------------------------------------
|
|
318
|
+
|
|
319
|
+
def find_cycle(U: np.ndarray, V: np.ndarray, alive_mask: np.ndarray, proofsize: int = 42):
|
|
320
|
+
edge_idx = np.where(alive_mask)[0]
|
|
321
|
+
if len(edge_idx) < proofsize:
|
|
322
|
+
return None
|
|
323
|
+
|
|
324
|
+
# Build adjacency on node-pairs.
|
|
325
|
+
# Node key: (side, pair_value), side ∈ {0=U, 1=V}.
|
|
326
|
+
adj: dict = defaultdict(list)
|
|
327
|
+
for ei in edge_idx:
|
|
328
|
+
up = (0, int(U[ei]) >> 1)
|
|
329
|
+
vp = (1, int(V[ei]) >> 1)
|
|
330
|
+
adj[up].append((vp, int(ei)))
|
|
331
|
+
adj[vp].append((up, int(ei)))
|
|
332
|
+
|
|
333
|
+
for start_node in list(adj.keys()):
|
|
334
|
+
# Fresh path state per start (ensures clean backtracking across starts).
|
|
335
|
+
path_depth: dict = {} # node -> depth on the CURRENT path only
|
|
336
|
+
path_edges: list = [] # edges on the current path (len == current depth)
|
|
337
|
+
|
|
338
|
+
# Recursive DFS. parent_ei is the edge index we arrived on (−1 at root)
|
|
339
|
+
# so we don't immediately traverse back on the same edge.
|
|
340
|
+
#
|
|
341
|
+
# Invariant entering dfs(node, depth, parent_ei):
|
|
342
|
+
# path_edges has exactly `depth` elements.
|
|
343
|
+
# path_depth holds exactly the nodes on the path from start to
|
|
344
|
+
# the CALLER of this function (not including `node` yet).
|
|
345
|
+
def dfs(node, depth, parent_ei):
|
|
346
|
+
# --- Back-edge check (done before the depth limit so we always
|
|
347
|
+
# detect cycles even at the maximum allowed depth) ---
|
|
348
|
+
if node in path_depth:
|
|
349
|
+
anc_depth = path_depth[node]
|
|
350
|
+
cycle_len = depth - anc_depth # #edges = depth - anc_depth
|
|
351
|
+
# path_edges[anc_depth:] is the back-edge included (it was
|
|
352
|
+
# appended by our caller before this call).
|
|
353
|
+
if cycle_len == proofsize:
|
|
354
|
+
cycle = path_edges[anc_depth:] # already has proofsize elements
|
|
355
|
+
sc = sorted(cycle)
|
|
356
|
+
if verify_cuckatoo_cycle(U, V, sc):
|
|
357
|
+
return sc
|
|
358
|
+
return None
|
|
359
|
+
|
|
360
|
+
# --- Depth limit: don't add nodes beyond proofsize levels ---
|
|
361
|
+
if depth >= proofsize:
|
|
362
|
+
return None
|
|
363
|
+
|
|
364
|
+
# --- Enter this node ---
|
|
365
|
+
path_depth[node] = depth
|
|
366
|
+
|
|
367
|
+
for nbr, ei in adj[node]:
|
|
368
|
+
if ei == parent_ei:
|
|
369
|
+
continue # skip the edge we arrived on
|
|
370
|
+
path_edges.append(ei) # include edge before recursing
|
|
371
|
+
result = dfs(nbr, depth + 1, ei)
|
|
372
|
+
path_edges.pop() # restore on unwind
|
|
373
|
+
if result is not None:
|
|
374
|
+
del path_depth[node]
|
|
375
|
+
return result
|
|
376
|
+
|
|
377
|
+
# --- Leave this node (backtrack) ---
|
|
378
|
+
del path_depth[node]
|
|
379
|
+
return None
|
|
380
|
+
|
|
381
|
+
result = dfs(start_node, 0, -1)
|
|
382
|
+
if result is not None:
|
|
383
|
+
return result
|
|
384
|
+
|
|
385
|
+
return None
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
# ---------------------------------------------------------------------------
|
|
389
|
+
# Main solve loop
|
|
390
|
+
# ---------------------------------------------------------------------------
|
|
391
|
+
|
|
392
|
+
def solve(challenge: dict) -> dict:
|
|
393
|
+
salt = base64.b64decode(challenge["salt"])
|
|
394
|
+
params = challenge["params"]
|
|
395
|
+
edgebits = int(params["edgebits"])
|
|
396
|
+
proofsize = int(params.get("proofsize", 42))
|
|
397
|
+
target = params.get("target")
|
|
398
|
+
|
|
399
|
+
_enforce_memory_budget(edgebits) # refuse oversized edgebits before allocating
|
|
400
|
+
|
|
401
|
+
header_nonce = 0
|
|
402
|
+
while True:
|
|
403
|
+
header = salt + struct.pack("<I", header_nonce)
|
|
404
|
+
k0, k1, k2, k3 = derive_keys(header)
|
|
405
|
+
|
|
406
|
+
U, V = build_endpoints(k0, k1, k2, k3, edgebits)
|
|
407
|
+
alive = trim_edges(U, V, edgebits)
|
|
408
|
+
cycle = find_cycle(U, V, alive, proofsize)
|
|
409
|
+
|
|
410
|
+
if cycle is not None:
|
|
411
|
+
if target is not None:
|
|
412
|
+
cycle_packed = struct.pack(f"<{len(cycle)}Q", *sorted(cycle))
|
|
413
|
+
cycle_hash = hashlib.blake2b(cycle_packed, digest_size=32).digest()
|
|
414
|
+
hash_int = int.from_bytes(cycle_hash, "big")
|
|
415
|
+
target_int = int(target) if isinstance(target, int) else int.from_bytes(target, "big")
|
|
416
|
+
if hash_int >= target_int:
|
|
417
|
+
header_nonce += 1
|
|
418
|
+
continue
|
|
419
|
+
return {"header_nonce": header_nonce, "cycle": cycle}
|
|
420
|
+
|
|
421
|
+
header_nonce += 1
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def main():
|
|
425
|
+
if len(sys.argv) > 1:
|
|
426
|
+
challenge = json.loads(sys.argv[1])
|
|
427
|
+
else:
|
|
428
|
+
challenge = json.load(sys.stdin)
|
|
429
|
+
|
|
430
|
+
result = solve(challenge)
|
|
431
|
+
print(json.dumps(result))
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
if __name__ == "__main__":
|
|
435
|
+
main()
|
metadata
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: kiosk-pow-cuckoo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.5.20
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Phil Pirozhkov
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: kiosk-pow
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.5.0
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.5.0
|
|
26
|
+
description: |
|
|
27
|
+
kiosk-pow-cuckoo is an optional Cuckatoo-Cycle (Cuckoo Cycle variant)
|
|
28
|
+
proof-of-work backend for the Kiosk framework.
|
|
29
|
+
|
|
30
|
+
Ships the provider-side Ruby VERIFIER only. The verifier is cheap
|
|
31
|
+
(a handful of hash evaluations; no wall-clock figure is benchmarked),
|
|
32
|
+
security-critical, and validated against Grin's Cuckatoo29 CI test
|
|
33
|
+
vector. A reference Python solver (solve_cuckoo.py) ships alongside for
|
|
34
|
+
parity testing; production solving is the client's concern.
|
|
35
|
+
|
|
36
|
+
The implementation is clean-room from Tromp's public-domain algorithm
|
|
37
|
+
spec (doc/spec, doc/mathspec) — no GPL/FAIR-MINING code is included.
|
|
38
|
+
BLAKE2b-256 comes from kiosk-pow, the base of every Kiosk PoW backend.
|
|
39
|
+
SipHash-2-4 is pure Ruby from the public-domain SipHash spec with
|
|
40
|
+
Cuckatoo's non-standard initialization (keys feed directly into v0..v3
|
|
41
|
+
without XOR-ing the 0x736f6d65... magic constants).
|
|
42
|
+
|
|
43
|
+
Does not depend on kiosk-core or Rails — pure Ruby, no native extensions.
|
|
44
|
+
email:
|
|
45
|
+
- hello@fili.pp.ru
|
|
46
|
+
executables: []
|
|
47
|
+
extensions: []
|
|
48
|
+
extra_rdoc_files: []
|
|
49
|
+
files:
|
|
50
|
+
- CHANGELOG.md
|
|
51
|
+
- LICENSE.txt
|
|
52
|
+
- README.md
|
|
53
|
+
- lib/kiosk/pow/cuckoo.rb
|
|
54
|
+
- lib/kiosk/pow/cuckoo/sip_hash.rb
|
|
55
|
+
- lib/kiosk/pow/cuckoo/version.rb
|
|
56
|
+
- requirements.txt
|
|
57
|
+
- solve_cuckoo.py
|
|
58
|
+
homepage: https://kiosk.tech
|
|
59
|
+
licenses:
|
|
60
|
+
- Apache-2.0
|
|
61
|
+
metadata:
|
|
62
|
+
homepage_uri: https://kiosk.tech
|
|
63
|
+
source_code_uri: https://github.com/kiosk-hq/kiosk
|
|
64
|
+
changelog_uri: https://github.com/kiosk-hq/kiosk/blob/main/kiosk-pow-cuckoo/CHANGELOG.md
|
|
65
|
+
bug_tracker_uri: https://github.com/kiosk-hq/kiosk/issues
|
|
66
|
+
rubygems_mfa_required: 'true'
|
|
67
|
+
rdoc_options: []
|
|
68
|
+
require_paths:
|
|
69
|
+
- lib
|
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '4.0'
|
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '0'
|
|
80
|
+
requirements: []
|
|
81
|
+
rubygems_version: 4.0.3
|
|
82
|
+
specification_version: 4
|
|
83
|
+
summary: Cuckatoo-Cycle proof-of-work backend for Kiosk
|
|
84
|
+
test_files: []
|