Skip to content

Commit

Permalink
Zkgm changes move (#3507)
Browse files Browse the repository at this point in the history
  • Loading branch information
Caglankaan authored Jan 14, 2025
2 parents b71f73f + 62677dd commit 4580146
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 254 deletions.
2 changes: 1 addition & 1 deletion move/move-ibc/sources/mpt_verifier.move
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ module ibc::mpt_verifier {
let slot = x"0000000000000000000000000000000000000000000000000000000000000000";
let key = keccak256(slot);

let (is_exists, value) = verify_trie_value(&proofChain, &key, storage_root);
let (is_exists, _value) = verify_trie_value(&proofChain, &key, storage_root);
assert!(is_exists, 1001);
}

Expand Down
33 changes: 33 additions & 0 deletions move/ucs03-relay/sources/eth_abi.move
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,39 @@ module ucs03::ethabi {
vector::append(buf, padding);
}

public fun encode_bytes32(buf: &mut vector<u8>, bytes: &vector<u8>) {
let len = vector::length(bytes);
vector::append(buf, *bytes);
// Calculate padding to align to 32 bytes
let padding_len = (32 - (len % 32)) % 32;
let padding = vector::empty<u8>();
let i = 0;
while (i < padding_len) {
vector::push_back(&mut padding, 0);
i = i + 1;
};
// Append the padding
vector::append(buf, padding);
}

public fun decode_bytes32(buf: &vector<u8>, index: &mut u64): vector<u8> {
// Decode the length of the bytes array
// let len_bytes = vector::slice(buf, *index, *index + 32); // Extract the next 32 bytes for length
// vector::reverse(&mut len_bytes); // Convert to big-endian format
// let len: u64 = (from_bcs::to_u256(len_bytes) as u64); // Convert the length bytes to u64
// *index = *index + 32; // Move the index forward after reading the length
// Decode the actual bytes
let len: u64 = 32;
let byte_data = vector::slice(buf, *index, *index + len); // Extract the bytes of the given length
*index = *index + len; // Move the index forward after reading the byte data

// Skip padding to align to 32-byte boundary
let padding_len = (32 - (len % 32)) % 32;
*index = *index + padding_len; // Adjust the index to skip the padding

byte_data // Return the decoded bytes
}

public fun decode_bytes(buf: &vector<u8>, index: &mut u64): vector<u8> {
// Decode the length of the bytes array
let len_bytes = vector::slice(buf, *index, *index + 32); // Extract the next 32 bytes for length
Expand Down
1 change: 0 additions & 1 deletion move/ucs03-relay/sources/helper.move
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module ucs03::zkgm_helpers {
use ibc::packet::Packet;
use std::string::{Self, String};
use std::copyable_any;

struct RecvPacketParamsZKGM has copy, drop, store {
Expand Down
Loading

0 comments on commit 4580146

Please sign in to comment.