master
six 2024-04-16 12:53:32 +04:00
commit 71799cb1c5
17 changed files with 1713 additions and 0 deletions

View File

@ -0,0 +1,8 @@
An investigator found the following words on a paper. He guessed what this is but something is wrong here. There are 10 DOT coins on this account, you can get it if you are the fastest.
jealous snow smoke talent tenant when todler ghost twist kingdom twice apology
Flag is the correct seed words chain together without spaces, for example: CCTF{jealoussnowsmoketalenttenantwhentodlerghosttwistkingdomtwiceapology}
//Type: substrate, cryptography, coding, logic
//Author: six

View File

@ -0,0 +1,28 @@
Welcome to a journey of the mystical realm of numbers and secrets hidden within the numerical fabric of the universe.
Instructions: In this adventure, you will dive into the depths of ancient wisdom and uncover the meanings behind numbers. Find the correlation between the numbers and solve the entire sequence. The participant who uncovers the hidden message quickest accomplishes the task. Each number holds a unique significance.
## The Quest
14 15 35 22 32 35 37
13 14 9 40 8 22
63 21 14 1 18 22 14
42 18 45 18 16 12
24 28 42 34 26 38
14 37 31 58 18 27
38 20 30 12 40 29
13 10 26 45 18 26 17
Flag: CCTF{word1word2} from which word1 is the first word of the last sentence and word2 is the first word after the comma (,). When you send to the flag API, send the word1word2 part in lower case.
Have fun!
//Type: Pythagorean numerology
//Author: csirke

View File

@ -0,0 +1,6 @@
This is another quick challenge to quickly grab a little amount of ETH from a 1337 address. But is it more important than solving the hard challenges?
Flag: you are going to find it, I know it.
// Type: javascript, reversing
// Author: six

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Play time</title>
</head>
<body>
<script>
var _0x3764dc=_0x821e;(function(_0x3f39d1,_0x55c516){var _0x518841=_0x821e,_0x286348=_0x3f39d1();while(!![]){try{var _0x87ff4b=parseInt(_0x518841(0x112))/0x1*(parseInt(_0x518841(0x119))/0x2)+-parseInt(_0x518841(0x10f))/0x3+-parseInt(_0x518841(0x11d))/0x4*(-parseInt(_0x518841(0x11a))/0x5)+parseInt(_0x518841(0x117))/0x6+parseInt(_0x518841(0x11b))/0x7+parseInt(_0x518841(0x116))/0x8+parseInt(_0x518841(0x115))/0x9*(-parseInt(_0x518841(0x110))/0xa);if(_0x87ff4b===_0x55c516)break;else _0x286348['push'](_0x286348['shift']());}catch(_0x246402){_0x286348['push'](_0x286348['shift']());}}}(_0x1210,0xeff80));function abcd(){var _0x2a5483=_0x821e;console[_0x2a5483(0x10e)]('You\x20have\x20found\x20an\x20easy\x20challenge.');}abcd();function wa(_0x51122e){var _0x3f12e0=_0x821e,_0x4b9ead=new Date()[_0x3f12e0(0x11c)](),_0xbf6257=_0x4b9ead;while(_0xbf6257<_0x4b9ead+_0x51122e){_0xbf6257=new Date()[_0x3f12e0(0x11c)]();}}function _0x1210(){var _0x3dcc4f=['getTime','6472636LogbDR','log','4663476RaTFxA','10ecLxaU','DJmZmI3ZmFkZmNjNzEyODc5Y2FmZWEzNjM0ZmRlODczYTM3ZDc1YQo','476822LhEYRN','1jg1ZDExM2Zl23VhMTllOT2wMWIwMjE2O','Mjg1ZDExM2ZlNTVhMTllOTYwMWIwMjE2O','40257837kdLJGq','15061432mbebSt','4657542HZENlV','You\x20just\x20need\x20to\x20play\x20around\x20a\x20bit.','6Nompsh','5GJrhME','9120552byuzES'];_0x1210=function(){return _0x3dcc4f;};return _0x1210();}var kjg34=_0x3764dc(0x114),jy4fzxa=_0x3764dc(0x111),kig34=_0x3764dc(0x113),jgi35fd='_Ot8j6_yOb75LjpXYHPsAJbNa-DRerOM';function _0x821e(_0x554310,_0x5362a6){var _0x12100a=_0x1210();return _0x821e=function(_0x821e51,_0x53489c){_0x821e51=_0x821e51-0x10e;var _0x5df805=_0x12100a[_0x821e51];return _0x5df805;},_0x821e(_0x554310,_0x5362a6);}function makeRangeIterator(_0x2b3389=0x0,_0x5efe3f=Infinity,_0x5057ec=0x1){let _0x32a8f4=_0x2b3389,_0x2f41af=0x0;const _0x40e5fe={'next'(){let _0x1f1b88;if(_0x32a8f4<_0x5efe3f)return _0x1f1b88={'value':_0x32a8f4,'done':![]},_0x32a8f4+=_0x5057ec,_0x2f41af++,_0x1f1b88;return{'value':_0x2f41af,'done':!![]};}};return _0x40e5fe;}function efg(){var _0xa4a79b=_0x3764dc;wa(0x2f5b),console[_0xa4a79b(0x10e)](_0xa4a79b(0x118)),atob(kjg34+jy4fzxa+'='),wa(0xdf);}efg();
</script>
</body>
</html>

