-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat(utils): utilities to seed MPC and iris code database #49
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4a5aa9d
add script to migrate codes to mpc dbs
0xKitsune 5b9be0e
update logic to get iris code snapshot
0xKitsune 90279ee
update snapshot logic
0xKitsune 961970f
refactored utils
0xKitsune 358c27f
added readme for utils
0xKitsune f83d377
Merge branch 'main' into 0xkitsune/migrate-codes
0xKitsune d76b06e
updated readme
0xKitsune 92cdb4b
update seed mpc db logging
0xKitsune 0a2d638
updated iris db seed logging
0xKitsune e25ae0c
updated migrate code args
0xKitsune d7e7160
removed migrate code from branch
0xKitsune f6fa2d3
clippy
0xKitsune 0333d7f
fix collection name
0xKitsune f3b1cbb
cargo fmt
0xKitsune d008248
Update README.md
0xKitsune File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# MPC Utils | ||
|
||
|
||
## Seed MPC Databases | ||
Seed the coordinator and participant databases with random shares and masks. When seeding multiple participant databases, specify a `--participant-db-url` for each participant db. | ||
|
||
```bash | ||
cargo run --bin utils seed-mpc-db --coordinator-db-url <COORDINATOR_DB_URL> --participant-db-url <PARTICIPANT_0_DB_URL> --participant-db-url <PARTICIPANT_1_DB_URL> --num-templates <NUM_TEMPLATES> | ||
``` | ||
|
||
## Seed Iris Database | ||
Seed the iris code database with random iris code entries. Each entry includes a `signup_id`, `serial_id`, `iris_code_left`, `mask_code_left`, `iris_code_right` and `mask_code_right`. | ||
|
||
```bash | ||
cargo run --bin utils seed-iris-db --iris-code-db <IRIS_CODE_DB> --num-templates <NUM_TEMPLATES> | ||
``` | ||
|
||
|
||
## Send a Random Query via SQS | ||
Send a random iris code template to the MPC setup via SQS. Ensure that you are logged into the proper AWS account for the queue url you are using. If running with Localstack, ensure to also pass `--endpoint-url <ENDPOINT_URL>` and `--region <AWS_REGION>`. | ||
|
||
```bash | ||
cargo run --bin utils sqs-query --queue-url <SQS_QUEUE_URL> | ||
``` | ||
|
||
|
||
## Receive SQS Results | ||
Receive messages from a queue. This is useful when inspecting the results queue after sending a query to the MPC setup. If the queue is empty, the program will continually check for new message every second. Once messages are in the queue, the program will receive all messages, print them to the terminal and then delete the message from the queue. Ensure that you are logged into the proper AWS account for the queue url you are using. If running with Localstack, ensure to also pass `--endpoint-url <ENDPOINT_URL>` and `--region <AWS_REGION>`. | ||
|
||
```bash | ||
cargo run --bin utils sqs-receive --queue-url <SQS_QUEUE_URL> | ||
``` | ||
|
||
## Generate Mock Templates | ||
|
||
Generate random templates and write the resulting items to an output file. | ||
|
||
```bash | ||
cargo run --bin utils generate-mock-templates --num-templates <NUM_TEMPLATES> --output <OUTPUT_FILE> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use clap::Args; | ||
use mpc::template::Template; | ||
use rand::{thread_rng, Rng}; | ||
|
||
#[derive(Debug, Clone, Args)] | ||
pub struct GenerateMockTemplates { | ||
#[clap(short, long)] | ||
pub output: String, | ||
|
||
#[clap(short, long)] | ||
pub num_templates: usize, | ||
} | ||
|
||
pub async fn generate_mock_templates( | ||
args: &GenerateMockTemplates, | ||
) -> eyre::Result<()> { | ||
let mut rng = thread_rng(); | ||
|
||
let templates: Vec<Template> = | ||
(0..args.num_templates).map(|_| rng.gen()).collect(); | ||
|
||
let json = serde_json::to_string(&templates)?; | ||
|
||
//write to file | ||
std::fs::write(&args.output, json)?; | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like at this point we should move the utils to a crate. I can take a look at that later