-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
37e2cd2
commit 0e2ef9e
Showing
10 changed files
with
467 additions
and
456 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Globals Edward Curves supported Baby JubJub | ||
use dep::std::ec::consts::te::{baby_jubjub}; | ||
use dep::std::ec::consts::te::baby_jubjub; | ||
|
||
global BJJ = baby_jubjub(); | ||
global G = BJJ.base8; |
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 |
---|---|---|
@@ -1,45 +1,45 @@ | ||
import { BarretenbergBackend } from '@noir-lang/backend_barretenberg' | ||
import { Noir } from '@noir-lang/noir_js' | ||
import { ProofData } from '@noir-lang/types' | ||
import { expect } from 'chai' | ||
import { randomBytes } from 'crypto' | ||
import { readFileSync } from 'fs' | ||
import { resolve } from 'path' | ||
import 'mocha' | ||
import { BarretenbergBackend } from "@noir-lang/backend_barretenberg" | ||
import { Noir } from "@noir-lang/noir_js" | ||
import { ProofData } from "@noir-lang/types" | ||
import { expect } from "chai" | ||
import { randomBytes } from "crypto" | ||
import { readFileSync } from "fs" | ||
import { resolve } from "path" | ||
import "mocha" | ||
|
||
function generatePrivateKey(): Uint8Array { | ||
return randomBytes(32) | ||
return randomBytes(32) | ||
} | ||
|
||
describe('ECDH Circuit Tests', function() { | ||
let noir: Noir | ||
let backend: BarretenbergBackend | ||
let correctProof: ProofData | ||
describe("ECDH Circuit Tests", function () { | ||
let noir: Noir | ||
let backend: BarretenbergBackend | ||
let correctProof: ProofData | ||
|
||
beforeEach(async () => { | ||
const circuitFile = readFileSync(resolve(__dirname, '../../../target/ecdh.json'), 'utf-8') | ||
const circuit = JSON.parse(circuitFile) | ||
backend = new BarretenbergBackend(circuit) | ||
noir = new Noir(circuit, backend) | ||
const pk1 = generatePrivateKey() | ||
const pk2 = generatePrivateKey() | ||
beforeEach(async () => { | ||
const circuitFile = readFileSync(resolve(__dirname, "../../../target/ecdh.json"), "utf-8") | ||
const circuit = JSON.parse(circuitFile) | ||
backend = new BarretenbergBackend(circuit) | ||
noir = new Noir(circuit, backend) | ||
const pk1 = generatePrivateKey() | ||
const pk2 = generatePrivateKey() | ||
|
||
// Convert Uint8Array to regular arrays | ||
const input = { | ||
private_key1: Array.from(pk1), | ||
private_key2: Array.from(pk2), | ||
} | ||
// Convert Uint8Array to regular arrays | ||
const input = { | ||
private_key1: Array.from(pk1), | ||
private_key2: Array.from(pk2) | ||
} | ||
|
||
correctProof = await noir.generateProof(input) | ||
}) | ||
correctProof = await noir.generateProof(input) | ||
}) | ||
|
||
it('Should generate valid proof for correct input', async function() { | ||
expect(correctProof.proof).to.be.instanceOf(Uint8Array) | ||
}) | ||
it("Should generate valid proof for correct input", async function () { | ||
expect(correctProof.proof).to.be.instanceOf(Uint8Array) | ||
}) | ||
|
||
it('Should verify valid proof for correct input', async function() { | ||
expect(correctProof).to.not.be.undefined // Ensure proof is generated | ||
const verification = await noir.verifyProof(correctProof) | ||
expect(verification).to.be.true | ||
}) | ||
it("Should verify valid proof for correct input", async function () { | ||
expect(correctProof).to.not.be.undefined // Ensure proof is generated | ||
const verification = await noir.verifyProof(correctProof) | ||
expect(verification).to.be.true | ||
}) | ||
}) |
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
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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// mod pedersen; | ||
// mod poseidon; | ||
// mod poseidon2; | ||
mod pedersen; | ||
mod poseidon; | ||
mod poseidon2; |
Oops, something went wrong.