View File

@ -0,0 +1,35 @@
Here's a home-brewed stream cipher:
```
uint64_t next(uint64_t x)
{
return (x << 12) ^ ((x >> 12) + 1);
}
typedef uint8_t (*hash_func_t)(uint64_t x);
hash_func_t hash;
uint64_t state;
void initialize(hash_func_t h, uint64_t iv)
{
hash = h;
state = iv;
}
uint8_t get_byte(void)
{
uint8_t b = hash(state);
state = next(state);
return b;
}
```
It's extra secure because even some of its code is secret.
Here's a (ASCII) message, containing the flag, encrypted with this method: the ciphertext is the plaintext xor-ed with a stream of bytes generated using these functions, starting with a secret, well-chosen hash function and a random initialization vector.
Flag: the format as commonly used, eg. CCTF{flagitself}
//Type: Cryptography
//Author: SI

Binary file not shown.

View File

@ -0,0 +1,6 @@
Can you get to the end of the questions? nc 209.250.246.26 4242
Flag: you get it in standard format.
//Type: AI, Substrate
//Author: six

View File

@ -0,0 +1,10 @@
An enthusiastic engineer is working on a new Substrate service and thought it is a good idea to implement his version of Schnorr in python3. If you look at the implementation, you may quickly find this might not be the best idea. He event shared to of his signatures!
Flag: you need to find the private key and send it to the flag API, eg CCTF{0o012341234123412341234}
Public Key: 106630695568759948071813539699675569395286201160397132670116903597838061377847847991076869032655669834285193320675031435028157222028259835741013483990415884458140958575374990044275391023414936459558900039981262463159552250080008521597069327679753631497392411000633926838535001352004304755387394854241740925761
Signature 1: (20270153139102829474906701310664582977060758156743914887186781872936805844109810939545932360628062407191717920484904112059408976839986373267238932155732899622943609634077236958169032604260475508959023623648729800182194207429586352759447204213373968561249353419571431424809290076636892498080245264961400233308, 260235413673258891990496308906471230403866483220016680807281388595349198324)
Signature 2: (20270153139102829474906701310664582977060758156743914887186781872936805844109810939545932360628062407191717920484904112059408976839986373267238932155732899622943609634077236958169032604260475508959023623648729800182194207429586352759447204213373968561249353419571431424809290076636892498080245264961400233308, 260235413673258891990496308906471230403866483220016680807281388595349198324)
//Type: Cryptography, Schnorr
//Author: six

View File

@ -0,0 +1,48 @@
import random
from sympy import isprime
def generate_large_prime(bits=512):
"""Generate a large prime number of specified bit length."""
p = 1
while not isprime(p):
p = random.getrandbits(bits)
return p
def blum_blum_shub(p, q, seed, length):
"""Blum-Blum-Shub PRNG for generating nonces."""
n = p * q
x = seed ** 2 % n
output_bits = []
for _ in range(length):
x = x ** 2 % n
output_bits.append(x % 2)
return int(''.join(map(str, output_bits)), 2)
def generate_keys():
"""Generate public and private keys for the Schnorr signature scheme."""
p = generate_large_prime()
q = generate_large_prime()
n = p * q
g = 0o12341234 # Example
x = 0o12341234 # Example
y = pow(g, x, n)
return (p, q, g, n, x, y)
def schnorr_sign(message, p, q, g, n, x):
"""Generate a Schnorr signature for a message."""
k = blum_blum_shub(p, q, random.randint(2, 2), 256)
r = pow(g, k, n)
s = (k - x * hash(message)) % (n-1)
return (r, s)
def main():
p, q, g, n, x, y = generate_keys()
message = "Sign this message!"
signature1 = schnorr_sign(message, p, q, g, n, x)
signature2 = schnorr_sign(message, p, q, g, n, x)
print("Public Key:", y)
print("Signature 1:", signature1)
print("Signature 2:", signature2)
if __name__ == "__main__":
main()

