Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update comm syntax #18

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/04-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ It has the same domain range of big nums.

```
user> (comm #0x0)
[2 iterations] => (comm #0x0)
[2 iterations] => #c0x0
```

### Characters
Expand Down
14 changes: 7 additions & 7 deletions src/05-commits.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ We can create a commitment to any Lurk data with `commit`.

```
user> (commit 123)
[2 iterations] => (comm #0x3719f5d02845123a80da4f5077c803ba0ce1964e08289a9d020603c1f3c450)
[2 iterations] => #c0x3719f5d02845123a80da4f5077c803ba0ce1964e08289a9d020603c1f3c450
```

Now Lurk knows that `(comm #0x3719f5d02845123a80da4f5077c803ba0ce1964e08289a9d020603c1f3c450)` is a commitment to `123` and can successfully open it.
Now Lurk knows that `#c0x3719f5d02845123a80da4f5077c803ba0ce1964e08289a9d020603c1f3c450` is a commitment to `123` and can successfully open it.

```
user> (open (comm #0x3719f5d02845123a80da4f5077c803ba0ce1964e08289a9d020603c1f3c450))
user> (open #c0x3719f5d02845123a80da4f5077c803ba0ce1964e08289a9d020603c1f3c450)
[2 iterations] => 123
```

Expand All @@ -32,14 +32,14 @@ The hiding *secret* must be a big num.

```
user> (hide #0x1 123)
[3 iterations] => (comm #0x7e14ff1d0f6c3844f57c9120786d54256e73c8f08a80f31d6502d87884b3d4)
[3 iterations] => #c0x7e14ff1d0f6c3844f57c9120786d54256e73c8f08a80f31d6502d87884b3d4
```

For when hiding is unimportant, `commit` creates commitments with a default secret of `#0x0`.

```
user> (hide #0x0 123)
[3 iterations] => (comm #0x3719f5d02845123a80da4f5077c803ba0ce1964e08289a9d020603c1f3c450)
[3 iterations] => #c0x3719f5d02845123a80da4f5077c803ba0ce1964e08289a9d020603c1f3c450
```

And both hashes above open to the same value `123`.
Expand All @@ -57,7 +57,7 @@ Again, we can commit to *any* Lurk data, including functions.

```
user> (commit (lambda (x) (+ 7 (* x x))))
[2 iterations] => (comm #0x84a0ebe63fadc8a5e8b848a644a4af72150b6c11652cdbe862f2ee3ffce614)
[2 iterations] => #c0x84a0ebe63fadc8a5e8b848a644a4af72150b6c11652cdbe862f2ee3ffce614
```

