Skip to content

Crypto engines cpp - #2

Merged
apayne185 merged 16 commits into
mainfrom
crypto-engines-cpp
Jun 24, 2026
Merged

Crypto engines cpp#2
apayne185 merged 16 commits into
mainfrom
crypto-engines-cpp

Conversation

@apayne185

Copy link
Copy Markdown
Owner

No description provided.

apayne185 and others added 16 commits June 22, 2026 14:05
Repository restructured from coursework layout to a coherent two-layer toolkit:

C++ layer (cpp/):
- sha256/: SHA-256 from FIPS PUB 180-4, no external dependencies
- pow/: parallel prefix brute-forcer using std::thread + std::atomic across all cores
- collision/: birthday attack on djb2 32-bit hash, single and parallel modes
- bitcoin/: raw P2PKH tx builder — Base58Check, varint, SIGHASH_ALL preimage, DER layout

TypeScript/Solidity layer:
- contracts/ and test/ flattened from implementation/exercise-{1,2}/
- Python Tkinter clients removed; replaced with ethers.js CLI scripts (scripts/)
- Unified hardhat.config.ts and package.json at repo root
- deploy-vending.ts, deploy-ticket.ts, vending.ts, tickets.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Delete remaining tracked files under implementation/ (old exercise READMEs
  referencing Python/Tkinter, and typechain artifacts from ex-1). These were
  left over from the restructure and contradicted the project's current stack.
- Rename ganache container from ganache-ex1 to ganache.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two parallel jobs:
- cpp: cmake Release build, then smoke-tests pow (single prefix), collision,
  and tx_builder to verify all three engines run end-to-end
- solidity: npm ci, hardhat build, hardhat test against the in-memory EDR
  network (no Ganache required in CI)

Also accepts optional prefix args in pow so CI can run a short target
without waiting for the full 32s 'decade' search.
hardhat run does not forward process.argv to scripts, so the previous
vending.ts / tickets.ts CLIs silently ignored every command argument.

Hardhat tasks receive typed, named options and are the idiomatic way to
expose contract interactions as CLI commands:

  npx hardhat vending list --network ganache
  npx hardhat vending buy --product-id 1 --qty 2 --network ganache
  npx hardhat ticket list --network ganache
  npx hardhat ticket buy --event-id 1 --network ganache
  npx hardhat ticket list-resale --ticket-id 1 --price 0.03 --network ganache

Deploy scripts (deploy-vending.ts, deploy-ticket.ts) are unchanged —
they do not need arguments so hardhat run is fine for those.
Six test vectors (empty, "abc", 448-bit, "bitcoin", 55-byte, 56-byte)
verify the implementation against authoritative Python hashlib values.
CMakeLists.txt wires the test into ctest; CI runs ctest --output-on-failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix 'evemts'/'evetns'/'intrecations' typos in Solidity comments.
Add tsconfig.json targeting ES2022/Node16 for the TS task files.
Exclude the leftover untracked implementation/ directory via .gitignore.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- README layout table: scripts/vending.ts + tickets.ts → tasks/vending.ts
  + ticket.ts; test files corrected to .ts extension
- README CLI examples: npm run vending/tickets → npx hardhat vending/ticket
  with correct --option-name flags matching the Hardhat 3 task definitions
- VendingMachine.sol: bump pragma from ^0.8.20 to ^0.8.24 to match
  TicketOffice.sol and the hardhat.config.ts compiler version
- package.json: add engines field declaring Node >=20 requirement

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Hardhat 3 dropped support for Node 20; bump CI setup-node and the
engines field to >=22.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rename getEvent() → getEventById() in TicketOffice.sol: ethers.js
BaseContract exposes its own getEvent(nameOrTopic) method which
shadowed the Solidity function, causing 'key.format is not a function'.

Replace hre.network.connect() with hre.network.getOrCreate() across
all task and test files to clear the Hardhat 3 deprecation warning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main edited the old exercise-1 README; our branch already removed the
entire implementation/ directory as part of the homework → portfolio
cleanup. Keeping the deletion.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@apayne185
apayne185 merged commit 377c74e into main Jun 24, 2026
4 checks passed
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.

1 participant