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

docs: update demo docs for user registration #721

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
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
76 changes: 58 additions & 18 deletions book/src/zcash/ywallet-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ cargo run --release -- sign --tx-plan <tx_plan_path> --ufvk <ufvk> -o <tx_signed

The program will print a SIGHASH and a Randomizer.


### Running the server

Now you will need to simulate two participants and a Coordinator to sign the
transaction, and the FROST server that handles communications between them.
It's probably easier to open four terminals.
Expand All @@ -128,36 +131,51 @@ run):
RUST_LOG=debug cargo run --bin server
```

In the second one, the Coordinator, run (in the same folder where key generation
was run):
### Registering users

In order to interact with the server, you will need to register users. For this
guide we will need two. In a new terminal, run the following command for user
"alice" (replace the password if you want):

```
cargo run --bin coordinator -- -C redpallas --http -r -
curl --data-binary '{"username": "alice", "password": "foobar10", "pubkey": ""}' -H 'Content-Type: application/json' http://127.0.0.1:2744/register
mpguerra marked this conversation as resolved.
Show resolved Hide resolved
```

And then:
It will output "null". Also register user "bob":

- It should read the public key package from `public-key-package.json`.
- Type `2` for the number of participants.
- Copy the session ID that is printed.
```
curl --data-binary '{"username": "bob", "password": "foobar10", "pubkey": ""}' -H 'Content-Type: application/json' http://127.0.0.1:2744/register
```

You only need to do this once, in case you want to sign more than one
mpguerra marked this conversation as resolved.
Show resolved Hide resolved
mpguerra marked this conversation as resolved.
Show resolved Hide resolved
transaction. If for some reason you want to start over, close the server and
delete the `db.sqlite` file.

In the third terminal, Participant 1, run the following, replacing
`<SESSION_ID>` with the session ID you have just copied:
Feel free to close this terminal, or reuse it for the next step.

```admonish warning
Do not use passwords that you use in practice; use dummy ones instead. (You
shouldn't reuse passwords anyway!) For real world usage you would need to take
more care to not end up writing the password to your shell history. (In real
world usage we'd expect this to be done by applications anyway.)
```
cargo run --bin participant -- -C redpallas --http --key-package key-package-1.json -s <SESSION_ID>
```

In the fourth terminal, for Participant 2, run the following, again replacing
the session ID:
### Coordinator

In the second terminal, the Coordinator, run (in the same folder where key
generation was run):

```
cargo run --bin participant -- -C redpallas --http --key-package key-package-2.json -s <SESSION_ID>
export PW=foobar10
cargo run --bin coordinator -- -C redpallas --http -u alice -w PW -S alice,bob -r -
```

Go back to the Coordinator CLI:
We will use "alice" as the Coordinator, so change the value next to `export PW=`
if you used another password when registering "alice".

And then:

- It should read the public key package from `public-key-package.json`.
- When prompted for the message to be signed, paste the SIGHASH printed by the
mpguerra marked this conversation as resolved.
Show resolved Hide resolved
signer above (just the hex value, e.g.
``4d065453cfa4cfb4f98dbc9cff60c4a3904ed91c523b8ef8d67d28bea7f12ea3``).
Expand All @@ -169,9 +187,31 @@ If you prefer to pass the randomizer as a file by using the `--randomizer`
argument, you will need to convert it to binary format.
```

The protocol should run and complete succesfully. You should still be at the
Coordinator CLI. It has just printed the final FROST-generated signature.
Hurrah! Copy it (just the hex value).
### Participant 1 (alice)

In the third terminal, Participant 1, run the following:

```
export PW=foobar10
cargo run --bin participant -- -C redpallas --http --key-package key-package-1.json -u alice -w PW
```

(We are using "alice" again. There's nothing stopping a Coordinator from being a
Partcipant too!)

### Participant 2 (bob)

In the fourth terminal, for Participant 2, run the following:

```
cargo run --bin participant -- -C redpallas --http --key-package key-package-2.json -u bob -w PW
mpguerra marked this conversation as resolved.
Show resolved Hide resolved
```

### Coordinator

Go back to the Coordinator CLI. The protocol should run and complete
succesfully. It will print the final FROST-generated signature. Hurrah! Copy it
(just the hex value).

Go back to the signer and paste the signature. It will write the raw signed
transaction to the file you specified.
Expand Down
Loading