Skip to content

Commit

Permalink
task7
Browse files Browse the repository at this point in the history
  • Loading branch information
dop0 committed Dec 6, 2024
1 parent 15819e6 commit 3b38c05
Show file tree
Hide file tree
Showing 6 changed files with 381 additions and 3 deletions.
24 changes: 24 additions & 0 deletions mover/sahab328/code/task7/get_flag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { getFullnodeUrl, SuiClient } from "@mysten/sui/client";
import { bcs, toHex } from '@mysten/bcs';
import { createHash } from "crypto";


async function get_flag(github_id: string) {
const flag_str_id = "0xc8dcd54baa7724177593a9f70598a09ae6a4286f996542e058f248209db08147";
const client = new SuiClient({ url: getFullnodeUrl("testnet") });

const flag_str_obj = await client.getObject({
id: flag_str_id,
options: {
showBcs: true,
showContent: true,
}
});
const content = flag_str_obj.data!.content as any;
const flag_str = content.fields["str"] as string;
const flag_str_bcs_bytes = bcs.string().serialize(flag_str).toBytes();
const github_id_bytes = new TextEncoder().encode(github_id);
const buffer = Buffer.concat([flag_str_bcs_bytes, github_id_bytes]);
const flag = createHash('sha3-256').update(buffer).digest();
console.log(toHex(new Uint8Array(flag)));
}
15 changes: 15 additions & 0 deletions mover/sahab328/code/task7/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "task7",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@mysten/sui": "^1.16.0"
}
}
230 changes: 230 additions & 0 deletions mover/sahab328/code/task7/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3b38c05

Please sign in to comment.