Skip to content
Draft
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
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.

2 changes: 2 additions & 0 deletions arm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ risc0-zkvm = { version = "3.0.3", features = ["std", "unstable"], default-featur
serde = { version = "1.0.197", default-features = false }
serde_with = "3.14.1"
k256 = { version = "=0.13.3", features = ["arithmetic", "serde", "expose-field", "std", "ecdsa", "hash2curve"], default-features = false }
sha2 = { version = "0.10", optional = true }
sha3 = { version = "0.10", optional = true }
rand = "0.8"
bincode = "1.3.3"
Expand All @@ -26,6 +27,7 @@ slab = "0.4.11"
[features]
default = ["transaction", "prove"]
transaction = ["compliance_circuit", "dep:sha3"]
solana = ["transaction", "dep:sha2"]
compliance_circuit = []
prove = ["risc0-zkvm/prove"]
bonsai = ["risc0-zkvm/bonsai"]
Expand Down
16 changes: 11 additions & 5 deletions arm/src/delta_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ use k256::{
use serde::{Deserialize, Serialize};

use crate::error::ArmError;
use sha3::{Digest, Keccak256};

// Conditionally use SHA-256 for Solana, Keccak-256 for EVM
#[cfg(feature = "solana")]
use sha2::{Digest, Sha256 as HashFunction};

#[cfg(not(feature = "solana"))]
use sha3::{Digest, Keccak256 as HashFunction};

#[derive(Clone, Debug)]
pub struct DeltaProof {
Expand All @@ -25,8 +31,8 @@ pub struct DeltaInstance {

impl DeltaProof {
pub fn prove(message: &[u8], witness: &DeltaWitness) -> Result<DeltaProof, ArmError> {
// Hash the message using Keccak256
let mut digest = Keccak256::new();
// Hash the message (SHA-256 for Solana, Keccak-256 for EVM)
let mut digest = HashFunction::new();
digest.update(message);

// Sign the hashed message using RFC6979
Expand Down Expand Up @@ -60,8 +66,8 @@ impl DeltaProof {
return Err(ArmError::InvalidDeltaProof);
}

// Hash the message using Keccak256
let mut digest = Keccak256::new();
// Hash the message (SHA-256 for Solana, Keccak-256 for EVM)
let mut digest = HashFunction::new();
digest.update(message);

// Verify the signature
Expand Down