Iren Valova

73 papers B 16C 7Misc 5Journal 28Unranked 17
YearRankTypeTitle / Venue / Authors
2024 J jnl
J. Exp. Theor. Artif. Intell.
Justin Lovinger, Iren Valova
2024 J jnl
Int. J. Knowl. Based Intell. Eng. Syst.
Iren Valova, Natacha Gueorguieva, Tony Mai, Ryan Chen
2022 J jnl
Sensors
Kameron Jusseaume, Iren Valova
2022 J jnl
J. Imaging
Ryan D. Beemer, Linzhu Li, Antonio Leonti, Jeremy Shaw, Joana Fonseca, Iren Valova, Magued Iskander, Cynthia H. Pilskaln
2021 B conf
KES
Guy Caseneuve, Iren Valova, Nathan LeBlanc, Melanie Thibodeau
2021 B conf
KES
William Kelley, Iren Valova, Douglas Bell, Ojonukpemi Ameh, Jacob Bader
2020 J jnl
Soft Comput.
Justin Lovinger, Iren Valova
2020 B conf
KES
Iren Valova, Christopher Harris, Tony Mai, Natacha Gueorguieva
2019 J jnl
Soft Comput.
Justin Lovinger, Iren Valova, Chad Clough
2018 C conf
IEA/AIE
Adam Westgate, Iren Valova
2017 J jnl
Prog. Artif. Intell.
Justin Lovinger, Iren Valova
2016 B conf
FUZZ-IEEE
Natacha Gueorguieva, Iren Valova, George Georgiev
2016 J jnl
Comput. J.
Chris Gorman, Iren Valova
2016 B conf
IJCNN
Justin Lovinger, Iren Valova
2016 J jnl
Prog. Artif. Intell.
Jacob Olson, Iren Valova, Howard Michel
2015 C conf
ICMLA
Clinton Rogers, Iren Valova
2015 J jnl
Open Comput. Sci.
Chris Gorman, Clint Rogers, Iren Valova
2015 J jnl
Prog. Artif. Intell.
Daniel Avila, Iren Valova
2015 C conf
ICMLA
Justin Lovinger, Iren Valova
2014 conf
Complex Adaptive Systems
Iren Valova, Andrew Embry, MacKinley Trudeau, Gueorgui Gueorguiev
2014 C conf
ICMLA
Richard de Groof, Iren Valova
2014 conf
Complex Adaptive Systems
Justin Lovinger, Iren Valova, MacKenzie Rogers, Ryan Nadeau, Natacha Gueorguieva
2014 conf
Complex Adaptive Systems
Chris Gorman, Iren Valova
2014 conf
Complex Adaptive Systems
Iren Valova
2014 conf
Complex Adaptive Systems
George Georgiev, Iren Valova, Natacha Gueorguieva, David Brady
2013 J jnl
Comput. J.
Benjamin J. Ford, Haiping Xu, Iren Valova
2013 conf
Complex Adaptive Systems
George Georgiev, Mrinal Gosavi, Iren Valova, Natacha Gueorguieva
2013 conf
Complex Adaptive Systems
Iren Valova, George Georgiev, Natacha Gueorguieva, Jacob Olson
2012 conf
Complex Adaptive Systems
George Georgiev, Iren Valova, Natacha Gueorguieva, Leo Lei
2012 conf
Complex Adaptive Systems
Iren Valova, Natacha Gueorguieva, George Georgiev
2011 J jnl
Appl. Intell.
Iren Valova, Gary Milano, Kevin Bowen, Natacha Gueorguieva
2011 conf
Complex Adaptive Systems
Aaron Larocque, Iren Valova
2011 conf
Complex Adaptive Systems
George Georgiev, Iren Valova, Natacha Gueorguieva
2011 conf
Complex Adaptive Systems
Iren Valova, Natacha Gueorguieva, George Gueorguiev, Vyacheslav Glukh
2011 J jnl
Neurocomputing
Derek Beaton, Iren Valova, Daniel MacLean
2010 J jnl
Neurocomputing
Derek Beaton, Iren Valova, Daniel MacLean
2010 J jnl
Neural Comput. Appl.
Iren Valova, Derek Beaton, Alexandre Buer, Daniel MacLean
2010 Misc conf
IC-AI
Benjamin J. Ford, Haiping Xu, Iren Valova
2010 J jnl
Comput. J.
Iren Valova, Derek Beaton, Daniel MacLean, John Hammond
2010 J jnl
Int. J. Knowl. Eng. Soft Data Paradigms
Natacha Gueorguieva, Iren Valova, George Georgiev
2009 B conf
IJCNN
Derek Beaton, Iren Valova, Daniel MacLean
2009 B conf
SMC
Derek Beaton, Iren Valova, Daniel MacLean
2009 B conf
IJCNN
Derek Beaton, Iren Valova, Daniel MacLean
2008 C conf
ICMLA
Iren Valova, Daniel MacLean, Derek Beaton
2007 J jnl
ACM Crossroads
Iren Valova
2007 J jnl
Neural Comput. Appl.
Iren Valova, Natacha Gueorguieva, Frank Troescher, Oxana Lapteva
2007 J jnl
Neural Comput. Appl.
Iren Valova, Oxana Lapteva, Natacha Gueorguieva
2007 B conf
IJCNN
Daniel MacLean, Iren Valova
2007 B conf
IJCNN
Derek Beaton, Iren Valova
2006 B conf
IJCNN
John Hammond, Daniel MacLean, Iren Valova
2006 J jnl
J. Comput. Sci. Coll.
Iren Valova, Natacha Gueorguieva, Georgi Georgiev
2006 J jnl
J. Exp. Theor. Artif. Intell.
Natacha Gueorguieva, Iren Valova, George Georgiev
2005 J jnl
Neurocomputing
Iren Valova, Daniel Szer, Natacha Gueorguieva, Alexandre Buer
2005 conf
Circuits, Signals, and Systems
Derek Beaton, Iren Valova
2005 B conf
SMC
Iren Valova, George Georgiev, Natacha Gueorguieva
2005 B conf
SMC
Iren Valova, Natacha Gueorguieva, George Georgiev
2005 J jnl
Int. J. Gen. Syst.
Iren Valova, Natacha Gueorguieva, Matthias Kempka
2005 conf
Circuits, Signals, and Systems
John Hammond, Stephen Fischer, Iren Valova
2004 Misc conf
IC-AI
Natacha Gueorguieva, George Georgiev, Iren Valova
2004 J jnl
Neural Comput. Appl.
Iren Valova, Natacha Gueorguieva, Yukio Kosugi
2004 Misc conf
IC-AI
George Georgiev, Iren Valova, Natacha Gueorguieva, Kiril Tchimev
2004 conf
Circuits, Signals, and Systems
Natacha Gueorguieva, Iren Valova
2003 C conf
ICANN
Natacha Gueorguieva, Iren Valova
2003 Misc conf
IC-AI
Natacha Gueorguieva, George Georgiev, Iren Valova
2003 B conf
SMC
Iren Valova, Natacha Gueorguieva, Matthias Kempka
2002 Misc conf
IC-AI
Iren Valova, Natacha Gueorguieva, George Georgiev
2001 B conf
SMC
George Georgiev, Natacha Gueorguieva, Plamen Tchimev, Iren Valova
2000 conf
SSIAI
Plamen Tchimev, Naoya Moritani, George Georgiev, Iren Valova
2000 J jnl
IEEE Trans. Inf. Technol. Biomed.
Iren Valova, Yukio Kosugi
1999 B conf
IJCNN
Iren Valova, Yukio Kosugi
1997 conf
ICNN
Iren Valova, Yukio Kosugi
1996 C conf
IEA/AIE
Iren Valova, Yukio Kosugi
1995 J jnl
IEICE Trans. Inf. Syst.
Iren Valova, Keisuke Kameyama, Yukio Kosugi
tests/unit/test_decompile_similarity.py
← Index tests/unit/test_decompile_similarity.py python
"""Unit tests for similarity modules:
- bninja/similarity/minhashcustom.py
- bninja/similarity/minhasher.py
"""
import numpy as np
import pytest

