From 6acf54e0d089ea9579d9fe038488b205164e8196 Mon Sep 17 00:00:00 2001 From: Heemale <1916737051@qq.com> Date: Sat, 7 Dec 2024 23:58:55 +0800 Subject: [PATCH] feat: finish task8. --- mover/Heemale/code/task8/call.sh | 1 + mover/Heemale/code/task8/contract/Move.toml | 37 ++ .../code/task8/contract/sources/task8.move | 101 +++++ .../task8/contract/tests/task8_tests.move | 56 +++ mover/Heemale/code/task8/ts/package.json | 23 + mover/Heemale/code/task8/ts/pnpm-lock.yaml | 420 ++++++++++++++++++ mover/Heemale/code/task8/ts/src/index.ts | 97 ++++ mover/Heemale/code/task8/ts/tsconfig.json | 111 +++++ mover/Heemale/readme.md | 2 +- 9 files changed, 847 insertions(+), 1 deletion(-) create mode 100644 mover/Heemale/code/task8/call.sh create mode 100644 mover/Heemale/code/task8/contract/Move.toml create mode 100644 mover/Heemale/code/task8/contract/sources/task8.move create mode 100644 mover/Heemale/code/task8/contract/tests/task8_tests.move create mode 100644 mover/Heemale/code/task8/ts/package.json create mode 100644 mover/Heemale/code/task8/ts/pnpm-lock.yaml create mode 100644 mover/Heemale/code/task8/ts/src/index.ts create mode 100644 mover/Heemale/code/task8/ts/tsconfig.json diff --git a/mover/Heemale/code/task8/call.sh b/mover/Heemale/code/task8/call.sh new file mode 100644 index 000000000..533997247 --- /dev/null +++ b/mover/Heemale/code/task8/call.sh @@ -0,0 +1 @@ +sui client call --package 0x097a3833b6b5c62ca6ad10f0509dffdadff7ce31e1d86e63e884a14860cedc0f --module lets_move --function get_flag --args " 31591919" "Heemale" 0x19e76ca504c5a5fa5e214a45fca6c058171ba333f6da897b82731094504d5ab9 0x8 \ No newline at end of file diff --git a/mover/Heemale/code/task8/contract/Move.toml b/mover/Heemale/code/task8/contract/Move.toml new file mode 100644 index 000000000..dc1475384 --- /dev/null +++ b/mover/Heemale/code/task8/contract/Move.toml @@ -0,0 +1,37 @@ +[package] +name = "task8" +edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] + +[dependencies] +Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" } + +# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`. +# Revision can be a branch, a tag, and a commit hash. +# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" } + +# For local dependencies use `local = path`. Path is relative to the package root +# Local = { local = "../path/to" } + +# To resolve a version conflict and force a specific version for dependency +# override use `override = true` +# Override = { local = "../conflicting/version", override = true } + +[addresses] +task8 = "0x0" + +# Named addresses will be accessible in Move as `@name`. They're also exported: +# for example, `std = "0x1"` is exported by the Standard Library. +# alice = "0xA11CE" + +[dev-dependencies] +# The dev-dependencies section allows overriding dependencies for `--test` and +# `--dev` modes. You can introduce test-only dependencies here. +# Local = { local = "../path/to/dev-build" } + +[dev-addresses] +# The dev-addresses section allows overwriting named addresses for the `--test` +# and `--dev` modes. +# alice = "0xB0B" + diff --git a/mover/Heemale/code/task8/contract/sources/task8.move b/mover/Heemale/code/task8/contract/sources/task8.move new file mode 100644 index 000000000..dfe40862e --- /dev/null +++ b/mover/Heemale/code/task8/contract/sources/task8.move @@ -0,0 +1,101 @@ +module task8::task8 { + use std::ascii::{String, string}; + use std::hash; + use sui::event; + use sui::bcs; + use sui::random; + use sui::random::Random; + use sui::transfer::share_object; + #[test_only] + use std::debug::print; + + const EPROOF: u64 = 0; + + public struct Flag has copy, drop { + sender: address, + flag: bool, + ture_num: u64, + github_id: String + } + + public struct Challenge has key { + id: UID, + str: String, + difficulity: u64, + ture_num: u64 + } + + fun init(ctx: &mut TxContext) { + let flag_str = Challenge { + id: object::new(ctx), + str: string(b"LetsMoveCTF"), + difficulity: 3, + ture_num: 0, + }; + share_object(flag_str); + } + + + entry fun get_flag( + proof: vector, + github_id: String, + challenge: &mut Challenge, + rand: &Random, + ctx: &mut TxContext + ) { + let mut full_proof: vector = vector::empty(); + vector::append(&mut full_proof, proof); + vector::append(&mut full_proof, tx_context::sender(ctx).to_bytes()); + vector::append(&mut full_proof, bcs::to_bytes(challenge)); + + let hash: vector = hash::sha3_256(full_proof); + + let mut prefix_sum: u32 = 0; + let mut i: u64 = 0; + while (i < challenge.difficulity) { + prefix_sum = prefix_sum + (*vector::borrow(&hash, i) as u32); + i = i + 1; + }; + + assert!(prefix_sum == 0, EPROOF); + + challenge.str = getRandomString(rand, ctx); + challenge.ture_num = challenge.ture_num + 1; + + event::emit(Flag { + sender: tx_context::sender(ctx), + flag: true, + ture_num: challenge.ture_num, + github_id + }); + } + + + fun getRandomString(rand: &Random, ctx: &mut TxContext): String { + let mut gen = random::new_generator(rand, ctx); + + let mut str_len = random::generate_u8_in_range(&mut gen, 4, 30); + + let mut rand: vector = b""; + while (str_len != 0) { + let rand_num = random::generate_u8_in_range(&mut gen, 34, 126); + vector::push_back(&mut rand, rand_num); + str_len = str_len - 1; + }; + + string(rand) + } + + #[test_only] + public fun init_for_testing(ctx: &mut TxContext) { + let id = object::new(ctx); + print(&object::uid_to_address(&id)); + let flag_str = Challenge { + id, + str: string(b"kR}Qd&*h]Ub?.ld}"), + difficulity: 3, + ture_num: 101, + }; + share_object(flag_str); + } +} diff --git a/mover/Heemale/code/task8/contract/tests/task8_tests.move b/mover/Heemale/code/task8/contract/tests/task8_tests.move new file mode 100644 index 000000000..4b99e3022 --- /dev/null +++ b/mover/Heemale/code/task8/contract/tests/task8_tests.move @@ -0,0 +1,56 @@ +#[test_only] +module task8::task8_tests { + use sui::test_scenario::{Self, ctx}; + use std::debug; + use std::bcs::{Self}; + use std::hash::{Self}; + use task8::task8::{Self, Challenge}; + + const ADMIN: address = @ADMIN; + + #[test] + fun process_for_testing() { + let mut scenario = test_scenario::begin(ADMIN); + + task8::init_for_testing(ctx(&mut scenario)); + test_scenario::next_tx(&mut scenario, ADMIN); + + let challenge = test_scenario::take_shared(&scenario); + + let mut proof = b"31591919"; + + let proof_data = bcs::to_bytes(&proof); + let admin_data = ADMIN.to_bytes(); + let challenge_data = bcs::to_bytes(&challenge); + debug::print(&proof_data); + debug::print(&admin_data); + debug::print(&challenge_data); + + let mut full_proof: vector = vector::empty(); + vector::append(&mut full_proof, proof_data); + vector::append(&mut full_proof, ADMIN.to_bytes()); + vector::append(&mut full_proof, challenge_data); + debug::print(&full_proof); + + let hash: vector = hash::sha3_256(full_proof); + debug::print(&hash); + + let mut prefix_sum: u32 = 0; + let mut i: u64 = 0; + while (i < 3) { + // 需要前三位是0 + prefix_sum = prefix_sum + (*vector::borrow(&hash, i) as u32); + debug::print(&prefix_sum); + i = i + 1; + }; + + if (prefix_sum == 0) { + debug::print(&1); + } else { + debug::print(&0); + }; + + test_scenario::return_shared(challenge); + test_scenario::end(scenario); + } +} diff --git a/mover/Heemale/code/task8/ts/package.json b/mover/Heemale/code/task8/ts/package.json new file mode 100644 index 000000000..05d9b76aa --- /dev/null +++ b/mover/Heemale/code/task8/ts/package.json @@ -0,0 +1,23 @@ +{ + "name": "task8-ts", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "npx ts-node -r tsconfig-paths/register ./src/index.ts" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@mysten/bcs": "^1.1.1", + "@mysten/sui": "^1.16.0", + "@types/node": "^22.10.1", + "js-sha3": "^0.9.3", + "ts-node": "^10.9.2", + "typescript": "^5.7.2" + }, + "devDependencies": { + "tsconfig-paths": "^4.2.0" + } +} diff --git a/mover/Heemale/code/task8/ts/pnpm-lock.yaml b/mover/Heemale/code/task8/ts/pnpm-lock.yaml new file mode 100644 index 000000000..973b507f3 --- /dev/null +++ b/mover/Heemale/code/task8/ts/pnpm-lock.yaml @@ -0,0 +1,420 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + '@mysten/bcs': + specifier: ^1.1.1 + version: 1.1.1 + '@mysten/sui': + specifier: ^1.16.0 + version: 1.16.0(typescript@5.7.2) + '@types/node': + specifier: ^22.10.1 + version: 22.10.1 + js-sha3: + specifier: ^0.9.3 + version: 0.9.3 + ts-node: + specifier: ^10.9.2 + version: 10.9.2(@types/node@22.10.1)(typescript@5.7.2) + typescript: + specifier: ^5.7.2 + version: 5.7.2 + devDependencies: + tsconfig-paths: + specifier: ^4.2.0 + version: 4.2.0 + +packages: + + '@0no-co/graphql.web@1.0.12': + resolution: {integrity: sha512-BTDjjsV/zSPy5fqItwm+KWUfh9CSe9tTtR6rCB72ddtkAxdcHbi4Ir4r/L1Et4lyxmL+i7Rb3m9sjLLi9tYrzA==} + peerDependencies: + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 + peerDependenciesMeta: + graphql: + optional: true + + '@0no-co/graphqlsp@1.12.16': + resolution: {integrity: sha512-B5pyYVH93Etv7xjT6IfB7QtMBdaaC07yjbhN6v8H7KgFStMkPvi+oWYBTibMFRMY89qwc9H8YixXg8SXDVgYWw==} + peerDependencies: + graphql: ^15.5.0 || ^16.0.0 || ^17.0.0 + typescript: ^5.0.0 + + '@cspotcode/source-map-support@0.8.1': + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + + '@gql.tada/cli-utils@1.6.3': + resolution: {integrity: sha512-jFFSY8OxYeBxdKi58UzeMXG1tdm4FVjXa8WHIi66Gzu9JWtCE6mqom3a8xkmSw+mVaybFW5EN2WXf1WztJVNyQ==} + peerDependencies: + '@0no-co/graphqlsp': ^1.12.13 + '@gql.tada/svelte-support': 1.0.1 + '@gql.tada/vue-support': 1.0.1 + graphql: ^15.5.0 || ^16.0.0 || ^17.0.0 + typescript: ^5.0.0 + peerDependenciesMeta: + '@gql.tada/svelte-support': + optional: true + '@gql.tada/vue-support': + optional: true + + '@gql.tada/internal@1.0.8': + resolution: {integrity: sha512-XYdxJhtHC5WtZfdDqtKjcQ4d7R1s0d1rnlSs3OcBEUbYiPoJJfZU7tWsVXuv047Z6msvmr4ompJ7eLSK5Km57g==} + peerDependencies: + graphql: ^15.5.0 || ^16.0.0 || ^17.0.0 + typescript: ^5.0.0 + + '@graphql-typed-document-node/core@3.2.0': + resolution: {integrity: sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==} + peerDependencies: + graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.5.0': + resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} + + '@jridgewell/trace-mapping@0.3.9': + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + + '@mysten/bcs@1.1.1': + resolution: {integrity: sha512-8X3IwmVfkwgHnNHR4izpi7f7aD0iVDU2B8p2KoIzCA9sCGcl9O2RnFDezHbNGgT+yBT+dKVDpTAczhnwZ6eUkQ==} + + '@mysten/sui@1.16.0': + resolution: {integrity: sha512-KI4richLtbq4RYbv5SmhWMIFD5BRW0tNOSGxZMLxjDBqBwkTqkQ4WBvmxjpbG/2WsLw0SCNrc7JYmoiaB58aLA==} + engines: {node: '>=18'} + + '@noble/curves@1.7.0': + resolution: {integrity: sha512-UTMhXK9SeDhFJVrHeUJ5uZlI6ajXg10O6Ddocf9S6GjbSBVZsJo88HzKwXznNfGpMTRDyJkqMjNDPYgf0qFWnw==} + engines: {node: ^14.21.3 || >=16} + + '@noble/hashes@1.6.0': + resolution: {integrity: sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ==} + engines: {node: ^14.21.3 || >=16} + + '@noble/hashes@1.6.1': + resolution: {integrity: sha512-pq5D8h10hHBjyqX+cfBm0i8JUXJ0UhczFc4r74zbuT9XgewFo2E3J1cOaGtdZynILNmQ685YWGzGE1Zv6io50w==} + engines: {node: ^14.21.3 || >=16} + + '@scure/base@1.2.1': + resolution: {integrity: sha512-DGmGtC8Tt63J5GfHgfl5CuAXh96VF/LD8K9Hr/Gv0J2lAoRGlPOMpqMpMbCTOoOJMZCk2Xt+DskdDyn6dEFdzQ==} + + '@scure/bip32@1.6.0': + resolution: {integrity: sha512-82q1QfklrUUdXJzjuRU7iG7D7XiFx5PHYVS0+oeNKhyDLT7WPqs6pBcM2W5ZdwOwKCwoE1Vy1se+DHjcXwCYnA==} + + '@scure/bip39@1.5.0': + resolution: {integrity: sha512-Dop+ASYhnrwm9+HA/HwXg7j2ZqM6yk2fyLWb5znexjctFY3+E+eU8cIWI0Pql0Qx4hPZCijlGq4OL71g+Uz30A==} + + '@suchipi/femver@1.0.0': + resolution: {integrity: sha512-bprE8+K5V+DPX7q2e2K57ImqNBdfGHDIWaGI5xHxZoxbKOuQZn4wzPiUxOAHnsUr3w3xHrWXwN7gnG/iIuEMIg==} + + '@tsconfig/node10@1.0.11': + resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} + + '@tsconfig/node12@1.0.11': + resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} + + '@tsconfig/node14@1.0.3': + resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} + + '@tsconfig/node16@1.0.4': + resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} + + '@types/node@22.10.1': + resolution: {integrity: sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==} + + acorn-walk@8.3.4: + resolution: {integrity: sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==} + engines: {node: '>=0.4.0'} + + acorn@8.14.0: + resolution: {integrity: sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==} + engines: {node: '>=0.4.0'} + hasBin: true + + arg@4.1.3: + resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} + + base-x@5.0.0: + resolution: {integrity: sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ==} + + bech32@2.0.0: + resolution: {integrity: sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==} + + bs58@6.0.0: + resolution: {integrity: sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==} + + create-require@1.1.1: + resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + + diff@4.0.2: + resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} + engines: {node: '>=0.3.1'} + + gql.tada@1.8.10: + resolution: {integrity: sha512-FrvSxgz838FYVPgZHGOSgbpOjhR+yq44rCzww3oOPJYi0OvBJjAgCiP6LEokZIYND2fUTXzQAyLgcvgw1yNP5A==} + hasBin: true + peerDependencies: + typescript: ^5.0.0 + + graphql@16.9.0: + resolution: {integrity: sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==} + engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} + + jose@5.9.6: + resolution: {integrity: sha512-AMlnetc9+CV9asI19zHmrgS/WYsWUwCn2R7RzlbJWD7F9eWYUTGyBmU9o6PxngtLGOiDGPRu+Uc4fhKzbpteZQ==} + + js-sha3@0.9.3: + resolution: {integrity: sha512-BcJPCQeLg6WjEx3FE591wVAevlli8lxsxm9/FzV4HXkV49TmBH38Yvrpce6fjbADGMKFrBMGTqrVz3qPIZ88Gg==} + + json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + + make-error@1.3.6: + resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + + minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + + poseidon-lite@0.2.1: + resolution: {integrity: sha512-xIr+G6HeYfOhCuswdqcFpSX47SPhm0EpisWJ6h7fHlWwaVIvH3dLnejpatrtw6Xc6HaLrpq05y7VRfvDmDGIog==} + + strip-bom@3.0.0: + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} + engines: {node: '>=4'} + + ts-node@10.9.2: + resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + + tsconfig-paths@4.2.0: + resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} + engines: {node: '>=6'} + + tweetnacl@1.0.3: + resolution: {integrity: sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==} + + typescript@5.7.2: + resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==} + engines: {node: '>=14.17'} + hasBin: true + + undici-types@6.20.0: + resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + + v8-compile-cache-lib@3.0.1: + resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} + + valibot@0.36.0: + resolution: {integrity: sha512-CjF1XN4sUce8sBK9TixrDqFM7RwNkuXdJu174/AwmQUB62QbCQADg5lLe8ldBalFgtj1uKj+pKwDJiNo4Mn+eQ==} + + yn@3.1.1: + resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} + engines: {node: '>=6'} + +snapshots: + + '@0no-co/graphql.web@1.0.12(graphql@16.9.0)': + optionalDependencies: + graphql: 16.9.0 + + '@0no-co/graphqlsp@1.12.16(graphql@16.9.0)(typescript@5.7.2)': + dependencies: + '@gql.tada/internal': 1.0.8(graphql@16.9.0)(typescript@5.7.2) + graphql: 16.9.0 + typescript: 5.7.2 + + '@cspotcode/source-map-support@0.8.1': + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + + '@gql.tada/cli-utils@1.6.3(@0no-co/graphqlsp@1.12.16(graphql@16.9.0)(typescript@5.7.2))(graphql@16.9.0)(typescript@5.7.2)': + dependencies: + '@0no-co/graphqlsp': 1.12.16(graphql@16.9.0)(typescript@5.7.2) + '@gql.tada/internal': 1.0.8(graphql@16.9.0)(typescript@5.7.2) + graphql: 16.9.0 + typescript: 5.7.2 + + '@gql.tada/internal@1.0.8(graphql@16.9.0)(typescript@5.7.2)': + dependencies: + '@0no-co/graphql.web': 1.0.12(graphql@16.9.0) + graphql: 16.9.0 + typescript: 5.7.2 + + '@graphql-typed-document-node/core@3.2.0(graphql@16.9.0)': + dependencies: + graphql: 16.9.0 + + '@jridgewell/resolve-uri@3.1.2': {} + + '@jridgewell/sourcemap-codec@1.5.0': {} + + '@jridgewell/trace-mapping@0.3.9': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.0 + + '@mysten/bcs@1.1.1': + dependencies: + bs58: 6.0.0 + + '@mysten/sui@1.16.0(typescript@5.7.2)': + dependencies: + '@graphql-typed-document-node/core': 3.2.0(graphql@16.9.0) + '@mysten/bcs': 1.1.1 + '@noble/curves': 1.7.0 + '@noble/hashes': 1.6.1 + '@scure/bip32': 1.6.0 + '@scure/bip39': 1.5.0 + '@suchipi/femver': 1.0.0 + bech32: 2.0.0 + gql.tada: 1.8.10(graphql@16.9.0)(typescript@5.7.2) + graphql: 16.9.0 + jose: 5.9.6 + poseidon-lite: 0.2.1 + tweetnacl: 1.0.3 + valibot: 0.36.0 + transitivePeerDependencies: + - '@gql.tada/svelte-support' + - '@gql.tada/vue-support' + - typescript + + '@noble/curves@1.7.0': + dependencies: + '@noble/hashes': 1.6.0 + + '@noble/hashes@1.6.0': {} + + '@noble/hashes@1.6.1': {} + + '@scure/base@1.2.1': {} + + '@scure/bip32@1.6.0': + dependencies: + '@noble/curves': 1.7.0 + '@noble/hashes': 1.6.1 + '@scure/base': 1.2.1 + + '@scure/bip39@1.5.0': + dependencies: + '@noble/hashes': 1.6.1 + '@scure/base': 1.2.1 + + '@suchipi/femver@1.0.0': {} + + '@tsconfig/node10@1.0.11': {} + + '@tsconfig/node12@1.0.11': {} + + '@tsconfig/node14@1.0.3': {} + + '@tsconfig/node16@1.0.4': {} + + '@types/node@22.10.1': + dependencies: + undici-types: 6.20.0 + + acorn-walk@8.3.4: + dependencies: + acorn: 8.14.0 + + acorn@8.14.0: {} + + arg@4.1.3: {} + + base-x@5.0.0: {} + + bech32@2.0.0: {} + + bs58@6.0.0: + dependencies: + base-x: 5.0.0 + + create-require@1.1.1: {} + + diff@4.0.2: {} + + gql.tada@1.8.10(graphql@16.9.0)(typescript@5.7.2): + dependencies: + '@0no-co/graphql.web': 1.0.12(graphql@16.9.0) + '@0no-co/graphqlsp': 1.12.16(graphql@16.9.0)(typescript@5.7.2) + '@gql.tada/cli-utils': 1.6.3(@0no-co/graphqlsp@1.12.16(graphql@16.9.0)(typescript@5.7.2))(graphql@16.9.0)(typescript@5.7.2) + '@gql.tada/internal': 1.0.8(graphql@16.9.0)(typescript@5.7.2) + typescript: 5.7.2 + transitivePeerDependencies: + - '@gql.tada/svelte-support' + - '@gql.tada/vue-support' + - graphql + + graphql@16.9.0: {} + + jose@5.9.6: {} + + js-sha3@0.9.3: {} + + json5@2.2.3: {} + + make-error@1.3.6: {} + + minimist@1.2.8: {} + + poseidon-lite@0.2.1: {} + + strip-bom@3.0.0: {} + + ts-node@10.9.2(@types/node@22.10.1)(typescript@5.7.2): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.11 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 22.10.1 + acorn: 8.14.0 + acorn-walk: 8.3.4 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.7.2 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + + tsconfig-paths@4.2.0: + dependencies: + json5: 2.2.3 + minimist: 1.2.8 + strip-bom: 3.0.0 + + tweetnacl@1.0.3: {} + + typescript@5.7.2: {} + + undici-types@6.20.0: {} + + v8-compile-cache-lib@3.0.1: {} + + valibot@0.36.0: {} + + yn@3.1.1: {} diff --git a/mover/Heemale/code/task8/ts/src/index.ts b/mover/Heemale/code/task8/ts/src/index.ts new file mode 100644 index 000000000..b7508ef69 --- /dev/null +++ b/mover/Heemale/code/task8/ts/src/index.ts @@ -0,0 +1,97 @@ +import {sha3_256} from 'js-sha3'; +import {bcs, fromHex, toHex} from "@mysten/bcs"; +import { Transaction } from "@mysten/sui/transactions"; + +const mergeUint8Arrays = (...arrays: Uint8Array[]): Uint8Array => { + // 计算合并后数组的总长度 + const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0); + + // 创建一个新的 Uint8Array 用来存放合并后的字节数组 + const mergedArray = new Uint8Array(totalLength); + + // 将每个数组依次拷贝到 mergedArray 中 + let offset = 0; + for (const array of arrays) { + mergedArray.set(array, offset); + offset += array.length; + } + + return mergedArray; +}; + +const Address = bcs.bytes(32).transform({ + // To change the input type, you need to provide a type definition for the input + input: (val: string) => fromHex(val), + output: (val) => toHex(val), +}); + +const UID = bcs.fixedArray(32, bcs.u8()).transform({ + input: (id: string) => fromHex(id), + output: (id) => toHex(Uint8Array.from(id)), +}); + +const Challenge = bcs.struct('Challenge', { + id: UID, + str: bcs.string(), + difficulity: bcs.u64(), + ture_num: bcs.u64(), +}); + +const challengeBytes = Challenge.serialize({ + id: '0x34401905bebdf8c04f3cd5f04f442a39372c8dc321c29edfb4f9cb30b23ab96', + str: "kR}Qd&*h]Ub?.ld}", + difficulity: 3, + ture_num: 101, +}).toBytes(); + +export const main = async () => { + let proof = 31591919; + const sender = ''; + + let is_success = false; + while (!is_success) { + const proofBytes = bcs.string().serialize(proof.toString()).toBytes(); + const senderBytes = Address.serialize(sender).toBytes(); + const fullProof = mergeUint8Arrays( + proofBytes, + senderBytes, + challengeBytes, + ); + const hash = sha3_256(fullProof); + const hashBytes = fromHex(hash); + + let prefixSum = 0; + let i = 0; + while (i < 3) { + prefixSum = prefixSum + hashBytes[i]; + i = i + 1; + } + if (prefixSum == 0) { + console.log(`Found proof: ${proof} with hash: ${hash}`); + is_success = true; + } else { + proof++; + } + } +}; + +export const getFlag = () => { + const tx = new Transaction(); + tx.moveCall({ + typeArguments: [], + target: '0x097a3833b6b5c62ca6ad10f0509dffdadff7ce31e1d86e63e884a14860cedc0f::lets_move::get_flag', + arguments: [ + tx.pure.vector('u8', [ + 8, 51, 49, 53, 57, + 49, 57, 49, 57 + ]), + tx.pure.string('Heemale'), + tx.object('0x19e76ca504c5a5fa5e214a45fca6c058171ba333f6da897b82731094504d5ab9'), + tx.object('0x8'), + ], + }); +} + +main().catch(({message}) => { + console.error({message}); +}); \ No newline at end of file diff --git a/mover/Heemale/code/task8/ts/tsconfig.json b/mover/Heemale/code/task8/ts/tsconfig.json new file mode 100644 index 000000000..c9c555d96 --- /dev/null +++ b/mover/Heemale/code/task8/ts/tsconfig.json @@ -0,0 +1,111 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/mover/Heemale/readme.md b/mover/Heemale/readme.md index 3febe0d0f..480d19d18 100644 --- a/mover/Heemale/readme.md +++ b/mover/Heemale/readme.md @@ -46,4 +46,4 @@ - [x] call hash: BbJbuXZViPNqvnVmvz7UvfKtmx1qHddU24UfdxY7m2Ld ## 08 Move CTF Lets Move -- [] call hash: \ No newline at end of file +- [x] call hash: e6Yoxz8o8FgLYtLJJ1XV86T4R1uU9eYPFAHi7gTNJmU \ No newline at end of file