The above is a commitment to a function that squares its input then adds seven.
Expand All @@ -81,7 +81,7 @@ user>
(let ((secret-data 222)
(data-interface (lambda (f) (f secret-data))))
(commit data-interface))
[5 iterations] => (comm #0x4668b9badf58209537dbb62e132badc5bb7bbaf137a8daeeef550046634da8)
[5 iterations] => #c0x4668b9badf58209537dbb62e132badc5bb7bbaf137a8daeeef550046634da8
```

Now we can open it, applying it to a function that adds `111` to the secret value that the committed function hides.
Expand Down
20 changes: 10 additions & 10 deletions src/07-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ user> (char nil)

```
user> (commit 1)
[2 iterations] => (comm #0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb)
user> (open (comm #0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb))
[2 iterations] => #c0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb
user> (open #c0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb)
[3 iterations] => 1
user> (secret (comm #0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb))
user> (secret #c0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb)
[3 iterations] => #0x0
```

Expand All @@ -132,10 +132,10 @@ user> (secret (comm #0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a4

```
user> (comm #0x0)
[2 iterations] => (comm #0x0)
[2 iterations] => #c0x0
user> (bignum (comm #0x0))
[3 iterations] => #0x0
user> (open (comm #0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb))
user> (open #c0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb)
[3 iterations] => 1
```

Expand Down Expand Up @@ -281,10 +281,10 @@ user> (type-eqq (+ 1 2) (cons 1 2))

```
user> (hide #0x123 456)
[3 iterations] => (comm #0x6abde5983eb1b904d3b4fa40700307e835f99547043ccec37a7be641aad3ce)
user> (open (comm #0x6abde5983eb1b904d3b4fa40700307e835f99547043ccec37a7be641aad3ce))
[3 iterations] => #c0x6abde5983eb1b904d3b4fa40700307e835f99547043ccec37a7be641aad3ce
user> (open #c0x6abde5983eb1b904d3b4fa40700307e835f99547043ccec37a7be641aad3ce)
[3 iterations] => 456
user> (secret (comm #0x6abde5983eb1b904d3b4fa40700307e835f99547043ccec37a7be641aad3ce))
user> (secret #c0x6abde5983eb1b904d3b4fa40700307e835f99547043ccec37a7be641aad3ce)
[3 iterations] => #0x123
```

Expand Down Expand Up @@ -370,7 +370,7 @@ user> (open (hide #0x123 2))
[4 iterations] => 2
user> (open #0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb)
[2 iterations] => 1
user> (open (comm #0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb))
user> (open #c0x35ff7b6fb1e777a95aadced4e080fa9c024a47d7b1f81d217fa04a2a494fbb)
[3 iterations] => 1
```

Expand Down Expand Up @@ -406,7 +406,7 @@ user> (secret (hide #0x123 2))
[4 iterations] => #0x123
user> (secret #0x93ac209775c37ba61db238500fb84e528807ae21d523a1e51a7b1be05d23dc)
[2 iterations] => #0x123
user> (secret (comm #0x93ac209775c37ba61db238500fb84e528807ae21d523a1e51a7b1be05d23dc))
user> (secret #c0x93ac209775c37ba61db238500fb84e528807ae21d523a1e51a7b1be05d23dc)
[3 iterations] => #0x123
```

Expand Down
10 changes: 5 additions & 5 deletions src/08-repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ For example, the following is accepted by Lurk.

```
user> (commit (lambda (x) (+ x 1)))
[2 iterations] => (comm #0x4384e08797d3cd0f911d844e137e54093460c295a4d71cf951259a9ff9712e)
[2 iterations] => #c0x4384e08797d3cd0f911d844e137e54093460c295a4d71cf951259a9ff9712e
user> (#0x4384e08797d3cd0f911d844e137e54093460c295a4d71cf951259a9ff9712e 10)
[6 iterations] => 11
```
Expand All @@ -75,22 +75,22 @@ user>
(let ((counter (+ counter x)))
(cons counter (commit (add counter)))))))
(add 0)))
[6 iterations] => (comm #0x8ef25bc2228ca9799db65fd2b137a7b0ebccbfc04cf8530133e60087d403db)
[6 iterations] => #c0x8ef25bc2228ca9799db65fd2b137a7b0ebccbfc04cf8530133e60087d403db
```

And let's see what happens when we provide the argument `5` to it.

```
user> (#0x8ef25bc2228ca9799db65fd2b137a7b0ebccbfc04cf8530133e60087d403db 5)
[13 iterations] => (5 . (comm #0x6b2984a56dc2bbb61495c6fdf8076f0debf10ab2ae43aa1de45de64b460141))
[13 iterations] => (5 . #c0x6b2984a56dc2bbb61495c6fdf8076f0debf10ab2ae43aa1de45de64b460141)
```

We get the current counter result and the next callable (a functional commitment in this example).
So let's provide the argument `3` to this next callable.

```
user> (#0x6b2984a56dc2bbb61495c6fdf8076f0debf10ab2ae43aa1de45de64b460141 3)
[13 iterations] => (8 . (comm #0x75711244ea5c5bb0f46692db8851748d860f1e8d7e24a8bbf12caf6ed27c91))
[13 iterations] => (8 . #c0x75711244ea5c5bb0f46692db8851748d860f1e8d7e24a8bbf12caf6ed27c91)
```

The new result is `8` and we also get the next callable, as expected.
Expand Down Expand Up @@ -206,7 +206,7 @@ user> !(prove (begin (open hash) t))
Proof key: "50426c0c272d181e8e2248f7de943b92093fd2386d5a1ecb68956a3250bb7d"
user> !(inspect "50426c0c272d181e8e2248f7de943b92093fd2386d5a1ecb68956a3250bb7d")
Expr: (begin (open hash) t)
Env: <Env ((hash . (comm #0x754a1c7a2f8d791e2896930cfb15fbce2ba61b92f4069f396d86e5addd28fb)) (password . "some password"))>
Env: <Env ((hash . #c0x754a1c7a2f8d791e2896930cfb15fbce2ba61b92f4069f396d86e5addd28fb) (password . "some password"))>
Result: t
```

Expand Down