-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
initial pepper service for keyless accounts #12158
Conversation
⏱️ 24h 48m total CI duration on this PR
🚨 2 jobs on the last run were significantly faster/slower than expected
|
oidb/pepper/service/src/lib.rs
Outdated
pub type KeyID = String; | ||
|
||
/// The core processing logic of this pepper service. | ||
pub async fn process(request: PepperRequest) -> anyhow::Result<String> { |
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.
should there be any data validation (e.g. max/expected sizes) throughout this function? there's a lot of deserialization and parsing with user-controlled input which could potentially be expensive.
oidb/pepper/service/src/vuf_keys.rs
Outdated
@@ -16,7 +17,7 @@ pub static VUF_SCHEME0_SK: Lazy<ark_bls12_381::Fr> = Lazy::new(|| { | |||
let vuf_key_hex = | |||
std::env::var("VRF_KEY_HEX").expect("VRF_KEY_HEX is required for pepper calculation"); | |||
let sk_bytes = hex::decode(vuf_key_hex).expect("vrf_key_hex should be a valid hex string"); | |||
ark_bls12_381::Fr::deserialize_compressed(sk_bytes.as_slice()).unwrap() | |||
ark_bls12_381::Fr::from_be_bytes_mod_order(sk_bytes.as_slice()) |
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.
@heliuchuan let's not use *_mod_order
as it accepts any byte string, ircc.
Reverse the byte string and use deserialize_compressed
instead.
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.
nvm, what's from envvar will be a 256-bit seed and we need to derive sk from the seed.
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.
The dev_setup.sh changes look good to me
@@ -892,6 +893,9 @@ while getopts "btoprvydaPJh:i:n" arg; do | |||
n) | |||
OPT_DIR="true" | |||
;; | |||
k) |
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.
Could you also update usage()
to describe what the -k
flag is used for?
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.
The current dev_setup change is actually a hack... (I'm surprised you didn't hate it lol, because below it's even trying to --break-system-packages
)
I could not figure out how to use existing dockerfile templates for pepper service, and the current dockerfile for pepper service is quick and dirty.
I will figure out the right way to docker build and revert this part. But if you are ok with the hack, i guess i can keep using the hack until i figure out?
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 think it's fine if this is just a quick hack
How is this image going to be built? If we want to use the GitHub workflows to automate this we probably want to do something similar to the other Dockerfiles for caching
oidb/pepper/common/src/jwt.rs
Outdated
.map_err(|e| anyhow!("jwt decoding error: {}", e)) | ||
} | ||
|
||
static DUMMY_DECODING_KEY: Lazy<DecodingKey> = Lazy::new(|| DecodingKey::from_secret(&[])); |
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.
What is this? Can you add a comment? Is this the JWK? If so, why are you calling it a decoding key?
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.
they are required by the jsonwebtoken library to parse jwt without verifing sig (its default behavior is to parse and verify both in one call, but we don't want it).
It's JWK, but the library call it DecodingKey...
I found another library jwt with API that makes more sense, but yet to replace this.
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 see. No worries, just move the statics inside the function if that's the only place where they are used?
Plus, in the end we will need to unify the JWT logic so that we can use the same calls in both the prover service, pepper service and the Rust authenticator.
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.
fixed
oidb/pepper/common/src/lib.rs
Outdated
} | ||
|
||
#[derive(Debug, Default, Deserialize, Serialize)] | ||
pub struct EncryptionPubKey { |
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.
Is this even used anywhere?
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.
no, since we are not doing encryption at the moment.
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.
Will it be used?
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.
now i remember this can be gone, given EphemeralPublicKey
in main.
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.
fixed
CODEOWNERS
Outdated
@@ -98,6 +98,11 @@ | |||
# Owners for the network and all its subdirectories. | |||
/network/ @gregnazario @joshlind @brianolson | |||
|
|||
# Owners for the scripts | |||
/scripts/ @aptos-labs/devinfra |
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.
Let's make this @aptos-labs/prod-eng.
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.
@aluon said to use devinfra
. Should I change it to prod-eng
or add prod-eng
next to it?
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.
@aluon do we need a different team here ?
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.
Also @aluon, there seems to be an error regarding the devinfra
team not existing.
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.
Let's set this to aptos-labs/prod-eng
for now. I was thinking we could create a devinfra
team so we can add other folks but I'm not sure why it's erroring
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.
Ok.
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.
@zjma this was not resolved. Can you change @aptos-labs/devinfra
to @aptos-labs/prod-eng
?
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 didn't add this diff... why is it even in this PR?
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.
anyway fixed
oidb/pepper/service/src/about.rs
Outdated
git_commit: String, | ||
} | ||
|
||
pub static ABOUT_JSON: Lazy<String> = Lazy::new(|| { |
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.
Can you add comments? What is this?
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.
this is for showing some metadata at /about
.
e.g. the commit SHA1
oidb/pepper/service/src/lib.rs
Outdated
let (pepper, vuf_proof) = vuf::scheme0::Scheme0::eval(&VUF_SCHEME0_SK, &input_bytes)?; | ||
ensure!(vuf_proof.is_empty(), "internal proof error"); | ||
let pepper_hexlified = hex::encode(pepper); | ||
Ok(pepper_hexlified) |
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.
Why are you not returning the proof here? @heliuchuan will want to verify the proof in the SDK.
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.
because the proof is empty?
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.
For BLS, sure, but when you change the scheme, will you put the proof inside pepper_hexlified
?
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.
in that case, pepper should be bcs::to_bytes(some_struct_that_include_output_and_proof)
?
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.
Sure, but the problem with this PR is that we do not have clean separation between structs and their serialization.
e.g., why is PepperResponse
containing hex strings? It should have Vec<u8>
's and the serialization code (BCS, JSON) will decide the format.
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.
fixed
oidb/pepper/service/src/vuf_keys.rs
Outdated
use once_cell::sync::Lazy; | ||
use ark_ff::PrimeField; | ||
|
||
pub struct VufScheme0Sk { |
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.
This is not even used...
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.
fixed
oidb/pepper/common/src/lib.rs
Outdated
} | ||
|
||
/// The response to `PepperRequestV0`, which contains the calculated pepper (hexlified) or a processing error. | ||
#[derive(Debug, Deserialize, Serialize)] |
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.
Please add comments and explain these fields.
Not sure why there are two things here.
There is just one pepper.
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.
fixed
f119ad1
to
f340408
Compare
@@ -384,6 +385,8 @@ aptos-package-builder = { path = "aptos-move/package-builder" } | |||
aptos-peer-monitoring-service-client = { path = "peer-monitoring-service/client" } | |||
aptos-peer-monitoring-service-server = { path = "peer-monitoring-service/server" } | |||
aptos-peer-monitoring-service-types = { path = "peer-monitoring-service/types" } | |||
aptos-keyless-pepper-common = { path = "keyless/pepper/common" } |
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.
We will likely move most of this into crates/aptos-crypto
and types
over time.
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.
Stamping assuming you've addressed the request/response formatting issues. Don't have time to look right now.
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.
stamp request response lgtm
v0 sennddddd
note eventually i think we should use axum over hyper
keyless/pepper/service/src/main.rs
Outdated
.header(ACCESS_CONTROL_ALLOW_ORIGIN, origin) | ||
.header(ACCESS_CONTROL_ALLOW_CREDENTIALS, "true") | ||
.header(ACCESS_CONTROL_ALLOW_METHODS, "GET, POST, OPTIONS") | ||
.header(ACCESS_CONTROL_ALLOW_HEADERS, "Content-Type, Authorization") |
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.
let's set this to "*" for now
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.
fixed
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
Description
TODOs
oidb/pepper
tooidb/pepper-service
oidb/
tokeyless/
Test Plan