-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
48 additions
and
152 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause-Clear | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import "fhevm/lib/TFHE.sol"; | ||
|
||
contract A { | ||
|
||
constructor() {} | ||
|
||
function requestDecryption(euint32 ct) external { | ||
require(TFHE.isInitialized(ct), "Ciphertext is not initialized"); | ||
euint32 ct_r = TFHE.shl(ct, 0); | ||
Check warning on line 13 in contracts/A.sol GitHub Actions / ci
|
||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause-Clear | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import "fhevm/lib/TFHE.sol"; | ||
import "./A.sol"; | ||
|
||
contract B { | ||
euint32 x; | ||
A a; | ||
|
||
constructor(address _a) { | ||
a = A(_a); | ||
x = TFHE.asEuint32(32); | ||
} | ||
|
||
function request() public { | ||
a.requestDecryption(x); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,37 +1,24 @@ | ||
import { expect } from "chai"; | ||
import { ethers } from "hardhat"; | ||
|
||
import { createInstances } from "../instance"; | ||
import { getSigners, initSigners } from "../signers"; | ||
|
||
describe("TestAsyncDecrypt", function () { | ||
describe("Test", function () { | ||
before(async function () { | ||
await initSigners(); | ||
this.signers = await getSigners(); | ||
}); | ||
|
||
beforeEach(async function () { | ||
const oracleFactory = await ethers.getContractFactory("Oracle"); | ||
this.oracle = await oracleFactory.connect(this.signers.alice).deploy(); // Alice is the Oracle Admin | ||
await this.oracle.waitForDeployment(); | ||
|
||
const tx1 = await this.oracle.addRelayer(this.signers.bob); // Bob is an Oracle Relayer | ||
await tx1.wait(); | ||
const aFactory = await ethers.getContractFactory("A"); | ||
this.a = await aFactory.connect(this.signers.alice).deploy(); // Alice is the Oracle Admin | ||
await this.a.waitForDeployment(); | ||
|
||
const oracleAddress = await this.oracle.getAddress(); | ||
const contractFactory = await ethers.getContractFactory("TestAsyncDecrypt"); | ||
this.contract = await contractFactory.connect(this.signers.alice).deploy(oracleAddress); | ||
const aAddress = await this.a.getAddress(); | ||
const bFactory = await ethers.getContractFactory("B"); | ||
this.b = await bFactory.connect(this.signers.alice).deploy(aAddress); | ||
}); | ||
|
||
it("test async decrypt", async function () { | ||
const tx2 = await this.contract.connect(this.signers.carol).request(5, 15); | ||
await tx2.wait(); | ||
|
||
const filter = this.oracle.filters.EventDecryption; | ||
const events = await this.oracle.queryFilter(filter, -1); | ||
const event = events[0]; | ||
|
||
const args = event.args; | ||
console.log(args); | ||
it("test b", async function () { | ||
const tx = await this.b.connect(this.signers.carol).request(); | ||
await tx.wait(); | ||
}); | ||
}); | ||
}); |