671
300_zk-dirham/Cargo.lock generated 100644
View File

@ -0,0 +1,671 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "ahash"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
dependencies = [
"cfg-if",
"once_cell",
"version_check",
"zerocopy",
]
[[package]]
name = "ark-bls12-381"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488"
dependencies = [
"ark-ec",
"ark-ff",
"ark-serialize",
"ark-std",
]
[[package]]
name = "ark-crypto-primitives"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3a13b34da09176a8baba701233fdffbaa7c1b1192ce031a3da4e55ce1f1a56"
dependencies = [
"ark-ec",
"ark-ff",
"ark-r1cs-std",
"ark-relations",
"ark-serialize",
"ark-snark",
"ark-std",
"blake2 0.10.6",
"derivative",
"digest 0.10.7",
"sha2",
"tracing",
]
[[package]]
name = "ark-ec"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba"
dependencies = [
"ark-ff",
"ark-poly",
"ark-serialize",
"ark-std",
"derivative",
"hashbrown",
"itertools",
"num-traits",
"zeroize",
]
[[package]]
name = "ark-ed-on-bls12-381"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba6d678bb98a7e4f825bd4e332e93ac4f5a114ce2e3340dee4d7dc1c7ab5b323"
dependencies = [
"ark-bls12-381",
"ark-ec",
"ark-ff",
"ark-r1cs-std",
"ark-std",
]
[[package]]
name = "ark-ff"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba"
dependencies = [
"ark-ff-asm",
"ark-ff-macros",
"ark-serialize",
"ark-std",
"derivative",
"digest 0.10.7",
"itertools",
"num-bigint",
"num-traits",
"paste",
"rustc_version",
"zeroize",
]
[[package]]
name = "ark-ff-asm"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348"
dependencies = [
"quote",
"syn 1.0.105",
]
[[package]]
name = "ark-ff-macros"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565"
dependencies = [
"num-bigint",
"num-traits",
"proc-macro2",
"quote",
"syn 1.0.105",
]
[[package]]
name = "ark-groth16"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20ceafa83848c3e390f1cbf124bc3193b3e639b3f02009e0e290809a501b95fc"
dependencies = [
"ark-crypto-primitives",
"ark-ec",
"ark-ff",
"ark-poly",
"ark-relations",
"ark-serialize",
"ark-std",
]
[[package]]
name = "ark-mnt4-753"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d27256f8a5cfb4ac27f43cabfbadf45ab60a153a8f65a3474b4c89e48fd35e40"
dependencies = [
"ark-ec",
"ark-ff",
"ark-r1cs-std",
"ark-std",
]
[[package]]
name = "ark-mnt6-753"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "380c58d43c24fd113d41094f5e183e9a2e6ef8bbc8a281e304bfd5076fda7e7f"
dependencies = [
"ark-ec",
"ark-ff",
"ark-mnt4-753",
"ark-r1cs-std",
"ark-std",
]
[[package]]
name = "ark-poly"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf"
dependencies = [
"ark-ff",
"ark-serialize",
"ark-std",
"derivative",
"hashbrown",
]
[[package]]
name = "ark-r1cs-std"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de1d1472e5cb020cb3405ce2567c91c8d43f21b674aef37b0202f5c3304761db"
dependencies = [
"ark-ec",
"ark-ff",
"ark-relations",
"ark-std",
"derivative",
"num-bigint",
"num-integer",
"num-traits",
"tracing",
]
[[package]]
name = "ark-relations"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00796b6efc05a3f48225e59cb6a2cda78881e7c390872d5786aaf112f31fb4f0"
dependencies = [
"ark-ff",
"ark-std",
"tracing",
]
[[package]]
name = "ark-serialize"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5"
dependencies = [
"ark-serialize-derive",
"ark-std",
"digest 0.10.7",
"num-bigint",
]
[[package]]
name = "ark-serialize-derive"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
]
[[package]]
name = "ark-snark"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84d3cc6833a335bb8a600241889ead68ee89a3cf8448081fb7694c0fe503da63"
dependencies = [
"ark-ff",
"ark-relations",
"ark-serialize",
"ark-std",
]
[[package]]
name = "ark-std"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185"
dependencies = [
"num-traits",
"rand",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "blake2"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174"
dependencies = [
"crypto-mac",
"digest 0.9.0",
"opaque-debug",
]
[[package]]
name = "blake2"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
dependencies = [
"digest 0.10.7",
]
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "cctf-zk"
version = "0.0.1"
dependencies = [
"ark-bls12-381",
"ark-crypto-primitives",
"ark-ec",
"ark-ed-on-bls12-381",
"ark-ff",
"ark-groth16",
"ark-mnt4-753",
"ark-mnt6-753",
"ark-r1cs-std",
"ark-relations",
"ark-serialize",
"ark-std",
"blake2 0.9.2",
"digest 0.9.0",
"rand_chacha",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cpufeatures"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0"
dependencies = [
"libc",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "crypto-mac"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab"
dependencies = [
"generic-array",
"subtle",
]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
]
[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [
"generic-array",
]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
"subtle",
]
[[package]]
name = "either"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "generic-array"
version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash",
]
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "libc"
version = "0.2.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
[[package]]
name = "num-bigint"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
[[package]]
name = "opaque-debug"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "paste"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
[[package]]
name = "pin-project-lite"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "proc-macro2"
version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]]
name = "semver"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
[[package]]
name = "sha2"
version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.10.7",
]
[[package]]
name = "subtle"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]]
name = "syn"
version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "synstructure"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"unicode-xid",
]
[[package]]
name = "tracing"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.43",
]
[[package]]
name = "tracing-core"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
[[package]]
name = "typenum"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-ident"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]]
name = "unicode-xid"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "zerocopy"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.43",
]
[[package]]
name = "zeroize"
version = "1.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f"
dependencies = [
"zeroize_derive",
]
[[package]]
name = "zeroize_derive"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.105",
"synstructure",
]