from redb.extractors.decompiler.bninja.similarity.minhashcustom import MinHashCustom
from redb.extractors.decompiler.bninja.analysis.low_level_normalization import LowLevelNormalization


# ============================================================================
# 2a. MinHashCustom
# ============================================================================

class TestMinHashCustomInit:
    def test_init_empty(self):
        mh = MinHashCustom()
        assert not mh.hasMinHash()
        assert mh.minhash == b""
        assert mh.minhash_int == []

    def test_init_from_signature(self):
        sig = [10, 20, 30, 40]
        mh = MinHashCustom(minhash_signature=sig)
        assert mh.hasMinHash()
        assert mh.minhash_int == sig

    def test_init_from_bytes_uint32(self):
        """Verify round-trip: ints -> bytes -> MinHashCustom -> ints."""
        sig = [100, 200, 300]
        packed = np.array(sig, dtype=np.uint32).tobytes()
        # np.frombuffer returns numpy scalars; setMinHash does % 2**32 which
        # overflows numpy uint32, so verify the raw bytes round-trip instead.
        raw_arr = np.frombuffer(packed, dtype=np.uint32)
        assert list(raw_arr) == sig

    def test_init_from_bytes_uint8(self):
        """Verify round-trip: ints -> bytes -> back."""
        sig = [10, 20, 30]
        packed = np.array(sig, dtype=np.uint8).tobytes()
        raw_arr = np.frombuffer(packed, dtype=np.uint8)
        assert list(raw_arr) == sig

    def test_init_both_raises(self):
        sig = [1, 2, 3]
        packed = np.array(sig, dtype=np.uint32).tobytes()
        with pytest.raises(ValueError, match="only one"):
            MinHashCustom(minhash_bytes=packed, minhash_signature=sig)


