-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
381 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.