Skip to content

Commit

Permalink
chore: less strict zkvm indirections
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Jul 25, 2024
1 parent b22f273 commit b51cfd6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions core/src/bytes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl<F: Field> ByteChip<F> {
/// Creates the preprocessed byte trace and event map.
///
/// This function returns a pair `(trace, map)`, where:
/// - `trace` is a matrix containing all possible byte operations.
/// - `trace` is a matrix containing all possible byte operations.
/// - `map` is a map from a byte lookup to the corresponding row it appears in the table and
/// the index of the result in the array of multiplicities.
/// the index of the result in the array of multiplicities.
pub fn trace_and_map(
shard: u32,
) -> (RowMajorMatrix<F>, BTreeMap<ByteLookupEvent, (usize, usize)>) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/runtime/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use super::{ExecutionRecord, MemoryReadRecord, MemoryWriteRecord};
/// The syscall number is a 32-bit integer, with the following layout (in little-endian format)
/// - The first byte is the syscall id.
/// - The second byte is 0/1 depending on whether the syscall has a separate table. This is used
/// in the CPU table to determine whether to lookup the syscall using the syscall interaction.
/// in the CPU table to determine whether to lookup the syscall using the syscall interaction.
/// - The third byte is the number of additional cycles the syscall uses.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EnumIter, Ord, PartialOrd)]
#[allow(non_camel_case_types)]
Expand Down
4 changes: 3 additions & 1 deletion zkvm/entrypoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ p3-field = { workspace = true, optional = true }
bincode = { workspace = true }
cfg-if = { workspace = true }
getrandom = { workspace = true, features = ["custom"] }
libm = { workspace = true, optional = true }
k256 = { workspace = true, features = ["ecdsa", "std", "bits"] }
lazy_static = { workspace = true }
once_cell = { workspace = true }
rand = { workspace = true }
sha2 = { workspace = true }

[features]
default = []
default = ["libm"]
libm = ["dep:libm"]
verify = ["dep:sphinx-primitives", "dep:p3-baby-bear", "dep:p3-field", "sphinx-precompiles/verify"]


Expand Down
2 changes: 1 addition & 1 deletion zkvm/precompiles/src/bls12_381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use anyhow::Result;
/// Decompresses a compressed public key using bls12381_g1_decompress precompile.
pub fn decompress_pubkey(compressed_key: &[u8; 48]) -> Result<[u8; 96]> {
cfg_if::cfg_if! {
if #[cfg(all(target_os = "zkvm", target_vendor = "succinct"))] {
if #[cfg(target_os = "zkvm")] {
let mut decompressed_key = [0u8; 96];
decompressed_key[..48].copy_from_slice(compressed_key);
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions zkvm/precompiles/src/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl CurveOperations for Secp256k1Operations {
/// Decompresses a compressed public key using secp256k1_decompress precompile.
pub fn decompress_pubkey(compressed_key: &[u8; 33]) -> Result<[u8; 65]> {
cfg_if::cfg_if! {
if #[cfg(all(target_os = "zkvm", target_vendor = "succinct"))] {
if #[cfg(target_os = "zkvm")] {
let mut decompressed_key: [u8; 64] = [0; 64];
decompressed_key[..32].copy_from_slice(&compressed_key[1..]);
let is_odd = match compressed_key[0] {
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn verify_signature(
s_inverse: Option<&Scalar>,
) -> bool {
cfg_if::cfg_if! {
if #[cfg(all(target_os = "zkvm", target_vendor = "succinct"))] {
if #[cfg(target_os = "zkvm")] {
let pubkey_x = Scalar::from_repr(bits2field::<Secp256k1>(&pubkey[1..33]).unwrap()).unwrap();
let pubkey_y = Scalar::from_repr(bits2field::<Secp256k1>(&pubkey[33..]).unwrap()).unwrap();

Expand Down

0 comments on commit b51cfd6

Please sign in to comment.