Initial commit
This commit is contained in:
commit
6f105fd0d1
4 changed files with 135 additions and 0 deletions
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
/target
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
.idea
|
13
Cargo.toml
Normal file
13
Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "VerifierTest"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
ark-ec = { version = "^0.3.0", default-features = false }
|
||||
ark-ff = { version = "^0.3.0", default-features = false }
|
||||
ark-groth16 = { version = "^0.3.0", default-features = false }
|
||||
ark-gm17 = { version = "^0.3.0", default-features = false }
|
||||
ark-bn254 = { version = "^0.3.0", features = ["curve"], default-features = false }
|
12
VerifierTest.iml
Normal file
12
VerifierTest.iml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="RUST_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
95
src/main.rs
Normal file
95
src/main.rs
Normal file
|
@ -0,0 +1,95 @@
|
|||
use ark_bn254::{Bn254, Fq, Fq2, Fr, G1Affine, G2Affine};
|
||||
use ark_ec::bn::Bn;
|
||||
use ark_gm17::{prepare_verifying_key, Proof, VerifyingKey, verify_proof};
|
||||
use ark_groth16::{prepare_verifying_key as g16_prepare_verification_key, Proof as g16_proof, VerifyingKey as g16_verification_key, verify_proof as g16_verify};
|
||||
use ark_ff::{Field, field_new, Zero, vec};
|
||||
|
||||
fn main() {
|
||||
let vk: VerifyingKey<Bn254> = VerifyingKey {
|
||||
h_g2: G2Affine::new(
|
||||
field_new!(Fq2,
|
||||
field_new!(Fq,"13392181199706406433907906681944920725920725050041966177004841420537696888836"),
|
||||
field_new!(Fq,"17791359019317259625577782643521698050995014522458932754805627815448360812479"),
|
||||
),
|
||||
field_new!(Fq2,
|
||||
field_new!(Fq,"10068564024814810474196866165841046251117876966750257324554768062350163607409"),
|
||||
field_new!(Fq,"6857543742386514686629159672291672793331479216115245397160837700975502288021"),
|
||||
),
|
||||
false,
|
||||
),
|
||||
g_alpha_g1: G1Affine::new(
|
||||
field_new!(Fq,"20160613181439748468662236233910418663699735850507077756075277496815952974155"),
|
||||
field_new!(Fq,"12534484533090688683541543246911227776901755797595117487014822108353147888358"),
|
||||
false,
|
||||
),
|
||||
h_beta_g2: G2Affine::new(
|
||||
field_new!(Fq2,
|
||||
field_new!(Fq,"13464648321807084546155552696466868695334090891595093427020705527606595985682"),
|
||||
field_new!(Fq,"5913631853015333412472600094149403468854489537558172804280916963747425490416"),
|
||||
),
|
||||
field_new!(Fq2,
|
||||
field_new!(Fq,"6783849322564872242395904259697043133193217635598545817206339200840370119678"),
|
||||
field_new!(Fq,"12717920015437605516089408642506904877800025726684454380165156913450139144203"),
|
||||
),
|
||||
false,
|
||||
),
|
||||
g_gamma_g1: G1Affine::new(
|
||||
field_new!(Fq,"14223078866065495396819165097926450933153523654996560667980906787578922744121"),
|
||||
field_new!(Fq,"8296125598270994789364494816386510543536546939392689418706852072692043152261"),
|
||||
false,
|
||||
),
|
||||
h_gamma_g2: G2Affine::new(
|
||||
field_new!(Fq2,
|
||||
field_new!(Fq,"13392181199706406433907906681944920725920725050041966177004841420537696888836"),
|
||||
field_new!(Fq,"17791359019317259625577782643521698050995014522458932754805627815448360812479"),
|
||||
),
|
||||
field_new!(Fq2,
|
||||
field_new!(Fq,"10068564024814810474196866165841046251117876966750257324554768062350163607409"),
|
||||
field_new!(Fq,"6857543742386514686629159672291672793331479216115245397160837700975502288021"),
|
||||
),
|
||||
false,
|
||||
),
|
||||
query: vec![
|
||||
G1Affine::new(
|
||||
field_new!(Fq,"11227766949313773713507801131380309129323286842239385343612331136722420886501"),
|
||||
field_new!(Fq,"4669705094682802344195512882762605666961899852551117739470742855402294787047"),
|
||||
false,
|
||||
),
|
||||
G1Affine::new(
|
||||
field_new!(Fq,"5290707226762461149698193348370759572229540708933635176517368332476007248499"),
|
||||
field_new!(Fq,"1396248717434497303724127814092661781702299663232696534784193158278890519790"),
|
||||
false,
|
||||
),
|
||||
],
|
||||
};
|
||||
let proof: Proof<Bn254> = Proof {
|
||||
a: G1Affine::new(
|
||||
field_new!(Fq,"10142265414420053981485444523022654074350261535894814216087876448850276925715"),
|
||||
field_new!(Fq,"3372049500924023889991369391935497281241918870878726411936966864719827227431"), false),
|
||||
b: G2Affine::new(
|
||||
field_new!(Fq2,
|
||||
field_new!(Fq,"5887224591511016247095738960270231594508833943830119820788085709685464001509"),
|
||||
field_new!(Fq,"2621158033579857882606080282447561898918638437250151563681495412578089968816")
|
||||
),
|
||||
field_new!(Fq2,
|
||||
field_new!(Fq,"10257253961156739620332333595473001968619575524170395500469519926721716981367"),
|
||||
field_new!(Fq,"11256705857386105933561686431417209051024579795830286969282928535954964228631")
|
||||
),
|
||||
false,
|
||||
),
|
||||
c: G1Affine::new(
|
||||
field_new!(Fq,"2550368043044579778011314219445660716273739959996608408303294307143737396986"),
|
||||
field_new!(Fq,"1232261532887476656908814366884472508548541157089651916710797927709772251181"),
|
||||
false,
|
||||
),
|
||||
};
|
||||
|
||||
let inputs = [field_new!(Fr,"4")];
|
||||
|
||||
let pvk = prepare_verifying_key::<Bn254>(&vk);
|
||||
|
||||
let result = verify_proof::<Bn254>(&pvk, &proof, &inputs).unwrap();
|
||||
|
||||
|
||||
println!("Verification result: {}", result);
|
||||
}
|
Loading…
Reference in a new issue