-
Notifications
You must be signed in to change notification settings - Fork 23
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
7 changed files
with
1,507 additions
and
359 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,22 +1,57 @@ | ||
use cairo_verifier::channel::channel::ChannelTrait; | ||
|
||
// === BLAKE ONLY BEGIN === | ||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_random_felts_to_prover() { | ||
// let mut channel = ChannelTrait::new( | ||
// u256 { low: 0xf7685ebd40e852b164633a4acbd3244c, high: 0xe8e77626586f73b955364c7b4bbf0bb7 } | ||
// ); | ||
// let random = channel.random_felts_to_prover(3); | ||
// assert( | ||
// *random[0] == 3199910790894706855027093840383592257502485581126271436027309705477370004002, | ||
// 'invalid random felts[0]' | ||
// ); | ||
// assert( | ||
// *random[1] == 2678311171676075552444787698918310126938416157877134200897080931937186268438, | ||
// 'invalid random felts[1]' | ||
// ); | ||
// assert( | ||
// *random[2] == 2409925148191156067407217062797240658947927224212800962983204460004996362724, | ||
// 'invalid random felts[2]' | ||
// ); | ||
// } | ||
// === BLAKE ONLY END === | ||
|
||
// === KECCAK ONLY BEGIN === | ||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_random_felts_to_prover() { | ||
let mut channel = ChannelTrait::new( | ||
u256 { low: 0xf7685ebd40e852b164633a4acbd3244c, high: 0xe8e77626586f73b955364c7b4bbf0bb7 } | ||
); | ||
let random = channel.random_felts_to_prover(3); | ||
assert( | ||
*random[0] == 3199910790894706855027093840383592257502485581126271436027309705477370004002, | ||
'invalid random felts[0]' | ||
let mut channel = ChannelTrait::new_with_counter( | ||
u256 { low: 0x31221b7950614c65772c2993e6727561, high: 0xfaa5d980c70cbe78934e534c13eaf18a }, | ||
0x0 | ||
); | ||
assert( | ||
*random[1] == 2678311171676075552444787698918310126938416157877134200897080931937186268438, | ||
'invalid random felts[1]' | ||
channel | ||
.random_felts_to_prover( | ||
6 | ||
) == array![ | ||
0x414b15fa27add0f6811a50e1c8b9f15817894a0bbfe4f7f295197c1012dfb18, | ||
0x5e0bb5569c25cb8b8836880bab4e2ce6d4a4daa7884f6ca843d68cb2eebec0b, | ||
0x38a8e373b08e1edebe3a42c2ac362c3677b34831d0d99ae08961fe96518b7d4, | ||
0x2a56da11e2abe0a267e2ba40166bb50163c182ac042b88f75f681d6f30c8f37, | ||
0x1824b7b0c6c0036c4998f345f4b34e1548a03dc637480ff0c6f315d4eacac4a, | ||
0x39a70b321a5d31147bf5c3299bb5946da16db82658b25af58802bfe64d6fc74, | ||
], | ||
'invalid random felts' | ||
); | ||
assert( | ||
*random[2] == 2409925148191156067407217062797240658947927224212800962983204460004996362724, | ||
'invalid random felts[2]' | ||
channel | ||
.digest == u256 { | ||
low: 0x31221b7950614c65772c2993e6727561, high: 0xfaa5d980c70cbe78934e534c13eaf18a | ||
}, | ||
'Invalid value' | ||
); | ||
assert(channel.counter == 0x6, 'Invalid value'); | ||
} | ||
// === KECCAK ONLY END === |
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,76 +1,152 @@ | ||
use cairo_verifier::channel::channel::ChannelTrait; | ||
|
||
// === BLAKE ONLY BEGIN === | ||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_random_uint256_to_prover_0() { | ||
// let mut channel = ChannelTrait::new_with_counter( | ||
// u256 { low: 0xf59fd6b10ccc33fe2e1e1e94e3411f56, high: 0x6572033443ae2c5f7b83bfdcd817240e }, | ||
// 0x0 | ||
// ); | ||
// assert( | ||
// channel | ||
// .random_uint256_to_prover() == u256 { | ||
// low: 0x5f1758ec5d5517006c3eac3c624dcda2, high: 0xb24fe50c70859073b185937f3e1eb93d | ||
// }, | ||
// 'Invalid value' | ||
// ); | ||
// } | ||
|
||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_random_uint256_to_prover_1() { | ||
// let mut channel = ChannelTrait::new_with_counter( | ||
// u256 { low: 0xf59fd6b10ccc33fe2e1e1e94e3411f56, high: 0x6572033443ae2c5f7b83bfdcd817240e }, | ||
// 0x1 | ||
// ); | ||
// assert( | ||
// channel | ||
// .random_uint256_to_prover() == u256 { | ||
// low: 0xad772a40c7f3c4e6f77db1daa5f8d8e, high: 0x96014698ef9d4df3438cf2da8aa483a4 | ||
// }, | ||
// 'Invalid value' | ||
// ); | ||
// } | ||
|
||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_random_uint256_to_prover_2() { | ||
// let mut channel = ChannelTrait::new_with_counter( | ||
// u256 { low: 0x8823a41f7994f81c6453f4bc3cad1c10, high: 0x75f85ae3fd3ff6b5f63029a51040037e }, | ||
// 0x0 | ||
// ); | ||
// assert( | ||
// channel | ||
// .random_uint256_to_prover() == u256 { | ||
// low: 0xf1466cd5383c0644def10ee2658b7a05, high: 0x32f0741071fba06bdee46d938b942542 | ||
// }, | ||
// 'Invalid value' | ||
// ); | ||
// } | ||
|
||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_random_uint256_to_prover_3() { | ||
// let mut channel = ChannelTrait::new_with_counter( | ||
// u256 { low: 0x89a405dfb23e546ad03d498e88dee3ba, high: 0xe614bdb3e56768f45a22fd34e999734c }, | ||
// 0x0 | ||
// ); | ||
// assert( | ||
// channel | ||
// .random_uint256_to_prover() == u256 { | ||
// low: 0x538dd6434921187f80b76fd1d804af3b, high: 0x1172f921f177f82f29a3d97f9cffd2df | ||
// }, | ||
// 'Invalid value' | ||
// ); | ||
// } | ||
|
||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_random_uint256_to_prover_4() { | ||
// let mut channel = ChannelTrait::new(0); | ||
// let random = channel.random_uint256_to_prover(); | ||
// assert( | ||
// random == 0xae09db7cd54f42b490ef09b6bc541af688e4959bb8c53f359a6f56e38ab454a3, | ||
// 'invalid random uint256' | ||
// ); | ||
// } | ||
// === BLAKE ONLY END === | ||
|
||
// === KECCAK ONLY BEGIN === | ||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_random_uint256_to_prover_0() { | ||
let mut channel = ChannelTrait::new_with_counter( | ||
u256 { low: 0xf59fd6b10ccc33fe2e1e1e94e3411f56, high: 0x6572033443ae2c5f7b83bfdcd817240e }, | ||
u256 { low: 0x31221b7950614c65772c2993e6727561, high: 0xfaa5d980c70cbe78934e534c13eaf18a }, | ||
0x0 | ||
); | ||
assert( | ||
channel | ||
.random_uint256_to_prover() == u256 { | ||
low: 0x5f1758ec5d5517006c3eac3c624dcda2, high: 0xb24fe50c70859073b185937f3e1eb93d | ||
low: 0x6249f523d42a9a89f8a41bbcffb837ee, high: 0x704fab98abe015f67ce8c5651141e746 | ||
}, | ||
'Invalid value' | ||
); | ||
assert( | ||
channel | ||
.digest == u256 { | ||
low: 0x31221b7950614c65772c2993e6727561, high: 0xfaa5d980c70cbe78934e534c13eaf18a | ||
}, | ||
'Invalid value' | ||
); | ||
assert(channel.counter == 0x1, 'Invalid value'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_random_uint256_to_prover_1() { | ||
let mut channel = ChannelTrait::new_with_counter( | ||
u256 { low: 0xf59fd6b10ccc33fe2e1e1e94e3411f56, high: 0x6572033443ae2c5f7b83bfdcd817240e }, | ||
0x1 | ||
u256 { low: 0x31221b7950614c65772c2993e6727561, high: 0xfaa5d980c70cbe78934e534c13eaf18a }, | ||
0x4 | ||
); | ||
assert( | ||
channel | ||
.random_uint256_to_prover() == u256 { | ||
low: 0xad772a40c7f3c4e6f77db1daa5f8d8e, high: 0x96014698ef9d4df3438cf2da8aa483a4 | ||
low: 0x9dd4eacd6e611a8f0da6dfcb9c1206d6, high: 0x67cb6d23cfb26dc408dac8c0c6a71602 | ||
}, | ||
'Invalid value' | ||
); | ||
} | ||
|
||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_random_uint256_to_prover_2() { | ||
let mut channel = ChannelTrait::new_with_counter( | ||
u256 { low: 0x8823a41f7994f81c6453f4bc3cad1c10, high: 0x75f85ae3fd3ff6b5f63029a51040037e }, | ||
0x0 | ||
); | ||
assert( | ||
channel | ||
.random_uint256_to_prover() == u256 { | ||
low: 0xf1466cd5383c0644def10ee2658b7a05, high: 0x32f0741071fba06bdee46d938b942542 | ||
.digest == u256 { | ||
low: 0x31221b7950614c65772c2993e6727561, high: 0xfaa5d980c70cbe78934e534c13eaf18a | ||
}, | ||
'Invalid value' | ||
); | ||
assert(channel.counter == 0x5, 'Invalid value'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_random_uint256_to_prover_3() { | ||
fn test_random_uint256_to_prover_2() { | ||
let mut channel = ChannelTrait::new_with_counter( | ||
u256 { low: 0x89a405dfb23e546ad03d498e88dee3ba, high: 0xe614bdb3e56768f45a22fd34e999734c }, | ||
0x0 | ||
u256 { low: 0x4ccd3b3aab8d3e3c4d99af0aa61de9d1, high: 0x8e5ef0503c12ab78b594db03b634546d }, | ||
0x3 | ||
); | ||
assert( | ||
channel | ||
.random_uint256_to_prover() == u256 { | ||
low: 0x538dd6434921187f80b76fd1d804af3b, high: 0x1172f921f177f82f29a3d97f9cffd2df | ||
low: 0x4220300fcccb24c97922cba73e4bcaa3, high: 0x6c733c0f5ab453eff35531225ebfcf65 | ||
}, | ||
'Invalid value' | ||
); | ||
} | ||
|
||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_random_uint256_to_prover_4() { | ||
let mut channel = ChannelTrait::new(0); | ||
let random = channel.random_uint256_to_prover(); | ||
assert( | ||
random == 0xae09db7cd54f42b490ef09b6bc541af688e4959bb8c53f359a6f56e38ab454a3, | ||
'invalid random uint256' | ||
channel | ||
.digest == u256 { | ||
low: 0x4ccd3b3aab8d3e3c4d99af0aa61de9d1, high: 0x8e5ef0503c12ab78b594db03b634546d | ||
}, | ||
'Invalid value' | ||
); | ||
assert(channel.counter == 0x4, 'Invalid value'); | ||
} | ||
// === KECCAK ONLY END === |
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,61 +1,100 @@ | ||
use cairo_verifier::channel::channel::ChannelTrait; | ||
|
||
// test data from cairo0-verifier run on stone-prover generated proof | ||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_read_felt_from_prover_0() { | ||
let mut channel = ChannelTrait::new_with_counter( | ||
u256 { low: 0x89a405dfb23e546ad03d498e88dee3ba, high: 0xe614bdb3e56768f45a22fd34e999734c }, | ||
0x1 | ||
); | ||
channel | ||
.read_felt_from_prover(0x3a63c21f32409c9ec7614199b40102547e7f698f903bdbbffe56785684b7e04); | ||
assert( | ||
channel | ||
.digest == u256 { | ||
low: 0xc123a2db28e4f285115f8c72934264ea, high: 0x810c2a15f74c5a93239754103cde49b0 | ||
}, | ||
'Invalid value' | ||
); | ||
assert(channel.counter == 0, 'Invalid value'); | ||
} | ||
// === BLAKE ONLY BEGIN === | ||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_read_felt_from_prover_0() { | ||
// let mut channel = ChannelTrait::new_with_counter( | ||
// u256 { low: 0x89a405dfb23e546ad03d498e88dee3ba, high: 0xe614bdb3e56768f45a22fd34e999734c }, | ||
// 0x1 | ||
// ); | ||
// channel | ||
// .read_felt_from_prover(0x3a63c21f32409c9ec7614199b40102547e7f698f903bdbbffe56785684b7e04); | ||
// assert( | ||
// channel | ||
// .digest == u256 { | ||
// low: 0xc123a2db28e4f285115f8c72934264ea, high: 0x810c2a15f74c5a93239754103cde49b0 | ||
// }, | ||
// 'Invalid value' | ||
// ); | ||
// assert(channel.counter == 0, 'Invalid value'); | ||
// } | ||
|
||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_read_felt_from_prover_1() { | ||
// let mut channel = ChannelTrait::new_with_counter( | ||
// u256 { low: 0xc123a2db28e4f285115f8c72934264ea, high: 0x810c2a15f74c5a93239754103cde49b0 }, | ||
// 0x0 | ||
// ); | ||
// channel | ||
// .read_felt_from_prover(0x5652f216d992bbf255b97dd1b0a4dde72fab97f1bbcc4a4f53fde7fc50293c8); | ||
// assert( | ||
// channel | ||
// .digest == u256 { | ||
// low: 0x5f72255a95751e54a4f9704096d61310, high: 0x3c9277c30982b407ad5442334e7771d4 | ||
// }, | ||
// 'Invalid value' | ||
// ); | ||
// assert(channel.counter == 0, 'Invalid value'); | ||
// } | ||
|
||
// test data from cairo0-verifier run on stone-prover generated proof | ||
// #[test] | ||
// #[available_gas(9999999999)] | ||
// fn test_read_felt_from_prover_2() { | ||
// let mut channel = ChannelTrait::new_with_counter( | ||
// u256 { low: 0xfc5a98310398b13c3218fdeb624ec8f8, high: 0x59dfc32f7867d987d2d504e264f97faa }, | ||
// 0x0 | ||
// ); | ||
// channel | ||
// .read_felt_from_prover(0x787521b50c17169b9729a4522e1a0e7bdc028fc8ffdd87c70147bd67c5595d3); | ||
// assert( | ||
// channel | ||
// .digest == u256 { | ||
// low: 0x746ca09ffaaea6826e10c1b343da771e, high: 0x24a6464484140e30a7f7497204b5abbe | ||
// }, | ||
// 'Invalid value' | ||
// ); | ||
// assert(channel.counter == 0, 'Invalid value'); | ||
// } | ||
// === BLAKE ONLY END === | ||
|
||
// === KECCAK ONLY BEGIN === | ||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_read_felt_from_prover_1() { | ||
fn test_read_felt_from_prover_0() { | ||
let mut channel = ChannelTrait::new_with_counter( | ||
u256 { low: 0xc123a2db28e4f285115f8c72934264ea, high: 0x810c2a15f74c5a93239754103cde49b0 }, | ||
u256 { low: 0x6b78b49c94cbdf349708a9d94a799c14, high: 0x83fed9107fa49a64270e4e0060b93633 }, | ||
0x0 | ||
); | ||
channel | ||
.read_felt_from_prover(0x5652f216d992bbf255b97dd1b0a4dde72fab97f1bbcc4a4f53fde7fc50293c8); | ||
.read_felt_from_prover(0x2bfd93b32c219ece244588f15f8aae89867abc7da1a579bf84ca9544f969c53); | ||
assert( | ||
channel | ||
.digest == u256 { | ||
low: 0x5f72255a95751e54a4f9704096d61310, high: 0x3c9277c30982b407ad5442334e7771d4 | ||
low: 0xa55020e872dfef9f7999a8f22098dfdf, high: 0xaaaf25698614d5c0216e7d570510039f | ||
}, | ||
'Invalid value' | ||
); | ||
assert(channel.counter == 0, 'Invalid value'); | ||
} | ||
|
||
// test data from cairo0-verifier run on stone-prover generated proof | ||
#[test] | ||
#[available_gas(9999999999)] | ||
fn test_read_felt_from_prover_2() { | ||
fn test_read_felt_from_prover_1() { | ||
let mut channel = ChannelTrait::new_with_counter( | ||
u256 { low: 0xfc5a98310398b13c3218fdeb624ec8f8, high: 0x59dfc32f7867d987d2d504e264f97faa }, | ||
u256 { low: 0x9245c7cf213bdcb501bdf9cb543e29e2, high: 0x4186a538a62f83802cde11ec1f7f4d29 }, | ||
0x0 | ||
); | ||
channel | ||
.read_felt_from_prover(0x787521b50c17169b9729a4522e1a0e7bdc028fc8ffdd87c70147bd67c5595d3); | ||
.read_felt_from_prover(0x5ab21b56b09e48e84b089eb21cd476ccb00fa7963b089a9ba9df2a0a5f3e49d); | ||
assert( | ||
channel | ||
.digest == u256 { | ||
low: 0x746ca09ffaaea6826e10c1b343da771e, high: 0x24a6464484140e30a7f7497204b5abbe | ||
low: 0x64c793e5f748d5d8c75d73916db389cb, high: 0x3616f6f0bfece8772bedda20d54a3d34 | ||
}, | ||
'Invalid value' | ||
); | ||
assert(channel.counter == 0, 'Invalid value'); | ||
} | ||
// === KECCAK ONLY END === |
Oops, something went wrong.