View File

@ -0,0 +1,26 @@
[package]
name = "cctf-zk-dirham"
version = "0.0.1"
edition = "2021"
[dependencies]
ark-ec = { version = "^0.4.0", default-features = false }
ark-ff = { version = "^0.4.0", default-features = false }
ark-serialize = { version = "^0.4.0", features = [ "derive" ] }
ark-std = { version = "^0.4.0", default-features = false, features = [ "std" ] }
ark-r1cs-std = { version = "^0.4.0", default-features = false }
ark-mnt4-753 = { version = "^0.4.0", default-features = false, features = [ "r1cs", "curve" ] }
ark-mnt6-753 = { version = "^0.4.0", default-features = false, features = [ "r1cs" ] }
ark-bls12-381 = { version = "^0.4.0", default-features = false, features = [ "curve" ] }
ark-ed-on-bls12-381 = { version = "^0.4.0", default-features = false, features = [ "r1cs" ] }
ark-crypto-primitives = { version = "^0.4.0", default-features = false, features = [ "r1cs", "merkle_tree" ] }
ark-relations = { version = "^0.4.0", default-features = false }
ark-groth16 = { version = "^0.4.0", default-features = false }
digest = { version = "0.9" }
blake2 = { version = "0.9", default-features = false }
rand_chacha = { version = "0.3.0", default-features = false }
[[bin]]
name = "main"
path = "src/main.rs"

View File

