Skip to content

Extend Kangaroo search interval from 128-bit to 256-bit#2

Merged
komyaka merged 2 commits intomasterfrom
copilot/increase-search-interval-256-bit
Feb 27, 2026
Merged

Extend Kangaroo search interval from 128-bit to 256-bit#2
komyaka merged 2 commits intomasterfrom
copilot/increase-search-interval-256-bit

Conversation

Copy link

Copilot AI commented Feb 26, 2026

The search interval was limited to ~125-128 bits due to int128_t (16-byte) fields in ENTRY, DP, and network structures. This replaces them with a new int256_t (32-byte) type, enabling ranges up to 2^256 and rejecting anything larger.

Core type change

// Before
typedef union int128_s { uint8_t i8[16]; uint64_t i64[2]; } int128_t;

// After — added alongside int128_t
typedef union int256_s { uint8_t i8[32]; uint32_t i32[8]; uint64_t i64[4]; } int256_t;

ENTRY grows from 32 → 64 bytes. Sign bit moves to bit255, kangaroo-type bit to bit254 of d.

Structural changes

  • HashTable.h/cppint256_t x/d in ENTRY; Convert() uses all 4 words; CalcDistAndType() decodes bit255/254; compare() / duplicate-check use 4 words; all I/O sizes updated via sizeof(ENTRY)
  • Kangaroo.hDP struct uses int256_t; new magic numbers HEADW/HEADK/HEADKS = 0xFA6B8001/2/3 (invalidates old 128-bit work files); function signatures updated
  • Kangaroo.cppjumpBit cap raised 128 → 255; InitRange() rejects rangePower > 256
  • Backup.cpp / Network.cpp — all vector<int128_t>vector<int256_t>; kangaroo packet sizes ×32; checksum and DP copy use all 4 words
  • GPU/GPUEngine.hKSIZE 10 → 12, ITEM_SIZE 56 → 72 (kIdx shifts from offset 12 → 16 in output buffer)
  • GPU/GPUMath.hjD[NB_JUMP][4]; new Add256 macro; LoadKangaroos/StoreKangaroos updated to slots 8-11 for distance, lastJump slot 10 → 12; OutputDP emits 8 distance words
  • GPU/GPUCompute.hdist[GPU_GRP_SIZE][4]; Add128Add256
  • GPU/GPUEngine.cuSetParams copies 4 words for jD; SetKangaroos/GetKangaroos/SetKangaroo use slots 8-11 for distance; output parsing reads 4 distance words
  • Timer.h/cpp — fixed pre-existing build failure (missing #include <cstdint>)
Original prompt

🎯 ЗАДАНИЕ ДЛЯ ИИ-АГЕНТОВ: Increase search interval from 125-bit to 256-bit

⚠️ ОБЯЗАТЕЛЬНО: При выполнении этого задания следуй инструкциям из .github/copilot-instructions.md (GUARDRAILS — Universal Copilot Instructions). Все принципы, протоколы STATUS.md, routing rules, write-zones, и gates из этого файла имеют высший приоритет. Все агенты принимают участие в разработке согласно этим правилам.

Контекст задачи

Репозиторий komyaka/Kangaroo — форк JeanLucPons/Kangaroo (Pollard's Kangaroo для SECP256K1).
Текущее ограничение: search interval ≤ 125-128 bit из-за использования int128_t в структурах данных.
Цель: расширить до полных 256 bit.

Язык/стек

  • C++ (81.3%), C (11.8%), CUDA (6%), Makefile (0.9%)
  • Build: make (CPU), make gpu=1 ccap=XX (GPU)
  • Test: ./Kangaroo puzzle32.txt, ./Kangaroo -check
  • Нет unit-test фреймворка — тестирование через built-in -check и puzzle solving

📚 ОБЯЗАТЕЛЬНЫЙ RESEARCH

Изучить до начала работы:

🏗️ DESIGN — Архитектура изменений

  • Этап А: int128_t → int256_t (структуры ENTRY/DP/Network, все массивы/операции), переносить diff из Kangaroo-256
  • Этап B: Оптимизации PR Major optimizations for 135-150 bit range support JeanLucPons/Kangaroo#148 (NB_JUMP=64, NB_RUN=128, HASH_SIZE_BIT=26, power-of-2 jumps, Gaudry-Schost 1.686, Ampere/Ada GPU, Makefile +O3)
  • Все тесты — через puzzle32.txt, -check, 200-bit, 256/257-bit input

ACCEPTANCE CRITERIA

  • make/make gpu=1 проходят
  • puzzle32.txt решается
  • -check работает CPU/GPU
  • Нет int128_t в финальном коде
  • rangePower > 128 поддерживается, >256 — ошибка

ℹ️ ТЕХНИЧЕСКИЙ СПЕК И ССЫЛКИ НА КОД

— см. полный план публикации (см. комментарий выше и описание PR)

РАСПРЕДЕЛЕНИЕ ЧЕКЛИСТОВ (write-zone!):

  • Architect → STATUS.md: SCOPE, DESIGN
  • QA → STATUS.md: TEST PLAN
  • Coder → .cpp/.h/.cu + Makefile/STATUS.md
  • Performance → STATUS.md: PERF REVIEW
  • Auditor → STATUS.md: AUDIT

⚠️ НЕ переписывать SECP256K1/ директорию. Вся логика — только DP/ENTRY/Network/GPU structs. GLV не подключать. Если несовместимость work-файлов — ввести новый magic number.

Edge cases for QA

  • 256-bit DP, старые work-файлы, network mode, 2^255 distance и пр.

📎 ОБЯЗАТЕЛЬНО сравнивать каждую строку с ZenulAbidin/Kangaroo-256 и PR JeanLucPons#148, если возникают расхождения — брать версию Kangaroo-256.


ПРИСТУПИТЬ! Все дальнейшие действия и статусы фиксировать в STATUS.md по GUARDRAILS-инструкциям.

Custom agent used: orchestrator
Master coordinator. Always active. Manages phases, gates, REDO cycles, and agent routing via trigger rules. Never writes implementation code.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: komyaka <34284729+komyaka@users.noreply.github.com>
Copilot AI changed the title [WIP] Increase search interval from 125-bit to 256-bit Extend Kangaroo search interval from 128-bit to 256-bit Feb 26, 2026
@komyaka komyaka marked this pull request as ready for review February 27, 2026 05:13
@komyaka komyaka merged commit 1b7665f into master Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants