Skip to content

Commit a019ba0

Browse files
committed
Translate from big-endian hex string to little-endian RawValue
1 parent c5791f4 commit a019ba0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/lang/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ mod tests {
9999
fn test_e2e_simple_request() -> Result<(), LangError> {
100100
let input = r#"
101101
REQUEST(
102-
ValueOf(?ConstPod["my_val"], 0x0000000000000001000000000000000000000000000000000000000000000000)
102+
ValueOf(?ConstPod["my_val"], 0x0000000000000000000000000000000000000000000000000000000000000001)
103103
Lt(?GovPod["dob"], ?ConstPod["my_val"])
104104
)
105105
"#;

src/lang/processor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ fn parse_pest_string_literal(pair: &Pair<Rule>) -> Result<String, ProcessorError
759759
Ok(result)
760760
}
761761

762+
// Translates a big-endian hex string to a little-endian RawValue
762763
fn parse_hex_str_to_raw_value(hex_str: &str) -> Result<middleware::RawValue, ProcessorError> {
763764
let mut v = [F::ZERO; VALUE_SIZE];
764765
let value_range = 0..VALUE_SIZE;
@@ -768,7 +769,7 @@ fn parse_hex_str_to_raw_value(hex_str: &str) -> Result<middleware::RawValue, Pro
768769
let hex_part = &hex_str[start_idx..end_idx];
769770

770771
let u64_val = u64::from_str_radix(hex_part, 16).unwrap();
771-
v[i] = F::from_canonical_u64(u64_val);
772+
v[VALUE_SIZE - i - 1] = F::from_canonical_u64(u64_val);
772773
}
773774
Ok(middleware::RawValue(v))
774775
}

0 commit comments

Comments
 (0)