@ -0,0 +1,6 @@
Sheikh Abdul, during his travels in europe got fascinated by the idea of privacy coins. He immediately recognized the potential behind Zeroknowledge proofs and even understood the importance of using nullifiers to prevent double-spending the same proof twice. He tasked his best engineers to build a digital dirham coin that uses zeroknowledge tch for private transactions and short nullifiers.
But the digital dirham's price is now falling on coingecko, and the explorer shows that Abdul's account is sending transactions that were never approved! But y?
//Type: ZK, Leaking
//Author: Silur

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,174 @@
use ark_ec::AffineRepr;
use ark_ff::PrimeField;
use ark_mnt4_753::{Fr as MNT4BigFr, MNT4_753};
use ark_mnt6_753::G1Affine;
use ark_mnt6_753::{constraints::G1Var, Fr as MNT6BigFr};
use ark_crypto_primitives::merkle_tree::{Config, MerkleTree, Path};
use ark_crypto_primitives::{crh::TwoToOneCRHScheme, snark::SNARK};
use ark_groth16::Groth16;
use ark_r1cs_std::fields::fp::FpVar;
use ark_r1cs_std::prelude::*;
use ark_relations::r1cs::{ConstraintSynthesizer, ConstraintSystemRef, SynthesisError};
use ark_serialize::{CanonicalDeserialize, Read};
use std::fs::File;
use std::io::Cursor;
pub mod poseidon_parameters;
type ConstraintF = MNT4BigFr;
use ark_crypto_primitives::{
crh::{poseidon, *},
merkle_tree::constraints::*,
merkle_tree::*,
};
use ark_std::rand::SeedableRng;
type LeafH = poseidon::CRH<ConstraintF>;
type LeafHG = poseidon::constraints::CRHGadget<ConstraintF>;
type CompressH = poseidon::TwoToOneCRH<ConstraintF>;
type CompressHG = poseidon::constraints::TwoToOneCRHGadget<ConstraintF>;
type LeafVar = [FpVar<ConstraintF>];
struct MntMerkleTreeParamsVar;
impl ConfigGadget<MntMerkleTreeParams, ConstraintF> for MntMerkleTreeParamsVar {
type Leaf = LeafVar;
type LeafDigest = <LeafHG as CRHSchemeGadget<LeafH, ConstraintF>>::OutputVar;
type LeafInnerConverter = IdentityDigestConverter<FpVar<ConstraintF>>;
type InnerDigest = <CompressHG as TwoToOneCRHSchemeGadget<CompressH, ConstraintF>>::OutputVar;
type LeafHash = LeafHG;
type TwoToOneHash = CompressHG;
}
type MntMerkleTree = MerkleTree<MntMerkleTreeParams>;
struct MntMerkleTreeParams;
impl Config for MntMerkleTreeParams {
type Leaf = [ConstraintF];
type LeafDigest = <LeafH as CRHScheme>::Output;
type LeafInnerDigestConverter = IdentityDigestConverter<ConstraintF>;
type InnerDigest = <CompressH as TwoToOneCRHScheme>::Output;
type LeafHash = LeafH;
type TwoToOneHash = CompressH;
}
#[derive(Clone)]
struct SpendCircuit {
pub leaf_params: <LeafH as CRHScheme>::Parameters,
pub two_to_one_params: <LeafH as CRHScheme>::Parameters,
pub root: <CompressH as TwoToOneCRHScheme>::Output,
pub proof: Path<MntMerkleTreeParams>,
pub secret: ConstraintF,
pub nullifier: ConstraintF,
}
impl ConstraintSynthesizer<ConstraintF> for SpendCircuit {
fn generate_constraints(
self,
cs: ConstraintSystemRef<ConstraintF>,
) -> Result<(), SynthesisError> {
let root = <LeafHG as CRHSchemeGadget<LeafH, _>>::OutputVar::new_input(
ark_relations::ns!(cs, "new_digest"),
|| Ok(self.root),
)?;
let leaf_crh_params_var =
<LeafHG as CRHSchemeGadget<LeafH, _>>::ParametersVar::new_constant(
ark_relations::ns!(cs, "leaf_crh_parameter"),
&self.leaf_params,
)?;
let two_to_one_crh_params_var =
<CompressHG as TwoToOneCRHSchemeGadget<CompressH, _>>::ParametersVar::new_constant(
ark_relations::ns!(cs, "two_to_one_crh_parameter"),
&self.two_to_one_params,
)?;
let secret = FpVar::new_witness(ark_relations::ns!(cs, "secret"), || Ok(self.secret))?;
let secret_bits = secret.to_bits_le()?;
Boolean::enforce_smaller_or_equal_than_le(&secret_bits, MNT6BigFr::MODULUS)?;
let nullifier = <LeafHG as CRHSchemeGadget<LeafH, _>>::OutputVar::new_input(
ark_relations::ns!(cs, "nullifier"),
|| Ok(self.nullifier),
)?;
let nullifier_in_circuit =
<LeafHG as CRHSchemeGadget<LeafH, _>>::evaluate(&leaf_crh_params_var, &[secret])?;
nullifier_in_circuit.enforce_equal(&nullifier)?;
let base = G1Var::new_constant(ark_relations::ns!(cs, "base"), G1Affine::generator())?;
let pk = base.scalar_mul_le(secret_bits.iter())?.to_affine()?;
let leaf_g: Vec<_> = vec![pk.x];
let cw: PathVar<MntMerkleTreeParams, ConstraintF, MntMerkleTreeParamsVar> =
PathVar::new_witness(ark_relations::ns!(cs, "new_witness"), || Ok(&self.proof))?;
cw.verify_membership(
&leaf_crh_params_var,
&two_to_one_crh_params_var,
&root,
&leaf_g,
)?
.enforce_equal(&Boolean::constant(true))?;
Ok(())
}
}
fn from_file<T: CanonicalDeserialize>(path: &str) -> T {
let mut file = File::open(path).unwrap();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).unwrap();
T::deserialize_uncompressed_unchecked(Cursor::new(&buffer)).unwrap()
}
fn main() {
let rng = &mut ark_std::rand::rngs::StdRng::seed_from_u64(0u64);
let leaves: Vec<Vec<MNT4BigFr>> = from_file("./leaves.bin");
let leaked_secret: MNT4BigFr = from_file("./leaked_secret.bin");
let (pk, vk): (
<Groth16<MNT4_753> as SNARK<MNT4BigFr>>::ProvingKey,
<Groth16<MNT4_753> as SNARK<MNT4BigFr>>::VerifyingKey,
) = from_file("./proof_keys.bin");
let leaf_crh_params = poseidon_parameters::poseidon_parameters();
let i = 2;
let two_to_one_crh_params = leaf_crh_params.clone();
let nullifier = <LeafH as CRHScheme>::evaluate(&leaf_crh_params, vec![leaked_secret]).unwrap();
let tree = MntMerkleTree::new(
&leaf_crh_params,
&two_to_one_crh_params,
leaves.iter().map(|x| x.as_slice()),
)
.unwrap();
let root = tree.root();
let leaf = &leaves[i];
let tree_proof = tree.generate_proof(i).unwrap();
assert!(tree_proof
.verify(
&leaf_crh_params,
&two_to_one_crh_params,
&root,
leaf.as_slice()
)
.unwrap());
let c = SpendCircuit {
leaf_params: leaf_crh_params.clone(),
two_to_one_params: two_to_one_crh_params.clone(),
root: root.clone(),
proof: tree_proof.clone(),
nullifier: nullifier.clone(),
secret: leaked_secret.clone(),
};
let proof = Groth16::<MNT4_753>::prove(&pk, c.clone(), rng).unwrap();
assert!(Groth16::<MNT4_753>::verify(&vk, &vec![root, nullifier], &proof).unwrap());
}

