Skip to content

Commit

Permalink
fix: replace bytearray.compare with '==' operator
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhbx-smartosc committed Apr 16, 2024
1 parent 9b84cf9 commit 487a2b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
Expand Up @@ -25,7 +25,7 @@ fn get_exist_proof_for_key(
expect comm_proof != proofs.null_commitment_proof()
when comm_proof.proof is {
CommitmentProof_Exist { exist } ->
if bytearray.compare(exist.key, key) == Equal {
if exist.key == key {
exist
} else {
proofs.null_existance_proof()
Expand Down
35 changes: 17 additions & 18 deletions cardano/lib/ibc/core/ics-023-vector-commitments/ics23/proof.ak
Expand Up @@ -27,12 +27,12 @@ pub fn verify_existence_proof(
key: ByteArray,
value: ByteArray,
) -> Bool {
expect check_against_spec(p, spec)
expect bytearray.compare(key, p.key) == Equal
expect bytearray.compare(value, p.value) == Equal
let calc = calculate_exist_internal(p, spec)
expect bytearray.compare(root, calc) == Equal
True
and {
check_against_spec(p, spec),
key == p.key,
value == p.value,
root == calculate_exist_internal(p, spec),
}
}

/// Verify does all checks to ensure the proof has valid non-existence proofs,
Expand Down Expand Up @@ -270,10 +270,7 @@ pub fn is_left_neighbor(
expect Some(t_left) = accum.3rd
expect Some(t_right) = accum.4th
if
bytearray.compare(t_left.prefix, t_right.prefix) == Equal && bytearray.compare(
t_left.suffix,
t_right.suffix,
) == Equal{
t_left.prefix == t_right.prefix && t_left.suffix == t_right.suffix{

if list.length(accum.1st) < 2 && list.length(accum.2nd) < 2 {
(
Expand Down Expand Up @@ -384,10 +381,11 @@ fn left_branches_are_empty(spec: InnerSpec, op: InnerOp) -> Bool {
let idx = get_position(spec.child_order, i)
let from = actual_prefix + idx * spec.child_size
if
!(bytearray.compare(
spec.empty_child,
bytearray.slice(op.prefix, from, from + spec.child_size - 1),
) == Equal){
!(spec.empty_child == bytearray.slice(
op.prefix,
from,
from + spec.child_size - 1,
)){

(False, True)
} else {
Expand Down Expand Up @@ -421,10 +419,11 @@ fn right_branches_are_empty(spec: InnerSpec, op: InnerOp) -> Bool {
let idx = get_position(spec.child_order, i)
let from = idx * spec.child_size
if
!(bytearray.compare(
spec.empty_child,
bytearray.slice(op.suffix, from, from + spec.child_size - 1),
) == Equal){
!(spec.empty_child == bytearray.slice(
op.suffix,
from,
from + spec.child_size - 1,
)){

(False, True)
} else {
Expand Down

0 comments on commit 487a2b3

Please sign in to comment.