chiklisp-puzzles 0.1.0__tar.gz
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.
- chiklisp_puzzles-0.1.0/LICENSE +13 -0
- chiklisp_puzzles-0.1.0/PKG-INFO +42 -0
- chiklisp_puzzles-0.1.0/README.md +20 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles/__init__.py +7 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles/puzzles/calculate_synthetic_public_key.clsp +5 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles/puzzles/p2_conditions.clsp +3 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp +91 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles/puzzles/runtime_build +19 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles.egg-info/PKG-INFO +42 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles.egg-info/SOURCES.txt +15 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles.egg-info/dependency_links.txt +1 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles.egg-info/requires.txt +1 -0
- chiklisp_puzzles-0.1.0/chiklisp_puzzles.egg-info/top_level.txt +1 -0
- chiklisp_puzzles-0.1.0/pyproject.toml +18 -0
- chiklisp_puzzles-0.1.0/setup.cfg +4 -0
- chiklisp_puzzles-0.1.0/setup.py +11 -0
- chiklisp_puzzles-0.1.0/tests/test_load.py +21 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 by Richard Kiss
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: chiklisp_puzzles
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Some canonical puzzles deployed on chik-blockchain
|
|
5
|
+
Author-email: Richard Kiss <him@richardkiss.com>
|
|
6
|
+
License: Copyright 2023 by Richard Kiss
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
|
|
23
|
+
# chiklisp_puzzles
|
|
24
|
+
|
|
25
|
+
This project contains several standard and legacy puzzles commonly used on the chik network.
|
|
26
|
+
|
|
27
|
+
Note that it uses `enscons` to build, as the more commonly used `setuptools` does not easily allow fine-grained control of the contents of the `sdist` and `wheel` files.
|
|
28
|
+
|
|
29
|
+
In particular, this example takes pains to include the source files `runtime_build` or `*.clsp` in the sdist but not the wheel.
|
|
30
|
+
|
|
31
|
+
## Use
|
|
32
|
+
|
|
33
|
+
To load a puzzle, do something like
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from chiklisp_puzzles import load_puzzle
|
|
37
|
+
|
|
38
|
+
program = load_puzzle("p2_delegated_puzzle_or_hidden_puzzle")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
- This project is licensed under the Apache 2 License. See the LICENSE file for more details.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# chiklisp_puzzles
|
|
2
|
+
|
|
3
|
+
This project contains several standard and legacy puzzles commonly used on the chik network.
|
|
4
|
+
|
|
5
|
+
Note that it uses `enscons` to build, as the more commonly used `setuptools` does not easily allow fine-grained control of the contents of the `sdist` and `wheel` files.
|
|
6
|
+
|
|
7
|
+
In particular, this example takes pains to include the source files `runtime_build` or `*.clsp` in the sdist but not the wheel.
|
|
8
|
+
|
|
9
|
+
## Use
|
|
10
|
+
|
|
11
|
+
To load a puzzle, do something like
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from chiklisp_puzzles import load_puzzle
|
|
15
|
+
|
|
16
|
+
program = load_puzzle("p2_delegated_puzzle_or_hidden_puzzle")
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
- This project is licensed under the Apache 2 License. See the LICENSE file for more details.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
; build a pay-to delegated puzzle or hidden puzzle
|
|
2
|
+
; coins can be unlocked by signing a delegated puzzle and its solution
|
|
3
|
+
; OR by revealing the hidden puzzle and the underlying original key
|
|
4
|
+
|
|
5
|
+
; glossary of parameter names:
|
|
6
|
+
|
|
7
|
+
; hidden_puzzle: a "hidden puzzle" that can be revealed and used as an alternate
|
|
8
|
+
; way to unlock the underlying funds
|
|
9
|
+
;
|
|
10
|
+
; synthetic_key_offset: a private key cryptographically generated using the hidden
|
|
11
|
+
; puzzle and as inputs `original_public_key`
|
|
12
|
+
;
|
|
13
|
+
; SYNTHETIC_PUBLIC_KEY: the public key that is the sum of `original_public_key` and the
|
|
14
|
+
; public key corresponding to `synthetic_key_offset`
|
|
15
|
+
;
|
|
16
|
+
; original_public_key: a public key, where knowledge of the corresponding private key
|
|
17
|
+
; represents ownership of the file
|
|
18
|
+
;
|
|
19
|
+
; delegated_puzzle: a delegated puzzle, as in "graftroot", which should return the
|
|
20
|
+
; desired conditions.
|
|
21
|
+
;
|
|
22
|
+
; solution: the solution to the delegated puzzle
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
(mod
|
|
26
|
+
; A puzzle should commit to `SYNTHETIC_PUBLIC_KEY`
|
|
27
|
+
;
|
|
28
|
+
; The solution should pass in 0 for `original_public_key` if it wants to use
|
|
29
|
+
; an arbitrary `delegated_puzzle` (and `solution`) signed by the
|
|
30
|
+
; `SYNTHETIC_PUBLIC_KEY` (whose corresponding private key can be calculated
|
|
31
|
+
; if you know the private key for `original_public_key`)
|
|
32
|
+
;
|
|
33
|
+
; Or you can solve the hidden puzzle by revealing the `original_public_key`,
|
|
34
|
+
; the hidden puzzle in `delegated_puzzle`, and a solution to the hidden puzzle.
|
|
35
|
+
|
|
36
|
+
(SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle solution)
|
|
37
|
+
|
|
38
|
+
; "assert" is a macro that wraps repeated instances of "if"
|
|
39
|
+
; usage: (assert A0 A1 ... An R)
|
|
40
|
+
; all of A0, A1, ... An must evaluate to non-null, or an exception is raised
|
|
41
|
+
; return the value of R (if we get that far)
|
|
42
|
+
|
|
43
|
+
(defmacro assert items
|
|
44
|
+
(if (r items)
|
|
45
|
+
(list if (f items) (c assert (r items)) (q . (x)))
|
|
46
|
+
(f items)
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
(include condition_codes.clib)
|
|
51
|
+
|
|
52
|
+
;; hash a tree
|
|
53
|
+
;; This is used to calculate a puzzle hash given a puzzle program.
|
|
54
|
+
(defun sha256tree1
|
|
55
|
+
(TREE)
|
|
56
|
+
(if (l TREE)
|
|
57
|
+
(sha256 2 (sha256tree1 (f TREE)) (sha256tree1 (r TREE)))
|
|
58
|
+
(sha256 1 TREE)
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
; "is_hidden_puzzle_correct" returns true iff the hidden puzzle is correctly encoded
|
|
63
|
+
|
|
64
|
+
(defun-inline is_hidden_puzzle_correct (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle)
|
|
65
|
+
(=
|
|
66
|
+
SYNTHETIC_PUBLIC_KEY
|
|
67
|
+
(point_add
|
|
68
|
+
original_public_key
|
|
69
|
+
(pubkey_for_exp (sha256 original_public_key (sha256tree1 delegated_puzzle)))
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
; "possibly_prepend_aggsig" is the main entry point
|
|
75
|
+
|
|
76
|
+
(defun-inline possibly_prepend_aggsig (SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle conditions)
|
|
77
|
+
(if original_public_key
|
|
78
|
+
(assert
|
|
79
|
+
(is_hidden_puzzle_correct SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle)
|
|
80
|
+
conditions
|
|
81
|
+
)
|
|
82
|
+
(c (list AGG_SIG_ME SYNTHETIC_PUBLIC_KEY (sha256tree1 delegated_puzzle)) conditions)
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
; main entry point
|
|
87
|
+
|
|
88
|
+
(possibly_prepend_aggsig
|
|
89
|
+
SYNTHETIC_PUBLIC_KEY original_public_key delegated_puzzle
|
|
90
|
+
(a delegated_puzzle solution))
|
|
91
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
|
|
3
|
+
from chiklisp_builder import ChiklispBuild
|
|
4
|
+
|
|
5
|
+
from chiklisp_stdlib import STABLE_INCLUDE_DIRECTORY
|
|
6
|
+
|
|
7
|
+
PUZZLE_PATHS = [
|
|
8
|
+
pathlib.Path(_)
|
|
9
|
+
for _ in [
|
|
10
|
+
"p2_conditions.clsp",
|
|
11
|
+
"p2_delegated_puzzle_or_hidden_puzzle.clsp",
|
|
12
|
+
"calculate_synthetic_public_key.clsp",
|
|
13
|
+
]
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
BUILD_ARGUMENTS = {
|
|
17
|
+
puzzle_path.with_suffix(".hex").name: ChiklispBuild([STABLE_INCLUDE_DIRECTORY])
|
|
18
|
+
for puzzle_path in PUZZLE_PATHS
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: chiklisp-puzzles
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Some canonical puzzles deployed on chik-blockchain
|
|
5
|
+
Author-email: Richard Kiss <him@richardkiss.com>
|
|
6
|
+
License: Copyright 2023 by Richard Kiss
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
|
|
23
|
+
# chiklisp_puzzles
|
|
24
|
+
|
|
25
|
+
This project contains several standard and legacy puzzles commonly used on the chik network.
|
|
26
|
+
|
|
27
|
+
Note that it uses `enscons` to build, as the more commonly used `setuptools` does not easily allow fine-grained control of the contents of the `sdist` and `wheel` files.
|
|
28
|
+
|
|
29
|
+
In particular, this example takes pains to include the source files `runtime_build` or `*.clsp` in the sdist but not the wheel.
|
|
30
|
+
|
|
31
|
+
## Use
|
|
32
|
+
|
|
33
|
+
To load a puzzle, do something like
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from chiklisp_puzzles import load_puzzle
|
|
37
|
+
|
|
38
|
+
program = load_puzzle("p2_delegated_puzzle_or_hidden_puzzle")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
- This project is licensed under the Apache 2 License. See the LICENSE file for more details.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
chiklisp_puzzles/__init__.py
|
|
6
|
+
chiklisp_puzzles.egg-info/PKG-INFO
|
|
7
|
+
chiklisp_puzzles.egg-info/SOURCES.txt
|
|
8
|
+
chiklisp_puzzles.egg-info/dependency_links.txt
|
|
9
|
+
chiklisp_puzzles.egg-info/requires.txt
|
|
10
|
+
chiklisp_puzzles.egg-info/top_level.txt
|
|
11
|
+
chiklisp_puzzles/puzzles/calculate_synthetic_public_key.clsp
|
|
12
|
+
chiklisp_puzzles/puzzles/p2_conditions.clsp
|
|
13
|
+
chiklisp_puzzles/puzzles/p2_delegated_puzzle_or_hidden_puzzle.clsp
|
|
14
|
+
chiklisp_puzzles/puzzles/runtime_build
|
|
15
|
+
tests/test_load.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chiklisp_loader>=0.1.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chiklisp_puzzles
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "chiklisp_puzzles"
|
|
3
|
+
description = "Some canonical puzzles deployed on chik-blockchain"
|
|
4
|
+
authors = [{name = "Richard Kiss", email = "him@richardkiss.com"}]
|
|
5
|
+
license = {file = "LICENSE"}
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
dependencies = ["chiklisp_loader>=0.1.0"]
|
|
9
|
+
|
|
10
|
+
[build-system]
|
|
11
|
+
requires = [
|
|
12
|
+
"setuptools>=42",
|
|
13
|
+
"wheel",
|
|
14
|
+
"chiklisp_builder>=0.1.0",
|
|
15
|
+
"chiklisp_stdlib>=0.1.0",
|
|
16
|
+
"klvm_rs",
|
|
17
|
+
]
|
|
18
|
+
build-backend = "setuptools.build_meta"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
from runtime_builder import build_runtime_setuptools
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
setup(
|
|
6
|
+
packages=["chiklisp_puzzles", "chiklisp_puzzles.puzzles"],
|
|
7
|
+
package_data={"chiklisp_puzzles.puzzles": ["*.hex", "*.clsp", "runtime_build"]},
|
|
8
|
+
cmdclass={
|
|
9
|
+
"build_runtime_builder_artifacts": build_runtime_setuptools("chiklisp_puzzles.puzzles"),
|
|
10
|
+
},
|
|
11
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from chiklisp_puzzles import load_puzzle
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def check(puzzle_name: str, expected_hash: str):
|
|
5
|
+
program = load_puzzle(puzzle_name)
|
|
6
|
+
assert program.tree_hash().hex() == expected_hash
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_load():
|
|
10
|
+
check(
|
|
11
|
+
"p2_delegated_puzzle_or_hidden_puzzle",
|
|
12
|
+
"e9aaa49f45bad5c889b86ee3341550c155cfdd10c3a6757de618d20612fffd52",
|
|
13
|
+
)
|
|
14
|
+
check(
|
|
15
|
+
"p2_conditions",
|
|
16
|
+
"1c77d7d5efde60a7a1d2d27db6d746bc8e568aea1ef8586ca967a0d60b83cc36",
|
|
17
|
+
)
|
|
18
|
+
check(
|
|
19
|
+
"calculate_synthetic_public_key",
|
|
20
|
+
"624c5d5704d0decadfc0503e71bbffb6cdfe45025bce7cf3e6864d1eafe8f65e",
|
|
21
|
+
)
|