Skip to content

Commit

Permalink
offload data into post body
Browse files Browse the repository at this point in the history
  • Loading branch information
lebedenko-ubique committed Nov 14, 2024
1 parent c8550f5 commit 6808ab7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
29 changes: 17 additions & 12 deletions next-gen-signing-service/examples/zkp/flow.http
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ GET http://localhost:8000/zkp/keypair
exports.issuer_sk = response.parsedBody.secret_key
}}

GET http://localhost:8000/zkp/issue
?data={{data}}
&issuer_pk={{issuer_pk}}
POST http://localhost:8000/zkp/issue
?issuer_pk={{issuer_pk}}
&issuer_sk={{issuer_sk}}
&issuer_id={{issuer_id}}
&issuer_key_id={{issuer_key_id}}

{{data}}

{{
exports.credential = response.parsedBody.encoded;
}}
Expand All @@ -71,22 +72,26 @@ GET http://localhost:8000/zkp/proving-keys
))
}}

GET http://localhost:8000/zkp/present
?credential={{credential}}
&definition={{definition}}
&proving_keys={{proving_keys}}
&issuer_pk={{issuer_pk}}
POST http://localhost:8000/zkp/present
?issuer_pk={{issuer_pk}}
&issuer_id={{issuer_id}}
&issuer_key_id={{issuer_key_id}}

{
"credential": "{{credential}}",
"definition": "{{definition}}",
"proving_keys": "{{proving_keys}}"
}

{{
exports.proof = response.parsedBody.proof
}}

GET http://localhost:8000/zkp/verify
?proof={{proof}}
&issuer_pk={{issuer_pk}}
POST http://localhost:8000/zkp/verify
?issuer_pk={{issuer_pk}}
&verifying_keys={{verifying_keys}}
&definition={{definition}}
&issuer_id={{issuer_id}}
&issuer_key_id={{issuer_key_id}}
&issuer_key_id={{issuer_key_id}}

{{proof}}
25 changes: 15 additions & 10 deletions next-gen-signing-service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mod zkp_routes {
Engine, BASE64_URL_SAFE_NO_PAD,
};
use rand::rngs::OsRng;
use rocket::{get, serde::json::Json};
use rocket::{get, post, serde::json::Json};
use serde_json::{json, Value};

use crate::KeyPair;
Expand All @@ -100,7 +100,10 @@ mod zkp_routes {
Json(key_pair)
}

#[get("/issue?<data>&<issuer_pk>&<issuer_sk>&<issuer_id>&<issuer_key_id>&<expiry_months>")]
#[post(
"/issue?<issuer_pk>&<issuer_sk>&<issuer_id>&<issuer_key_id>&<expiry_months>",
data = "<data>"
)]
pub async fn issue(
data: String,
issuer_pk: String,
Expand Down Expand Up @@ -146,20 +149,19 @@ mod zkp_routes {
Json(circuits)
}

#[get(
"/present?<credential>&<definition>&<proving_keys>&<issuer_pk>&<issuer_id>&<issuer_key_id>"
)]
#[post("/present?<issuer_pk>&<issuer_id>&<issuer_key_id>", data = "<data>")]
pub async fn present(
credential: String,
definition: String,
proving_keys: String,
data: Json<Value>,
issuer_pk: String,
issuer_id: String,
issuer_key_id: String,
) -> Json<Value> {
let mut rng = OsRng;

println!("{credential}");
let credential = data["credential"].as_str().unwrap().to_string();
let definition = data["definition"].as_str().unwrap().to_string();
let proving_keys = data["proving_keys"].as_str().unwrap().to_string();

let credential = zkp::Credential::deserialize_encoded(&credential);

let reqs = {
Expand Down Expand Up @@ -190,7 +192,10 @@ mod zkp_routes {
}))
}

#[get("/verify?<proof>&<issuer_pk>&<verifying_keys>&<definition>&<issuer_id>&<issuer_key_id>")]
#[post(
"/verify?<issuer_pk>&<verifying_keys>&<definition>&<issuer_id>&<issuer_key_id>",
data = "<proof>"
)]
pub async fn verify(
proof: String,
issuer_pk: String,
Expand Down

0 comments on commit 6808ab7

Please sign in to comment.