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

update hardcoded hashes #23

Merged
merged 1 commit into from
Sep 24, 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
26 changes: 13 additions & 13 deletions src/05-commits.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ We can create a commitment to any Lurk data with `commit`.

```
lurk-user> (commit 123)
[2 iterations] => #c0x4a902d7be96d1021a473353bd59247ea4c0f0688b5bae0c833a1f624b77ede
[2 iterations] => #c0x944834111822843979ace19833d05ca9daf2f655230faec517433e72fe777b
```

Now Lurk knows that `#c0x4a902d7be96d1021a473353bd59247ea4c0f0688b5bae0c833a1f624b77ede` is a commitment to `123` and can successfully open it.
Now Lurk knows that `#c0x944834111822843979ace19833d05ca9daf2f655230faec517433e72fe777b` is a commitment to `123` and can successfully open it.

```
lurk-user> (open #c0x4a902d7be96d1021a473353bd59247ea4c0f0688b5bae0c833a1f624b77ede)
lurk-user> (open #c0x944834111822843979ace19833d05ca9daf2f655230faec517433e72fe777b)
[2 iterations] => 123
```

Lurk understands it if you use big nums in an `open` expression directly.

```
lurk-user> (open #0x4a902d7be96d1021a473353bd59247ea4c0f0688b5bae0c833a1f624b77ede)
lurk-user> (open #0x944834111822843979ace19833d05ca9daf2f655230faec517433e72fe777b)
[2 iterations] => 123
```

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

```
lurk-user> (hide #0x1 123)
[3 iterations] => #c0x2d42d50c445fe7021003b9d177e09e93008f97f74eea0f1c61c3f27aec104f
[3 iterations] => #c0x483cd4ed61cb38d4722743fe470c4c81abf1a568ceae9423864d5acf03739f
```

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

```
lurk-user> (hide #0x0 123)
[3 iterations] => #0x4a902d7be96d1021a473353bd59247ea4c0f0688b5bae0c833a1f624b77ede
[3 iterations] => #c0x944834111822843979ace19833d05ca9daf2f655230faec517433e72fe777b
```

And both hashes above open to the same value `123`.

```
lurk-user> (open #0x4a902d7be96d1021a473353bd59247ea4c0f0688b5bae0c833a1f624b77ede)
lurk-user> (open #c0x944834111822843979ace19833d05ca9daf2f655230faec517433e72fe777b)
[2 iterations] => 123
lurk-user> (open #c0x2d42d50c445fe7021003b9d177e09e93008f97f74eea0f1c61c3f27aec104f)
lurk-user> (open #c0x483cd4ed61cb38d4722743fe470c4c81abf1a568ceae9423864d5acf03739f)
[2 iterations] => 123
```

Expand All @@ -56,16 +56,16 @@ Again, we can commit to *any* Lurk data, including functions.

```
lurk-user> (commit (lambda (x) (+ 7 (* x x))))
[2 iterations] => #c0x8b10a9e88372ee05aea4230b21d7ed9b9e4b1d7f9d2a056d125172ad07c4fc
[2 iterations] => #c0x6cea5bb3cb63a9bd119d5d00e40807e717e6b98c645ac25aae60ed35255b07
```

The above is a commitment to a function that squares its input then adds seven.
Then we can open it and apply arguments as usual.

```
lurk-user> ((open #c0x8b10a9e88372ee05aea4230b21d7ed9b9e4b1d7f9d2a056d125172ad07c4fc) 5)
lurk-user> ((open #c0x6cea5bb3cb63a9bd119d5d00e40807e717e6b98c645ac25aae60ed35255b07) 5)
[8 iterations] => 32
lurk-user> ((open #c0x8b10a9e88372ee05aea4230b21d7ed9b9e4b1d7f9d2a056d125172ad07c4fc) 9)
lurk-user> ((open #c0x6cea5bb3cb63a9bd119d5d00e40807e717e6b98c645ac25aae60ed35255b07) 9)
[8 iterations] => 88
```

