Skip to content

Commit

Permalink
tracies test vector passing
Browse files Browse the repository at this point in the history
0xJepsen committed Sep 19, 2024

Unverified

No user is associated with the committer email.
1 parent 7e47189 commit 8e1864d
Showing 2 changed files with 27 additions and 4 deletions.
12 changes: 12 additions & 0 deletions circuits/test/gfmulint/nistgfmul.test.ts
Original file line number Diff line number Diff line change
@@ -31,6 +31,18 @@ describe("NistGMulByte", () => {
const expected = [0xe6, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03];
await circuit.expectPass({ X: X, Y: Y }, { out: expected });
});
it("Should Compute NistGMulByte of LSB=1 Correctly", async () => {

// x = "aae06992acbf52a3e8f4a96ec9300bd7"
// y = "98e7247c07f0fe411c267e4384b0f600"
// expected = "90e87315fb7d4e1b4092ec0cbfda5d7d"
let X = [0xaa, 0xe0, 0x69, 0x92, 0xac, 0xbf, 0x52, 0xa3, 0xe8, 0xf4, 0xa9, 0x6e, 0xc9, 0x30, 0x0b, 0xd7];
let Y = [0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41, 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00];

const expected = [0x90, 0xe8, 0x73, 0x15, 0xfb, 0x7d, 0x4e, 0x1b, 0x40, 0x92, 0xec, 0x0c, 0xbf, 0xda, 0x5d, 0x7d];
await circuit.expectPass({ X: X, Y: Y }, { out: expected });
});

});

describe("debug1", () => {
19 changes: 15 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ mod tests {
};
use hex_literal::hex;

// first byte is 00000001
// first bit is 1
const H: [u8; 16] = hex!("80000000000000000000000000000000");
const X: [u8; 16] = hex!("80000000000000000000000000000000");

@@ -116,15 +116,26 @@ mod tests {
ghash.update(&[X.into()]);
let result = ghash.finalize();

// last bit is 1
const H_1: [u8; 16] = hex!("00000000000000000000000000000001");
const X_1: [u8; 16] = hex!("00000000000000000000000000000001");
// Alternative.

let mut ghash2 = GHash::new(&H_1.into());
ghash2.update(&[X_1.into()]);
let result2 = ghash2.finalize();

println!("GHASH result_1: {:?}", hex::encode(result.as_slice()));
println!("GHASH result_2: {:?}", hex::encode(result2.as_slice()));
// test vector of pain
const H_2: [u8; 16] = hex!("aae06992acbf52a3e8f4a96ec9300bd7");
const X_2: [u8; 16] = hex!("98e7247c07f0fe411c267e4384b0f600");

let mut ghash3 = GHash::new(&H_2.into());
ghash3.update(&[X_2.into()]);
let result3 = ghash3.finalize();

println!("GHASH Test vector 1: {:?}", hex::encode(result.as_slice()));
println!("GHASH Test vector 2: {:?}", hex::encode(result2.as_slice()));
println!("GHASH Test vector 3: {:?}", hex::encode(result3.as_slice()));

// println!("expected: {:?}", hex::encode(expected));

}

0 comments on commit 8e1864d

Please sign in to comment.