-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MaximFischuk/feature/zksnarks-api-support
Feature/zksnarks api support
- Loading branch information
Showing
10 changed files
with
505 additions
and
3 deletions.
There are no files selected for viewing
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 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 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 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,44 @@ | ||
use vaultrs::client::{VaultClient, VaultClientSettingsBuilder}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// Create a client | ||
let client = VaultClient::new( | ||
VaultClientSettingsBuilder::default() | ||
.address("http://localhost:8200") | ||
.token("root") | ||
.build() | ||
.unwrap(), | ||
) | ||
.unwrap(); | ||
|
||
// Create a new account | ||
let account = quorum_vault_client::api::create_zksnarks_account(&client, "quorum") | ||
.await | ||
.unwrap(); | ||
println!("account: {:?}", account); | ||
|
||
// Read the account | ||
let account = | ||
quorum_vault_client::api::read_zksnarks_account(&client, "quorum", &account.public_key) | ||
.await | ||
.unwrap(); | ||
println!("account: {:?}", account); | ||
|
||
// List the accounts | ||
let accounts = quorum_vault_client::api::list_zksnarks_accounts(&client, "quorum") | ||
.await | ||
.unwrap(); | ||
println!("accounts: {:?}", accounts); | ||
|
||
// Sign a message | ||
let signature = quorum_vault_client::api::zksnarks_sign( | ||
&client, | ||
"quorum", | ||
&account.public_key, | ||
"some-data".as_bytes(), | ||
) | ||
.await | ||
.unwrap(); | ||
println!("signature: {:?}", signature); | ||
} |
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 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,2 @@ | ||
pub mod requests; | ||
pub mod responses; |
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,83 @@ | ||
use crate::api::zksnarks::responses::*; | ||
use rustify_derive::Endpoint; | ||
|
||
/// ## Create Zk-Snarks Account | ||
/// This endpoint creates a new Zk-Snarks account. | ||
/// | ||
/// * Path: /zk-snarks/accounts | ||
/// * Method: POST | ||
/// * Response: [ZkSnarksAccountResponse] | ||
#[derive(Builder, Debug, Endpoint)] | ||
#[endpoint( | ||
path = "{self.mount}/zk-snarks/accounts", | ||
method = "POST", | ||
response = "ZkSnarksAccountResponse", | ||
builder = "true" | ||
)] | ||
#[builder(setter(into))] | ||
pub struct CreateZkSnarksAccountRequest { | ||
#[endpoint(skip)] | ||
pub mount: String, | ||
} | ||
|
||
/// ## Read Zk-Snarks Account | ||
/// This endpoint gets a Zk-Snarks account by ID. | ||
/// | ||
/// * Path: /zk-snarks/accounts/{self.id} | ||
/// * Method: GET | ||
/// * Response: [ZkSnarksAccountResponse] | ||
#[derive(Builder, Debug, Endpoint)] | ||
#[endpoint( | ||
path = "{self.mount}/zk-snarks/accounts/{self.id}", | ||
method = "GET", | ||
response = "ZkSnarksAccountResponse", | ||
builder = "true" | ||
)] | ||
#[builder(setter(into))] | ||
pub struct ReadZkSnarksAccountRequest { | ||
#[endpoint(skip)] | ||
pub mount: String, | ||
pub id: String, | ||
} | ||
|
||
/// ## List Zk-Snarks Accounts | ||
/// This endpoint gets all Zk-Snarks accounts. | ||
/// | ||
/// * Path: /zk-snarks/accounts | ||
/// * Method: GET | ||
/// * Response: [ZkSnarksAccountsResponse] | ||
#[derive(Builder, Debug, Endpoint)] | ||
#[endpoint( | ||
path = "{self.mount}/zk-snarks/accounts", | ||
method = "GET", | ||
response = "ZkSnarksAccountsResponse", | ||
builder = "true" | ||
)] | ||
#[builder(setter(into))] | ||
pub struct ListZkSnarksAccountsRequest { | ||
#[endpoint(skip)] | ||
pub mount: String, | ||
} | ||
|
||
/// ## Sign data with Zk-Snarks Account | ||
/// This endpoint signs data with a Zk-Snarks account. | ||
/// | ||
/// * Path: /zk-snarks/accounts/{self.id}/sign | ||
/// * Method: POST | ||
/// * Response: [ZkSnarksSignResponse] | ||
#[derive(Builder, Debug, Endpoint)] | ||
#[endpoint( | ||
path = "{self.mount}/zk-snarks/accounts/{self.id}/sign", | ||
method = "POST", | ||
response = "ZkSnarksSignResponse", | ||
builder = "true" | ||
)] | ||
#[builder(setter(into))] | ||
pub struct ZkSnarksSignRequest { | ||
#[endpoint(skip)] | ||
pub mount: String, | ||
#[endpoint(skip)] | ||
pub id: String, | ||
#[endpoint(body)] | ||
pub data: String, | ||
} |
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,22 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Response from executing [CreateZkSnarksAccountRequest][crate::api::zksnarks::requests::CreateZkSnarksAccountRequest] | ||
#[derive(Deserialize, Debug, Serialize)] | ||
pub struct ZkSnarksAccountResponse { | ||
pub curve: String, | ||
pub namespace: String, | ||
pub public_key: String, | ||
pub signing_algorithm: String, | ||
} | ||
|
||
/// Response from executing [ListZkSnarksAccountsRequest][crate::api::zksnarks::requests::ListZkSnarksAccountsRequest] | ||
#[derive(Deserialize, Debug, Serialize)] | ||
pub struct ZkSnarksAccountsResponse { | ||
pub keys: Vec<String>, | ||
} | ||
|
||
/// Response from executing [ZkSnarksSignRequest][crate::api::zksnarks::requests::ZkSnarksSignRequest] | ||
#[derive(Deserialize, Debug, Serialize)] | ||
pub struct ZkSnarksSignResponse { | ||
pub signature: String, | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
mod ethereum; | ||
mod keys; | ||
mod zksnarks; |
Oops, something went wrong.