View File

@ -0,0 +1,656 @@
use ark_crypto_primitives::sponge::poseidon::PoseidonConfig;
use ark_std::str::FromStr;
use ark_std::{One, Zero};
use ark_mnt4_753::Fr as MNT4BigFr;
type F = MNT4BigFr;
pub fn poseidon_parameters() -> PoseidonConfig<F> {
let full_rounds = 8;
let partial_rounds = 29;
let alpha = 17;
let ark = vec![
vec![
F::from_str(
"9478896780421655835758496955063136571251874317427585180076394551808670301829",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"1410220424381727336803825453763847584610565307685015130563813219659976870089",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"12324248147325396388933912754817224521085038231095815415485781874375379288849",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"5869197693688547188262203345939784760013629955870738354032535473827837048029",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"7027675418691353855077049716619550622043312043660992344940177187528247727783",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"12525656923125347519081182951439180216858859245949104467678704676398049957654",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"2393593257638453164081539737606611596909105394156134386135868506931280124380",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"21284282509779560826339329447865344953337633312148348516557075030360788076689",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"9426009547297688316907727916185688178981799243406990694957955230529774886223",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"5340930120720868177469579986808462005013697381998009281661327587975132166755",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"13224952063922250960936823741448973692264041750100990569445192064567307041002",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"5263772922985715307758718731861278699232625525745635678504665316187832057553",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"12905140589386545724352113723305099554526316070018892915579084990225436501424",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"3682692866591423277196501877256311982914914533289815428970072263880360882202",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"19681976272543335942352939522328215645129363120562038296975370569202780487598",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"5636115553781577891149626756201577064573186936824720926267940879716772984728",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"9501050736957980494328252533770324735114766672253853282051029963140075785396",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"2809392708032113981798687947163092027958611686144429680366467696224014505992",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"18433043696013996573551852847056868761017170818820490351056924728720017242180",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"1600424531609887868281118752288673305222025191763201214001133841689879221076",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"4077863666335789263839414578443702921867998881654209770993100224779179660280",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"10750183821931976144366649760909312224094512474274826686974526305203678408743",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"5876585841304782856135279046524906005004905983316552629403091395701737015709",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"13484299981373196201166722380389594773562113262309564134825386266765751213853",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"17382139184029132729706972098151128411278461930818849113274328379445169530719",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"20539300163698134245746932972121993866388520784246731402041866252259697791654",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"149101987103211771991327927827692640556911620408176100290586418839323044234",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"3772300053282831651551351000101118094165364582047053942163129913249479587871",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"1859494671365748569037492975272316924127197175139843386363551067183747450207",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"6056775412522970299341516426839343188000696076848171109448990325789072743616",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"13535861576199801040709157556664030757939966797019046516538528720719863222691",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"3166287940256215995277151981354337176516077219230228956292184356796876826882",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"3878105211417696553129343540655091450996375987051865710523878345663272335218",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"3234972450165117119793849127765475568944145932922109597427102281521349833458",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"4245107901241859301876588161430872878162557070919886440605528540426123750702",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"14797507122636944484020484450153618519329103538375805997650508264647579279513",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"3893725073760673244819994221888005992135922325903832357013427303988853516024",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"21641836396029226240087625131527365621781742784615208902930655613239471409203",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"4622082908476410083286670201138165773322781640914243047922441301693321472984",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"14738633807199650048753490173004870343158648561341211428780666160270584694255",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"2635090520059500019661864086615522409798872905401305311748231832709078452746",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"19070766579582338321241892986615538320421651429118757507174186491084617237586",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"12622420533971517050761060317049369208980632120901481436392835424625664738526",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"4395637216713203985567958440367812800809784906642242330796693491855644277207",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"13856237567677889405904897420967317137820909836352033096836527506967315017500",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"2152570847472117965131784005129148028733701170858744625211808968788882229984",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"6585203416839617436007268534508514569040432229287367393560615429950244309612",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"2153122337593625580331500314713439203221416612327349850130027435376816262006",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"7340485916200743279276570085958556798507770452421357119145466906520506506342",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"12717879727828017519339312786933302720905962296193775803009326830415523871745",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"5392903649799167854181087360481925061021040403603926349022734894553054536405",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"7221669722700687417346373353960536661883467014204005276831020252277657076044",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"8259126917996748375739426565773281408349947402369855975457055235880500335093",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"9272385735015968356236075957906198733226196415690072035874639311675477515202",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"10999027991078055598627757097261950281899485771669414759870674222957875237568",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"15453393396765207016379045014101989306173462885430532298601655955681532648226",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"5478929644476681096437469958231489102974161353940993351588559414552523375472",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"6864274099016679903139678736335228538241825704814597078997020342617052506183",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"12133526413093116990739357861671284889661106676453313677855438696597541491864",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"4363234898901124667709814170397096827222883770682185860994495523839008586252",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"16799465577487943696587954846666404704275729737273450161871875150400464433797",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"3466902930973160737502426090330438125630820207992414876720169645462530526357",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"10062441698891350053170325824989022858836994651376301483266809451301259521913",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"5849282602749563270643968237860161465694876981255295041960826011116890638924",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"18460093993858702487671589299005229942046272739124591066186726570539410116617",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"9812100862165422922235757591915383485338044715409891361026651619010947646011",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"3387849124775103843519196664933515074848119722071551419682472701704619249120",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"5283840871671971215904992681385681067319154145921438770232973796570506340281",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"14450974197863079729258614455552607708855872944526185987072755641686663205867",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"12613293459867195704822743599193025685229122593088639435739984309110321350551",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"6228273556621778927381918766322387348845347649737780310185999880647567569148",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"7482296435079443913598332362891173417094991594500715575107878549173583070413",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"18655449861670697203232484600163743308157596453845950955559776266093852537258",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"19948920146235041970991269588233091409704340607794045065548049409652881283328",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"13866078374565054775555309394949653928903776100036987352339975076159400168494",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"19398653685274645718325650121748668221118186023117741800737442235635318532994",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"4234154881267169381851681265196336178292466185695662916289548353755778788440",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"12763628380946395634691260884409562631856128057257959813602172954351304541746",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"7882453112990894293341171586279209575183467873317150236705310601775347127762",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"5669812778237054435250482766817044415794242063465169363632154286378940417646",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"16998738906020038479274018881471127087312245548341958049900081105113388112420",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"3923902724726826782251513956816550869721438812970437824859252798290604500141",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"8649850619802776810849631749100283821801281306919958924112424995025830909252",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"11095642206650177249637693917287763476332497377393343056089442602164577098005",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"6935839211798937659784055008131602708847374430164859822530563797964932598700",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"7009671085960032501857416946339379996865118520008277046653124221544059312084",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"14361753917538892938870644779277430374939140280641641154553910654644462796654",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"6296738827713642491839335218022320853584196754765009910619998033694434027436",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"13849351053619304861036345979638534258290466678610892122310972291285921828452",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"434708832289952835651719825370636597763362139118091644948171210201038442144",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"16633750393567936099837698146248798150044883935695159627422586429892098538881",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"12944939557587269500508410478785174192748264930676627398550886896505925728421",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"13132297714437965464312509267711212830308064898189789451541658159340762509645",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"3197382106307730326149017386920960267079843887376371149099833465681078850285",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"1219439673853113792340300173186247996249367102884530407862469123523013083971",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"3493891993991676033939225547105305872211028239751045376877382816726002847983",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"17474961424148900675164871904345354895260557993970869987490270849177572737815",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"14496326112831768456074139601688618143496262542471380389977686658437504436331",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"2924472580096769678506212811457662807142794313402961128576445038927398235897",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"4628296006426596599826873705217702584581936573072175641058168144816722698331",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"21191637522268746884323101636631937283436518241594045635071026927358145697662",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"16951212238971640283544926666565087199118390400059790490897089817025688673127",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"19613695336435411200907478310503966803576648245805018042761984388590288078910",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"19408817842355340096520725353160494939342325645253279486424056603334799168015",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"21454045045501902703155952158575095010854214688097850310899813261125869452799",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"7770328480231095569114093553841085793308707788942057894109603074902652929530",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"16464571997310094273270381226660568195148193554716113613093103468413654931642",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"17470702407108506528534764015553049093186219898758900659217736458688524875937",
)
.map_err(|_| ())
.unwrap(),
],
vec![
F::from_str(
"18550730212998825286534234924565339469725380540133305684933015562293032312245",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"2896017217286658654468296502214232988965841950467453595108246966331694256153",
)
.map_err(|_| ())
.unwrap(),
F::from_str(
"14675299739240143232464986549869467617250208852063994519435190317578889428919",
)
.map_err(|_| ())
.unwrap(),
],
];
// We use a near MDS matrix of the form:
// [[1, 0, 1],
// [1, 1, 0],
// [0, 1, 1]]
let mds = vec![
vec![F::one(), F::zero(), F::one()],
vec![F::one(), F::one(), F::zero()],
vec![F::zero(), F::one(), F::one()],
];
PoseidonConfig::<F>::new(full_rounds, partial_rounds, alpha, mds, ark, 2, 1)
}

