-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* stuff * Working tests for aes-gcm and gctr * Remove logs --------- Co-authored-by: devloper <[email protected]>
- Loading branch information
Showing
5 changed files
with
46 additions
and
41 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
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,27 +1,28 @@ | ||
import { WitnessTester } from "circomkit"; | ||
import { circomkit } from "./common"; | ||
import { circomkit, hexBytesToBigInt } from "./common"; | ||
import { assert } from "chai"; | ||
|
||
// signal input key[nk * 4]; | ||
// signal input initialCounterBlock[128]; | ||
// signal input plainText[INPUT_LEN]; | ||
// signal output cipherText[INPUT_LEN]; | ||
describe("GCTR", () => { | ||
let circuit: WitnessTester<["key", "initialCounterBlock", "plainText"], ["cipherText"]>; | ||
let circuit: WitnessTester<["plainText", "initialCounterBlock", "key"], ["cipherText"]>; | ||
it("should encrypt the plaintext", async () => { | ||
circuit = await circomkit.WitnessTester(`GCTR`, { | ||
file: "aes-gcm/gctr", | ||
template: "GCTR", | ||
params: [129, 4], | ||
params: [16, 4], | ||
}); | ||
await circuit.expectPass( | ||
{ | ||
key: [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c], | ||
initialCounterBlock: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], | ||
plainText: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], | ||
}, | ||
{ | ||
cipherText: [0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a], | ||
} | ||
); | ||
|
||
// GOOD TEST CASE. | ||
const key = [0xca, 0xaa, 0x3f, 0x6f, 0xd3, 0x18, 0x22, 0xed, 0x2d, 0x21, 0x25, 0xf2, 0x25, 0xb0, 0x16, 0x9f]; | ||
const column_wise_icb = [0x7f,0x48,0x12,0x00,0x6d,0x3e,0xfa,0x00,0x90,0x8c,0x55,0x00,0x41,0x14,0x2a,0x02]; | ||
const pt = [0x84, 0xc9, 0x07, 0xb1, 0x1a, 0xe3, 0xb7, 0x9f,0xc4, 0x45, 0x1d, 0x1b, 0xf1, 0x7f, 0x4a, 0x99]; | ||
const ct = [0xfd, 0xb4, 0xaa, 0xfa, 0x35, 0x19, 0xd3, 0xc0,0x55, 0xbe, 0x8b, 0x34, 0x77, 0x64, 0xea, 0x33]; | ||
|
||
const witness = await circuit.compute({ key: key, initialCounterBlock: column_wise_icb, plainText: pt }, ["cipherText"]) | ||
|
||
assert.deepEqual(witness.cipherText, hexBytesToBigInt(ct)) | ||
}); | ||
}); |