Commit 7d7f02cb authored by Roman Walch's avatar Roman Walch
Browse files

some challenge instances

parent c1b60898
/target
Cargo.lock
flamegraph.svg
perf.data
perf.data.old
[package]
name = "zkhash-bounties"
version = "0.1.0"
authors = ["Roman Walch <roman.walch@iaik.tugraz.at>"]
description = "Rust implementaitons of zk permuations"
edition = "2018"
[dependencies]
ff = {package = "ff_ce", version = "0.13", features = ["derive"] }
rand = "0.4" # held back for ff_ce
lazy_static = "1.4"
cfg-if = "1.0"
sha3 = "0.9"
[[example]]
name = "poseidon_easy1"
path = "examples/poseidon/poseidon_easy1.rs"
[[example]]
name = "poseidon_easy2"
path = "examples/poseidon/poseidon_easy2.rs"
[[example]]
name = "poseidon_medium"
path = "examples/poseidon/poseidon_medium.rs"
[[example]]
name = "poseidon_hard1"
path = "examples/poseidon/poseidon_hard1.rs"
[[example]]
name = "poseidon_hard2"
path = "examples/poseidon/poseidon_hard2.rs"
[[example]]
name = "rescue_easy1"
path = "examples/rescue/rescue_easy1.rs"
[[example]]
name = "rescue_easy2"
path = "examples/rescue/rescue_easy2.rs"
[[example]]
name = "rescue_medium"
path = "examples/rescue/rescue_medium.rs"
[[example]]
name = "rescue_hard1"
path = "examples/rescue/rescue_hard1.rs"
[[example]]
name = "rescue_hard2"
path = "examples/rescue/rescue_hard2.rs"
[[example]]
name = "feistel_mimc_easy1"
path = "examples/feistel_mimc/feistel_mimc_easy1.rs"
[[example]]
name = "feistel_mimc_easy2"
path = "examples/feistel_mimc/feistel_mimc_easy2.rs"
[[example]]
name = "feistel_mimc_medium"
path = "examples/feistel_mimc/feistel_mimc_medium.rs"
[[example]]
name = "feistel_mimc_hard1"
path = "examples/feistel_mimc/feistel_mimc_hard1.rs"
[[example]]
name = "feistel_mimc_hard2"
path = "examples/feistel_mimc/feistel_mimc_hard2.rs"
[profile.release]
lto = true
codegen-units = 1
debug = true
opt-level = 3
[profile.bench]
lto = true
codegen-units = 1
debug = true
opt-level = 3
use ff::{from_hex, Field};
use zkhash_bounties::{
feistel_mimc::{feistel_mimc::FeistelMimc, feistel_mimc_instances::FM_PARAMS_EASY1},
fields::{field::Fp, utils},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &FM_PARAMS_EASY1;
let feistel_mimc = FeistelMimc::new(params);
println!("FeistelMimc Challange easy1");
println!("r = {}", params.get_rounds());
// insert your solution here:
let solution: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[utils::random_scalar(true), Scalar::zero()]
} else {
[solution, Scalar::zero()]
};
let output = feistel_mimc.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
feistel_mimc::{feistel_mimc::FeistelMimc, feistel_mimc_instances::FM_PARAMS_EASY2},
fields::{field::Fp, utils},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &FM_PARAMS_EASY2;
let feistel_mimc = FeistelMimc::new(params);
println!("FeistelMimc Challange easy2");
println!("r = {}", params.get_rounds());
// insert your solution here:
let solution: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[utils::random_scalar(true), Scalar::zero()]
} else {
[solution, Scalar::zero()]
};
let output = feistel_mimc.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
feistel_mimc::{feistel_mimc::FeistelMimc, feistel_mimc_instances::FM_PARAMS_HARD1},
fields::{field::Fp, utils},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &FM_PARAMS_HARD1;
let feistel_mimc = FeistelMimc::new(params);
println!("FeistelMimc Challange hard1");
println!("r = {}", params.get_rounds());
// insert your solution here:
let solution: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[utils::random_scalar(true), Scalar::zero()]
} else {
[solution, Scalar::zero()]
};
let output = feistel_mimc.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
feistel_mimc::{feistel_mimc::FeistelMimc, feistel_mimc_instances::FM_PARAMS_HARD2},
fields::{field::Fp, utils},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &FM_PARAMS_HARD2;
let feistel_mimc = FeistelMimc::new(params);
println!("FeistelMimc Challange hard2");
println!("r = {}", params.get_rounds());
// insert your solution here:
let solution: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[utils::random_scalar(true), Scalar::zero()]
} else {
[solution, Scalar::zero()]
};
let output = feistel_mimc.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
feistel_mimc::{feistel_mimc::FeistelMimc, feistel_mimc_instances::FM_PARAMS_MEDIUM},
fields::{field::Fp, utils},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &FM_PARAMS_MEDIUM;
let feistel_mimc = FeistelMimc::new(params);
println!("FeistelMimc Challange medium");
println!("r = {}", params.get_rounds());
// insert your solution here:
let solution: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[utils::random_scalar(true), Scalar::zero()]
} else {
[solution, Scalar::zero()]
};
let output = feistel_mimc.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
fields::{field::Fp, utils},
poseidon::{poseidon::Poseidon, poseidon_instances::POSEIDON_PARAMS_EASY1},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &POSEIDON_PARAMS_EASY1;
let poseidon = Poseidon::new(params);
println!("Poseidon Challange easy1");
println!("RP = {}", params.get_rp());
// insert your solution here:
let solution1: Scalar = from_hex("0x0000000000000000").unwrap();
let solution2: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[
utils::random_scalar(true),
utils::random_scalar(true),
Scalar::zero(),
]
} else {
[solution1, solution2, Scalar::zero()]
};
let output = poseidon.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
fields::{field::Fp, utils},
poseidon::{poseidon::Poseidon, poseidon_instances::POSEIDON_PARAMS_EASY2},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &POSEIDON_PARAMS_EASY2;
let poseidon = Poseidon::new(params);
println!("Poseidon Challange easy2");
println!("RP = {}", params.get_rp());
// insert your solution here:
let solution1: Scalar = from_hex("0x0000000000000000").unwrap();
let solution2: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[
utils::random_scalar(true),
utils::random_scalar(true),
Scalar::zero(),
]
} else {
[solution1, solution2, Scalar::zero()]
};
let output = poseidon.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
fields::{field::Fp, utils},
poseidon::{poseidon::Poseidon, poseidon_instances::POSEIDON_PARAMS_HARD1},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &POSEIDON_PARAMS_HARD1;
let poseidon = Poseidon::new(params);
println!("Poseidon Challange hard1");
println!("RP = {}", params.get_rp());
// insert your solution here:
let solution1: Scalar = from_hex("0x0000000000000000").unwrap();
let solution2: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[
utils::random_scalar(true),
utils::random_scalar(true),
Scalar::zero(),
]
} else {
[solution1, solution2, Scalar::zero()]
};
let output = poseidon.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
fields::{field::Fp, utils},
poseidon::{poseidon::Poseidon, poseidon_instances::POSEIDON_PARAMS_HARD2},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &POSEIDON_PARAMS_HARD2;
let poseidon = Poseidon::new(params);
println!("Poseidon Challange hard2");
println!("RP = {}", params.get_rp());
// insert your solution here:
let solution1: Scalar = from_hex("0x0000000000000000").unwrap();
let solution2: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[
utils::random_scalar(true),
utils::random_scalar(true),
Scalar::zero(),
]
} else {
[solution1, solution2, Scalar::zero()]
};
let output = poseidon.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
fields::{field::Fp, utils},
poseidon::{poseidon::Poseidon, poseidon_instances::POSEIDON_PARAMS_MEDIUM},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &POSEIDON_PARAMS_MEDIUM;
let poseidon = Poseidon::new(params);
println!("Poseidon Challange medium");
println!("RP = {}", params.get_rp());
// insert your solution here:
let solution1: Scalar = from_hex("0x0000000000000000").unwrap();
let solution2: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[
utils::random_scalar(true),
utils::random_scalar(true),
Scalar::zero(),
]
} else {
[solution1, solution2, Scalar::zero()]
};
let output = poseidon.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
fields::{field::Fp, utils},
rescue_prime::{rescue_prime::RescuePrime, rescue_prime_instances::RESCUE_PRIME_PARAMS_EASY1},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &RESCUE_PRIME_PARAMS_EASY1;
let rescue = RescuePrime::new(params);
println!("Rescue Challange easy1");
println!("N = {}", params.get_rounds());
// insert your solution here:
let solution1: Scalar = from_hex("0x0000000000000000").unwrap();
let solution2: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[
utils::random_scalar(true),
utils::random_scalar(true),
Scalar::zero(),
]
} else {
[solution1, solution2, Scalar::zero()]
};
let output = rescue.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
fields::{field::Fp, utils},
rescue_prime::{rescue_prime::RescuePrime, rescue_prime_instances::RESCUE_PRIME_PARAMS_EASY2},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;
fn main() {
let params = &RESCUE_PRIME_PARAMS_EASY2;
let rescue = RescuePrime::new(params);
println!("Rescue Challange easy2");
println!("N = {}", params.get_rounds());
// insert your solution here:
let solution1: Scalar = from_hex("0x0000000000000000").unwrap();
let solution2: Scalar = from_hex("0x0000000000000000").unwrap();
let input = if RANDOM_INPUT {
[
utils::random_scalar(true),
utils::random_scalar(true),
Scalar::zero(),
]
} else {
[solution1, solution2, Scalar::zero()]
};
let output = rescue.permutation(&input);
println!("Input = {:?}", input);
println!("Output = {:?}", output);
if output[output.len() - 1] == Scalar::zero() {
println!("Challenge solved!");
} else {
println!("Challenge not solved!");
}
}
use ff::{from_hex, Field};
use zkhash_bounties::{
fields::{field::Fp, utils},
rescue_prime::{rescue_prime::RescuePrime, rescue_prime_instances::RESCUE_PRIME_PARAMS_HARD1},
};
type Scalar = Fp;
static RANDOM_INPUT: bool = false;