Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed May 14, 2024
1 parent 518bea3 commit d20334f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{
stark::{ShardProof, StarkVerifyingKey},
utils::{BabyBearPoseidon2, Buffer},
};
use k256::sha2::{Digest, Sha256};
use serde::{de::DeserializeOwned, Deserialize, Serialize};

/// Standard input for the prover.
Expand Down Expand Up @@ -127,6 +128,20 @@ impl SP1PublicValues {
pub fn write_slice(&mut self, slice: &[u8]) {
self.buffer.write_slice(slice);
}

/// Hash the public values to get a Bn254 value.
pub fn hash_public_values(&self) -> Bn254Fr {

Check failure on line 133 in core/src/io.rs

View workflow job for this annotation

GitHub Actions / Groth16

cannot find type `Bn254Fr` in this scope

Check failure on line 133 in core/src/io.rs

View workflow job for this annotation

GitHub Actions / Formatting & Clippy

cannot find type `Bn254Fr` in this scope

Check failure on line 133 in core/src/io.rs

View workflow job for this annotation

GitHub Actions / Test (ARM)

cannot find type `Bn254Fr` in this scope

Check failure on line 133 in core/src/io.rs

View workflow job for this annotation

GitHub Actions / Test (x86-64)

cannot find type `Bn254Fr` in this scope
let mut hasher = Sha256::new();
hasher.update(self.buffer.data.as_slice());
let hash_result = hasher.finalize();

let mut hash = hash_result.to_vec();

// Mask the top 3 bits.
hash[0] &= 0b00111111;

BabyBearPoseidon2::from_bytes(hasher.finalize().as_slice()).unwrap()

Check failure on line 143 in core/src/io.rs

View workflow job for this annotation

GitHub Actions / Groth16

no function or associated item named `from_bytes` found for struct `baby_bear_poseidon2::BabyBearPoseidon2` in the current scope

Check failure on line 143 in core/src/io.rs

View workflow job for this annotation

GitHub Actions / Formatting & Clippy

no function or associated item named `from_bytes` found for struct `utils::prove::baby_bear_poseidon2::BabyBearPoseidon2` in the current scope

Check failure on line 143 in core/src/io.rs

View workflow job for this annotation

GitHub Actions / Test (ARM)

no function or associated item named `from_bytes` found for struct `baby_bear_poseidon2::BabyBearPoseidon2` in the current scope

Check failure on line 143 in core/src/io.rs

View workflow job for this annotation

GitHub Actions / Test (x86-64)

no function or associated item named `from_bytes` found for struct `baby_bear_poseidon2::BabyBearPoseidon2` in the current scope
}
}

impl AsRef<[u8]> for SP1PublicValues {
Expand Down

0 comments on commit d20334f

Please sign in to comment.