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

Guardian enclave signs off on a vtBurnOffset during provisioning #54

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 7 additions & 2 deletions src/client/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ mod guardian;
mod secure_signer;
mod validator;

use ethers::types::U256;

use crate::client::traits::{GuardianClientTrait, ValidatorClientTrait};

use crate::eth2::eth_types::GENESIS_FORK_VERSION;
Expand Down Expand Up @@ -67,7 +69,8 @@ async fn registration_flow_succeeds() {
mrenclave,
mrsigner,
verify_remote_attestation,
validator_index: 0
validator_index: 0,
vt_burn_offset: U256::from_dec_str("1000000000000000000").unwrap(),
};

// Guardian validates they received custody
Expand Down Expand Up @@ -130,8 +133,10 @@ async fn test_cli_keygen_verified_by_guardians() {
mrenclave: "".to_string(),
mrsigner: "".to_string(),
verify_remote_attestation,
validator_index: 0
validator_index: 0,
vt_burn_offset: U256::from_dec_str("1000").unwrap(),
};
println!("req: {:?}", req.vt_burn_offset);

// Guardian validates they received custody
let resp3: crate::enclave::types::ValidateCustodyResponse =
Expand Down
7 changes: 5 additions & 2 deletions src/enclave/guardian/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub async fn verify_and_sign_custody_received(
&request.keygen_payload,
&guardian_enclave_sk,
&request.validator_index,
request.vt_burn_offset.clone(),
)
.await?;

Expand Down Expand Up @@ -196,12 +197,14 @@ async fn approve_custody(
keygen_payload: &crate::enclave::types::BlsKeygenPayload,
guardian_enclave_sk: &EthSecretKey,
validator_index: &ValidatorIndex,
vt_burn_offset: U256,
) -> Result<String> {
let mut hasher = sha3::Keccak256::new();

// validatorIndex, pubKey, withdrawalCredentials, signature, depositDataRoot
// validatorIndex, vtBurnOffset, pubKey, withdrawalCredentials, signature, depositDataRoot
let msg = ethers::abi::encode(&[
ethers::abi::Token::Uint(U256::from(validator_index.clone())),
ethers::abi::Token::Uint(vt_burn_offset),
ethers::abi::Token::Bytes(
keygen_payload
.public_key_set()?
Expand Down Expand Up @@ -468,7 +471,7 @@ mod tests {
let (resp, g_sks, _mre, _mrs) = setup();

for g_sk in g_sks {
assert!(approve_custody(&resp, &g_sk, &0).await.is_ok());
assert!(approve_custody(&resp, &g_sk, &0, U256::from_dec_str("1000").unwrap()).await.is_ok());
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/enclave/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::eth2::eth_types::ValidatorIndex;
use anyhow::{bail, Result};
use blsttc::{PublicKey as BlsPublicKey, PublicKeySet};
use ecies::{PublicKey as EthPublicKey, SecretKey as EthSecretKey};
use ethers::types::U256;
use serde::ser::SerializeSeq;
use serde::{Deserialize, Serialize};
use tree_hash::TreeHash;
Expand Down Expand Up @@ -138,7 +139,8 @@ pub struct ValidateCustodyRequest {
pub mrenclave: String,
pub mrsigner: String,
pub verify_remote_attestation: bool,
pub validator_index: ValidatorIndex
pub validator_index: ValidatorIndex,
pub vt_burn_offset: U256
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down
Loading