Expand All @@ -80,14 +80,14 @@ lurk-user>
(let ((secret-data 222)
(data-interface (lambda (f) (f secret-data))))
(commit data-interface))
[5 iterations] => #c0x759b94bccb5545915690c4e847e0f3e5e42c732eafcc02cbcd55ac50066c9b
[5 iterations] => #c0x4b672917bfcbef3c73e01e50a500f2947d9378f6a1ec19588bc7fd3766f81d
```

Now we can open it, applying it to a function that adds `111` to the secret value that the committed function hides.

```
lurk-user>
((open #c0x759b94bccb5545915690c4e847e0f3e5e42c732eafcc02cbcd55ac50066c9b)
((open #c0x4b672917bfcbef3c73e01e50a500f2947d9378f6a1ec19588bc7fd3766f81d)
(lambda (data) (+ data 111)))
[10 iterations] => 333
```
Expand Down
24 changes: 11 additions & 13 deletions src/07-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ lurk-user> ((lambda (x) (begin (emit x) (+ x x))) 1)

```
lurk-user> (bignum (commit 1))
[3 iterations] => #0x8f1deaa5f6031277a6a5a7e0f35f15ef42da64b1e203769982da26038f1e25
[3 iterations] => #0xf99d96623838468091ce6590ccb3b829938823d964f3f5962f837f1400e2b
```

### `car`
Expand Down Expand Up @@ -120,10 +120,10 @@ lurk-user> (char nil)

```
lurk-user> (commit 1)
[2 iterations] => #c0x8f1deaa5f6031277a6a5a7e0f35f15ef42da64b1e203769982da26038f1e25
lurk-user> (open #c0x8f1deaa5f6031277a6a5a7e0f35f15ef42da64b1e203769982da26038f1e25)
[2 iterations] => #c0xf99d96623838468091ce6590ccb3b829938823d964f3f5962f837f1400e2b
lurk-user> (open #c0xf99d96623838468091ce6590ccb3b829938823d964f3f5962f837f1400e2b)
[3 iterations] => 1
lurk-user> (secret #c0x8f1deaa5f6031277a6a5a7e0f35f15ef42da64b1e203769982da26038f1e25)
lurk-user> (secret #c0xf99d96623838468091ce6590ccb3b829938823d964f3f5962f837f1400e2b)
[3 iterations] => #0x0
```

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

```
lurk-user> (hide #0x123 456)
[3 iterations] => #c0x7834e8081d1317cce4dd8c9098e417bbf248ac0b997772a96980c00686e7e0
lurk-user> (open #c0x7834e8081d1317cce4dd8c9098e417bbf248ac0b997772a96980c00686e7e0)
[3 iterations] => #c0x4420657169325d52f910f0ffe606b3a7b600a982691926b207f21350120d3d
lurk-user> (open #c0x4420657169325d52f910f0ffe606b3a7b600a982691926b207f21350120d3d)
[3 iterations] => 456
lurk-user> (secret #c0x7834e8081d1317cce4dd8c9098e417bbf248ac0b997772a96980c00686e7e0)
lurk-user> (secret #c0x4420657169325d52f910f0ffe606b3a7b600a982691926b207f21350120d3d)
[3 iterations] => #0x123
```

Expand Down Expand Up @@ -376,11 +376,9 @@ lurk-user> (u64 nil)
```
lurk-user> (open (commit 1))
[3 iterations] => 1
lurk-user> (open (hide #0x123 2))
[4 iterations] => 2
lurk-user> (open #0x8f1deaa5f6031277a6a5a7e0f35f15ef42da64b1e203769982da26038f1e25)
lurk-user> (open #c0xf99d96623838468091ce6590ccb3b829938823d964f3f5962f837f1400e2b)
[2 iterations] => 1
lurk-user> (open #c0x8f1deaa5f6031277a6a5a7e0f35f15ef42da64b1e203769982da26038f1e25)
lurk-user> (open #0xf99d96623838468091ce6590ccb3b829938823d964f3f5962f837f1400e2b)
[2 iterations] => 1
```

Expand Down Expand Up @@ -414,9 +412,9 @@ lurk-user> (secret (commit 1))
[3 iterations] => #0x0
lurk-user> (secret (hide #0x123 2))
[4 iterations] => #0x123
lurk-user> (secret #0x7a9196fa4cb9236389fdbd2feb108986d4d668c8caad347f4334c6b147cb67)
lurk-user> (secret #c0x76cc74360d9492188f072ecdafd2ddf50fadac0ce2007c551c09fdcd556109)
[2 iterations] => #0x123
lurk-user> (secret #c0x7a9196fa4cb9236389fdbd2feb108986d4d668c8caad347f4334c6b147cb67)
lurk-user> (secret #0x76cc74360d9492188f072ecdafd2ddf50fadac0ce2007c551c09fdcd556109)
[2 iterations] => #0x123
```

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

```
lurk-user> (commit (lambda (x) (+ x 1)))
[2 iterations] => #c0x3a248e9776f7f49a5279269aae67a9a0eac50357406b1e1083b571fd5b2c5b
lurk-user> (#c0x3a248e9776f7f49a5279269aae67a9a0eac50357406b1e1083b571fd5b2c5b 10)
[2 iterations] => #c0x1471db9125f186dc43467642fccf39121096fbe733384ea00b69e1800b1aae
lurk-user> (#c0x1471db9125f186dc43467642fccf39121096fbe733384ea00b69e1800b1aae 10)
[6 iterations] => 11
```

Expand All @@ -75,22 +75,22 @@ lurk-user>
(let ((counter (+ counter x)))
(cons counter (commit (add counter)))))))
(add 0)))
[6 iterations] => #c0x5a34ed7712c5fd2f324feb0e1764b27bac9259c4b663e4601e678939a9363d
[6 iterations] => #c0x4b0eb13f048385909480e765f4eefec94c304edf9e01b2170869c9cdf8eb11
```

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

```
lurk-user> (#c0x5a34ed7712c5fd2f324feb0e1764b27bac9259c4b663e4601e678939a9363d 5)
[13 iterations] => (5 . #c0x4a706d7701a9b79ddbffca887f38c60bd7eb38acc737b53ea631a10fff7e4b)
lurk-user> (#c0x4b0eb13f048385909480e765f4eefec94c304edf9e01b2170869c9cdf8eb11 5)
[13 iterations] => (5 . #c0x43f23a52a844a74f53f564c7234a6fa265afacd228c7a1b12167d542cc34e3)
```

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.

```
lurk-user> (#c0x4a706d7701a9b79ddbffca887f38c60bd7eb38acc737b53ea631a10fff7e4b 3)
[13 iterations] => (8 . #c0xf61e10e5c607c0fe0ef7cd879b6d2a6eb1ea7016fde6479e836b56ea27bf3)
lurk-user> (#c0x43f23a52a844a74f53f564c7234a6fa265afacd228c7a1b12167d542cc34e3 3)
[13 iterations] => (8 . #c0x784468987da6dd9cbb1f43d265c906f8f3e4c7503cf26b031aa51176a457c1)
```

The new result is `8` and we also get the next callable, as expected.
Expand Down Expand Up @@ -152,14 +152,14 @@ And then prove it for, say, the number `3`.

```
lurk-user> !(prove-protocol simple-protocol "protocol-proof" 3)
Proof key: "299be6acd05ee9cc8e3687cb85b3b3cf32acf62f4be3c46995156136597966"
Proof key: "702b71f40deacfc4167be5493b1df1a6dd4cd7e56e4fc25d6f21114255b8df"
Protocol proof saved at protocol-proof
```

Let's inspect the (cached) proof we've just created.

```
lurk-user> !(inspect "299be6acd05ee9cc8e3687cb85b3b3cf32acf62f4be3c46995156136597966")
lurk-user> !(inspect "702b71f40deacfc4167be5493b1df1a6dd4cd7e56e4fc25d6f21114255b8df")
Expr: (= 3 3)
Env: <Env ()>
Result: t
Expand Down Expand Up @@ -211,10 +211,10 @@ lurk-user> !(def hash (hide (bignum (commit password)) "private data"))
hash
lurk-user> !(prove (begin (open hash) t))
[4 iterations] => t
Proof key: "14c6c98e3409c56139e2d3b096980bb5b6f380fc7582f69bbf61edccc13949"
lurk-user> !(inspect "14c6c98e3409c56139e2d3b096980bb5b6f380fc7582f69bbf61edccc13949")
Proof key: "468985a2f4691664335d87793144d0b9b7531acb06841ac725474910985927"
lurk-user> !(inspect "468985a2f4691664335d87793144d0b9b7531acb06841ac725474910985927")
Expr: (begin (open hash) t)
Env: <Env ((hash . #c0x51d1c3d0c5ea9d2d7d27eda6ef7ef48ad2ffd8dd80693adf06a4afeed6fd8a) (password . "some password"))>
Env: <Env ((hash . #c0x145c99908adac10ee79eb5e1d74ad8fe42c10abe79f5ef3d5dbb96915cc7a3) (password . "some password"))>
Result: t
```

Expand Down