Skip to content

Commit

Permalink
job
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Apr 19, 2024
1 parent 8a2f765 commit 3b9c67b
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions crates/common/src/job.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use libsecp256k1::{PublicKey, Signature};
use libsecp256k1::{curve::Scalar, sign, PublicKey, SecretKey, Signature};
use std::{
fmt::Display,
hash::{DefaultHasher, Hash, Hasher},
Expand All @@ -18,6 +18,24 @@ pub struct Job {
pub cpu_air_prover_config: Vec<u8>, // needed for proving
}

impl Default for Job {
fn default() -> Self {
let secret_key = &SecretKey::default();
let public_key = PublicKey::from_secret_key(secret_key);
let (signature, _recovery_id) =
sign(&libsecp256k1::Message(Scalar([0, 0, 0, 0, 0, 0, 0, 0])), secret_key);
Self {
reward: 0,
num_of_steps: 0,
cairo_pie: vec![1, 2, 3],
public_key,
signature,
cpu_air_params: vec![1, 2, 3],
cpu_air_prover_config: vec![1, 2, 3],
}
}
}

impl Hash for Job {
fn hash<H: Hasher>(&self, state: &mut H) {
self.reward.hash(state);
Expand All @@ -34,12 +52,12 @@ impl Display for Job {
}
}

impl Job {
pub fn serialize_job(&self) -> Vec<u8> {
bincode::serialize(self).unwrap()
}
// impl Job {
// pub fn serialize_job(&self) -> Vec<u8> {
// bincode::serialize(self).unwrap()
// }

pub fn deserialize_job(serialized_job: &[u8]) -> Self {
bincode::deserialize(serialized_job).unwrap()
}
}
// pub fn deserialize_job(serialized_job: &[u8]) -> Self {
// bincode::deserialize(serialized_job).unwrap()
// }
// }

0 comments on commit 3b9c67b

Please sign in to comment.