Skip to content

Commit

Permalink
Merge pull request #32 from NethermindEth/feature/13-fq-field-u384
Browse files Browse the repository at this point in the history
Feature/13 fq field u384
  • Loading branch information
danielntmd authored Jan 2, 2025
2 parents b683655 + 0bad2f9 commit c280fc9
Show file tree
Hide file tree
Showing 53 changed files with 3,119 additions and 2,169 deletions.
2 changes: 2 additions & 0 deletions contract/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
starkli_cmd.md
/target
Empty file.
30 changes: 30 additions & 0 deletions contract/Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "plonk_verifier"
version = "0.1.0"
dependencies = [
"snforge_std",
]

[[package]]
name = "plonk_verifier_contract"
version = "0.1.0"
dependencies = [
"plonk_verifier",
"snforge_std",
]

[[package]]
name = "snforge_scarb_plugin"
version = "0.31.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.31.0#72ea785ca354e9e506de3e5d687da9fb2c1b3c67"

[[package]]
name = "snforge_std"
version = "0.31.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.31.0#72ea785ca354e9e506de3e5d687da9fb2c1b3c67"
dependencies = [
"snforge_scarb_plugin",
]
20 changes: 20 additions & 0 deletions contract/Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "plonk_verifier_contract"
version = "0.1.0"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[[target.starknet-contract]]
casm = true
sierra = true

[dependencies]
starknet = "2.8.2"
plonk_verifier = { path = "../plonk-verifier" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.31.0" }
assert_macros = "2.8.2"

[cairo]
sierra-replace-ids = false
55 changes: 55 additions & 0 deletions contract/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
pub use plonk_verifier::plonk::types::{PlonkVerificationKey, PlonkProof};
pub use plonk_verifier::plonk::verify;
use core::array::ArrayTrait;

#[starknet::interface]
trait IVerifier<T> {
// fn verify(
// ref self: T,
// verification_key: PlonkVerificationKey, proof: PlonkProof, publicSignals: Array<u256>
// );
fn verify(ref self: T);
}

#[starknet::contract]
mod PLONK_Verifier{

use core::array::ArrayTrait;

use plonk_verifier::plonk::verify;
use plonk_verifier::plonk::types::{PlonkVerificationKey, PlonkProof};
use plonk_verifier::plonk::constants;

#[storage]
struct Storage {}

#[constructor]
fn constructor(ref self: ContractState) {}

#[abi(embed_v0)]
impl PLONK_verifier of super::IVerifier<ContractState> {

// fn verify(ref self: ContractState, verification_key: PlonkVerificationKey, proof: PlonkProof, publicSignals: Array<u256>) {
fn verify(ref self: ContractState) {
let (n, power, k1, k2, nPublic, nLagrange, Qm, Ql, Qr, Qo, Qc, S1, S2, S3, X_2, w) =
constants::verification_key();
let verification_key:PlonkVerificationKey = PlonkVerificationKey {
n, power, k1, k2, nPublic, nLagrange, Qm, Ql, Qr, Qo, Qc, S1, S2, S3, X_2, w
};

// proof
let (A, B, C, Z, T1, T2, T3, Wxi, Wxiw, eval_a, eval_b, eval_c, eval_s1, eval_s2,
eval_zw) =
constants::proof();
let proof: PlonkProof = PlonkProof {
A, B, C, Z, T1, T2, T3, Wxi, Wxiw, eval_a, eval_b, eval_c, eval_s1, eval_s2, eval_zw
};

//public_signals
let public_signals = constants::public_inputs();
let verified: bool = plonk_verifier::plonk::verify::PlonkVerifier::verify(verification_key, proof, public_signals);
assert(verified, 'plonk verification failed');
}
}
}

4 changes: 2 additions & 2 deletions plonk-verifier/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v
assert_macros = "2.8.2"

[lib]
sierra = true
casm = true
# sierra = true
# casm = true
1 change: 0 additions & 1 deletion plonk-verifier/contracts/lib.cairo

This file was deleted.

2 changes: 0 additions & 2 deletions plonk-verifier/contracts/verifier.cairo

This file was deleted.

38 changes: 0 additions & 38 deletions plonk-verifier/contracts/verifier/plonk_constants.cairo

This file was deleted.

37 changes: 0 additions & 37 deletions plonk-verifier/contracts/verifier/plonk_verifier.cairo

This file was deleted.

Loading

0 comments on commit c280fc9

Please sign in to comment.