28
README.md 100644
View File

@ -0,0 +1,28 @@
==== CCTF vol9 rnd2 ====
Challenges are in this repository.
DCTF smart contract to submit your challenges (ASTAR Network): https://blockscout.com/astar/tx/0x5ccdc6732d6b806c6565af1a9fa9e0591e608ef1941573f01a753560b291b5dc
Competition ID is "92" and the password is "1337".
Code of smart contract (if needed): https://v-space.hu/p/?4b42ce01f60deac2#kJKBdqOMvqM0mVV6/voEj8C693g9MI5Nv0zOWIcdeak=
Flag encoder frontend: https://git.hsbp.org/CCTF/DCTF/src/branch/main/flag_encoder_fe
Some challenges won't return the private key itself, so you'll need to use the converter API: wget -qO- "209.250.246.26:6789/get?flag=CCTF{test}"
====== Challenges ~ ID, Name, Points, Pub Address ======
1 | 100_grabDOT | 100 | 0x133745A6aF4F954f870798f6Db662E27741c8d7B
2 | 100_numerology | 100 | 0x1337bDE03d31AE1e3Dada64F6da49fB358C0D39C
3 | 107_js_play | 107 | 0x1337E7DF1E590916e2EA80bA4eE8f575462A5c49
4 | 200_unsavable | 200 | 0x133758E7A3Aba91457647650211dBCad3c48cBfb
5 | 230_Subquiz | 230 | 0x1337bf1A2e60c2f6a6CC7e7D6402Adcc855BB6AC
6 | 300_schnor-ng | 300 | 0x1337E1F66E9343c132C4C290eACE0Cc5023813BB
7 | 300_zk-dirham | 300 | 0x1337C98f553A996BD8a58B4051254A222B443b7c
Max score: 1337
Good luck and have fun!