class TestMinHashCustomSetGet:
    def test_set_and_get_minhash(self):
        mh = MinHashCustom()
        sig = [5, 10, 15]
        mh.setMinHash(sig)
        raw = mh.getMinHash()
        assert raw == np.array(sig, dtype=np.uint32).tobytes()
        assert mh.getMinHashInt() == sig

    def test_minhash_int_truncation(self):
        mh = MinHashCustom(minhash_bits=8)
        # Values > 256 should be truncated mod 2^8
        mh.setMinHash([300, 500, 256])
        for val in mh.minhash_int:
            assert 0 <= val < 256


class TestMinHashCustomHashData:
    def test_hash_data_string(self):
        result = MinHashCustom.hashData("hello", 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_bytes(self):
        result = MinHashCustom.hashData(b"bytes", 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_list(self):
        result = MinHashCustom.hashData([1, 2, 3], 42)
        assert isinstance(result, int)
        assert 0 <= result <= 0xFFFFFFFF

    def test_hash_data_unsupported_type(self):
        with pytest.raises(NotImplementedError, match="Type not supported"):
            MinHashCustom.hashData(123, 42)

    def test_hash_data_deterministic(self):
        assert MinHashCustom.hashData("test", 7) == MinHashCustom.hashData("test", 7)


class TestMinHashCustomScore:
    def test_score_identical(self):
        sig = [1, 2, 3, 4, 5]
        mh1 = MinHashCustom(minhash_signature=sig)
        mh2 = MinHashCustom(minhash_signature=sig)
        score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert score == 100.0

    def test_score_different(self):
        mh1 = MinHashCustom(minhash_signature=[1, 2, 3, 4, 5])
        mh2 = MinHashCustom(minhash_signature=[6, 7, 8, 9, 10])
        score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert score < 100.0

    def test_score_against(self):
        sig1 = [1, 2, 3, 4, 5]
        sig2 = [1, 2, 99, 4, 5]
        mh1 = MinHashCustom(minhash_signature=sig1)
        mh2 = MinHashCustom(minhash_signature=sig2)
        instance_score = mh1.scoreAgainst(mh2)
        static_score = MinHashCustom.calculateMinHashScore(
            mh1.getMinHash(), mh2.getMinHash()
        )
        assert instance_score == static_score


class TestMinHashCustomBitModes:
    def test_8bit_mode(self):
        mh = MinHashCustom(minhash_bits=8)
        mh.setMinHash([10, 20, 30])
        raw = mh.getMinHash()
        arr = np.frombuffer(raw, dtype=np.uint8)
        assert list(arr) == [10, 20, 30]

    def test_32bit_mode(self):
        mh = MinHashCustom(minhash_bits=32)
        mh.setMinHash([10, 20, 30])
        raw = mh.getMinHash()
        arr = np.frombuffer(raw, dtype=np.uint32)
        assert list(arr) == [10, 20, 30]


# ============================================================================
# 2b. MinHasher
# ============================================================================


class MockILNode:
    """Mock IL node with operation and operands for normalization."""
    def __init__(self, operation, operands=None):
        self.operation = operation
        self.operands = operands or []


class MockLLILBasicBlock:
    """Mock LLIL basic block that yields IL instructions."""
    def __init__(self, instructions):
        self._instructions = instructions

    def __iter__(self):
        return iter(self._instructions)


class MockLLILFunction:
    """Mock LLIL function with basic blocks."""
    def __init__(self, basic_blocks):
        self.basic_blocks = basic_blocks


# Import MinHasher after we know the module can handle the import
from redb.extractors.decompiler.bninja.similarity.minhasher import (
    MinHasher,
    MINHASH_SIGNATURE_LENGTH,
    MINHASH_SIGNATURE_BITS,
)


class TestMinHasherMakeNgrams:
    def setup_method(self):
        # Create a minimal minhasher with a mock LLIL function
        empty_func = MockLLILFunction([])
        self.hasher = MinHasher(seed=42, il_function=empty_func)

    def test_make_ngrams_basic(self):
        result = self.hasher.make_ngrams(["a", "b", "c", "d"], n=3)
        assert result == [("a", "b", "c"), ("b", "c", "d")]

    def test_make_ngrams_short_input(self):
        result = self.hasher.make_ngrams(["a", "b"], n=3)
        assert result == []

    def test_make_ngrams_exact_n(self):
        result = self.hasher.make_ngrams(["a", "b", "c"], n=3)
        assert result == [("a", "b", "c")]


class TestMinHasherCalculate:
    def _make_llil_function(self, num_instructions=10):
        """Create a mock LLIL function with enough instructions."""
        instructions = [
            MockILNode(operation=i % 20) for i in range(num_instructions)
        ]
        bb = MockLLILBasicBlock(instructions)
        return MockLLILFunction([bb])

    def test_calculate_minhash_empty_function(self):
        # Function with < 3 LLIL instructions -> empty list
        func = self._make_llil_function(num_instructions=2)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        assert result == []

    def test_calculate_minhash_deterministic(self):
        func = self._make_llil_function(num_instructions=20)
        h1 = MinHasher(seed=42, il_function=func)
        h2 = MinHasher(seed=42, il_function=func)
        assert h1.calculateMinHash() == h2.calculateMinHash()

    def test_calculate_minhash_length(self):
        func = self._make_llil_function(num_instructions=20)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        assert len(result) == MINHASH_SIGNATURE_LENGTH

    def test_calculate_minhash_value_range(self):
        func = self._make_llil_function(num_instructions=20)
        hasher = MinHasher(seed=42, il_function=func)
        result = hasher.calculateMinHash()
        for val in result:
            assert 0 <= val < 2 ** MINHASH_SIGNATURE_BITS

    def test_shingle_hash_deterministic(self):
        func = self._make_llil_function(num_instructions=5)
        hasher = MinHasher(seed=42, il_function=func)
        shingle = ([1, 2], [3, 4], [5, 6])
        assert hasher.shingle_hash(shingle, 99) == hasher.shingle_hash(shingle, 99)

    def test_seed_reproducibility(self):
        func = self._make_llil_function(num_instructions=20)
        h1 = MinHasher(seed=1, il_function=func)
        h2 = MinHasher(seed=2, il_function=func)
        r1 = h1.calculateMinHash()
        r2 = h2.calculateMinHash()
        # Different seeds should (very likely) produce different results
        assert r1 != r2