From 5bbe78376bdaaf6892e7cdae8b6adb4377c475b1 Mon Sep 17 00:00:00 2001 From: Constance Date: Wed, 19 Apr 2023 11:26:20 +0200 Subject: [PATCH 01/10] Update R constant for ZSA note commitment --- Cargo.toml | 6 +++--- src/note/commitment.rs | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e482b0f76..d52cf36ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,8 @@ blake2b_simd = "1" ff = "0.12" fpe = "0.5" group = { version = "0.12.1", features = ["wnaf-memuse"] } -halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "zsa1" } -halo2_proofs = { git = "https://github.com/QED-it/halo2", branch = "zsa1" } +halo2_gadgets = {git = "https://github.com/QED-it/halo2", branch = "commit_doamin_from_two_personalizations"} +halo2_proofs = {git = "https://github.com/QED-it/halo2", branch = "commit_doamin_from_two_personalizations"} hex = "0.4" lazy_static = "1" memuse = { version = "0.2.1", features = ["nonempty"] } @@ -52,7 +52,7 @@ plotters = { version = "0.3.0", optional = true } [dev-dependencies] criterion = "0.3" -halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "zsa1" , features = ["test-dependencies"] } +halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "commit_doamin_from_two_personalizations", features = ["test-dependencies"] } hex = "0.4" proptest = "1.0.0" zcash_note_encryption = { version = "0.2", features = ["pre-zip-212"] } diff --git a/src/note/commitment.rs b/src/note/commitment.rs index f95d8be82..55b13ecd7 100644 --- a/src/note/commitment.rs +++ b/src/note/commitment.rs @@ -83,7 +83,10 @@ impl NoteCommitment { bits: impl Iterator, rcm: NoteCommitTrapdoor, ) -> CtOption { - let domain = sinsemilla::CommitDomain::new(personalization); + let domain = sinsemilla::CommitDomain::new_with_two_personalizations( + personalization, + NOTE_COMMITMENT_PERSONALIZATION, + ); domain.commit(bits, &rcm.0).map(NoteCommitment) } } From a5b030d31141aec11fc3bcd5202f0572ff2c86a2 Mon Sep 17 00:00:00 2001 From: Constance Date: Wed, 19 Apr 2023 15:10:21 +0200 Subject: [PATCH 02/10] Update note_encryption_v3 test vectors --- src/test_vectors/note_encryption_v3.rs | 240 ++++++++++++------------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/src/test_vectors/note_encryption_v3.rs b/src/test_vectors/note_encryption_v3.rs index 0ea5da482..79b514869 100644 --- a/src/test_vectors/note_encryption_v3.rs +++ b/src/test_vectors/note_encryption_v3.rs @@ -2287,9 +2287,9 @@ pub(crate) fn test_vectors() -> Vec { 0xbc, 0xf8, 0x63, 0x37, ], cmx: [ - 0x85, 0xec, 0x16, 0xe8, 0x78, 0x77, 0x33, 0x37, 0x07, 0x9a, 0xec, 0xf3, 0x2c, 0x45, - 0x5e, 0xbf, 0x16, 0x96, 0x8d, 0xa1, 0xd4, 0x34, 0x51, 0xb7, 0xa3, 0x06, 0x87, 0x6c, - 0xa3, 0x08, 0xea, 0x3c, + 0x20, 0x43, 0xa5, 0x58, 0x39, 0x9e, 0x2e, 0xed, 0x91, 0xd9, 0x5d, 0x32, 0xe6, 0xd6, + 0x7c, 0x93, 0xdb, 0x08, 0xe2, 0x15, 0x15, 0x02, 0x85, 0x8d, 0x8b, 0x77, 0x54, 0x87, + 0x5f, 0x10, 0x89, 0x32, ], esk: [ 0x05, 0x18, 0xdd, 0xc0, 0xc4, 0x7b, 0x7f, 0x77, 0xed, 0xcd, 0x39, 0x16, 0x0f, 0xe5, @@ -2403,9 +2403,9 @@ pub(crate) fn test_vectors() -> Vec { 0xc3, 0xcf, 0xc9, 0xca, 0xd8, 0xdb, 0x82, 0x3f, 0xbd, 0x74, ], ock: [ - 0xc6, 0x7c, 0x23, 0x33, 0xc3, 0xcf, 0x4a, 0xc4, 0x6e, 0xde, 0x34, 0xe3, 0xe3, 0xe0, - 0xdb, 0xff, 0x1e, 0x96, 0xb7, 0xa7, 0x8f, 0x16, 0xaa, 0xef, 0x1c, 0x74, 0xa3, 0xef, - 0x07, 0xc5, 0x97, 0x16, + 0x9b, 0x8e, 0x79, 0x56, 0x76, 0x38, 0xa2, 0xee, 0x38, 0x72, 0x5a, 0x94, 0x28, 0x99, + 0xa5, 0xa3, 0xbd, 0xd6, 0x88, 0xdb, 0x76, 0x38, 0x99, 0x7c, 0x77, 0x27, 0x6d, 0x27, + 0x0c, 0x87, 0xd2, 0xa3, ], op: [ 0x05, 0x82, 0x53, 0xd4, 0x85, 0x76, 0x44, 0x88, 0x5e, 0x26, 0xa9, 0x09, 0xc8, 0x38, @@ -2415,12 +2415,12 @@ pub(crate) fn test_vectors() -> Vec { 0xe0, 0xd2, 0x9b, 0x35, 0x9a, 0xc4, 0xfa, 0x2c, ], c_out: [ - 0xe4, 0xba, 0x0e, 0xa2, 0x92, 0x3b, 0x40, 0x19, 0xac, 0x8a, 0xbc, 0xd1, 0x9b, 0xe6, - 0x1c, 0x90, 0xf1, 0x8e, 0xef, 0xae, 0x87, 0xc4, 0xed, 0x8c, 0x76, 0x70, 0x85, 0xba, - 0xa8, 0x3b, 0x4d, 0x61, 0x0c, 0xf3, 0x63, 0x70, 0xda, 0x07, 0x90, 0x1e, 0xad, 0x6d, - 0x4f, 0x4b, 0x71, 0xdc, 0xae, 0x31, 0x1f, 0xa0, 0x36, 0x40, 0x6d, 0x64, 0x7b, 0x7e, - 0xe1, 0x41, 0x1e, 0xf5, 0xae, 0xe0, 0x34, 0x68, 0xb1, 0x09, 0x13, 0xc9, 0x90, 0xcb, - 0x61, 0x61, 0x22, 0xeb, 0xbe, 0x49, 0xda, 0x67, 0x81, 0xc2, + 0xe6, 0xe7, 0xa3, 0x48, 0xf3, 0x3a, 0xdd, 0x64, 0x22, 0x87, 0xc5, 0xf8, 0xf0, 0x9a, + 0x5a, 0xae, 0xd7, 0x9d, 0xf6, 0x70, 0xcc, 0x29, 0x74, 0x78, 0xc2, 0x27, 0x11, 0xe3, + 0x4e, 0xfa, 0x00, 0x88, 0x1d, 0x34, 0xb8, 0x7c, 0x0f, 0x69, 0xcb, 0x55, 0xd9, 0x1d, + 0x91, 0x1d, 0x2d, 0x84, 0x1e, 0x5e, 0xf6, 0x40, 0x38, 0x24, 0xdc, 0x9d, 0x7c, 0x55, + 0x1c, 0xdb, 0xae, 0xb4, 0xa6, 0xfb, 0x46, 0x8e, 0xc0, 0x39, 0xbc, 0x84, 0x17, 0x79, + 0xa0, 0xd7, 0xbf, 0xc3, 0x1b, 0xe2, 0x0b, 0x34, 0xee, 0x25, ], }, TestVector { @@ -2505,9 +2505,9 @@ pub(crate) fn test_vectors() -> Vec { 0xb6, 0xf6, 0x4c, 0x26, ], cmx: [ - 0x40, 0x8f, 0x59, 0x4f, 0xdd, 0xc5, 0x0c, 0x67, 0xf5, 0x47, 0xe1, 0xeb, 0x3e, 0xa2, - 0x99, 0xa3, 0x1f, 0x69, 0xf5, 0x7f, 0xc9, 0x92, 0x03, 0x01, 0x42, 0x90, 0x35, 0xa6, - 0xc2, 0x49, 0x79, 0x1a, + 0xf0, 0x32, 0x44, 0xf8, 0x87, 0xe7, 0x5e, 0x45, 0x2f, 0xf0, 0x06, 0x89, 0x64, 0x44, + 0x2c, 0x9b, 0xc1, 0x03, 0x48, 0xec, 0xa6, 0xc2, 0xbc, 0x46, 0xcc, 0x85, 0xda, 0x5d, + 0x34, 0x0b, 0x43, 0x35, ], esk: [ 0xcb, 0xfc, 0x51, 0x10, 0xff, 0x2f, 0xe9, 0xc5, 0xd5, 0x9e, 0xef, 0x08, 0xbd, 0xf6, @@ -2621,9 +2621,9 @@ pub(crate) fn test_vectors() -> Vec { 0x83, 0x95, 0xa3, 0x99, 0x63, 0x65, 0xa2, 0x0c, 0x22, 0x9e, ], ock: [ - 0x2f, 0x88, 0x37, 0x27, 0xb5, 0x4d, 0x06, 0x25, 0xcf, 0xdc, 0x19, 0x5a, 0xce, 0x10, - 0xca, 0xc0, 0x26, 0x8a, 0xba, 0x3d, 0xe2, 0x8a, 0xd6, 0x08, 0x88, 0x06, 0x50, 0x6d, - 0x69, 0xc4, 0xdd, 0x8e, + 0xb9, 0x64, 0x28, 0x18, 0x81, 0x8d, 0x69, 0x17, 0x6d, 0x6c, 0xe6, 0x08, 0x88, 0x7d, + 0x75, 0x70, 0x58, 0xc7, 0x35, 0x42, 0x74, 0xac, 0xa2, 0xb8, 0x7b, 0x50, 0xf7, 0xa6, + 0x38, 0x52, 0x51, 0x1b, ], op: [ 0x7a, 0xfc, 0xa0, 0x5d, 0x04, 0x2c, 0x84, 0x3e, 0xec, 0xdc, 0x37, 0x24, 0x10, 0x52, @@ -2633,12 +2633,12 @@ pub(crate) fn test_vectors() -> Vec { 0xf5, 0x3b, 0x57, 0xc3, 0x45, 0xa9, 0x87, 0x2f, ], c_out: [ - 0x99, 0x96, 0x90, 0xd4, 0xcd, 0xd9, 0xe7, 0x6b, 0x07, 0x2c, 0x3c, 0x4c, 0x41, 0xbf, - 0xc7, 0x9a, 0xaa, 0xc6, 0x7f, 0xdc, 0x0f, 0x41, 0xe8, 0x0e, 0x95, 0x48, 0x80, 0x0e, - 0xef, 0xbc, 0x95, 0x74, 0xf1, 0x5d, 0x64, 0xa6, 0x9e, 0x44, 0x47, 0xc4, 0x5b, 0x07, - 0x0c, 0x6c, 0x9f, 0x50, 0x0a, 0xdd, 0xef, 0x6f, 0x57, 0x14, 0xa5, 0x76, 0x22, 0x1f, - 0x3f, 0xbc, 0x61, 0x22, 0x8d, 0x95, 0xc3, 0xac, 0xe4, 0x21, 0x4b, 0xb6, 0xcf, 0x5b, - 0xd9, 0x69, 0x84, 0xd7, 0x78, 0x96, 0x0d, 0xe9, 0x0c, 0x02, + 0xa2, 0xd6, 0x5e, 0x96, 0x7e, 0x98, 0x89, 0x0e, 0x9c, 0x42, 0xf9, 0xb3, 0x4b, 0xf8, + 0x45, 0xfb, 0x8e, 0xaa, 0xf9, 0x20, 0x45, 0x0b, 0x29, 0xec, 0x06, 0x16, 0xb3, 0xf0, + 0x82, 0xea, 0x90, 0x8c, 0x66, 0x87, 0xf4, 0xf9, 0x74, 0x1a, 0xe8, 0xab, 0x81, 0x30, + 0x15, 0x35, 0xfd, 0x10, 0x30, 0x35, 0x7a, 0x78, 0xb2, 0x07, 0xf1, 0xc4, 0x42, 0x77, + 0xf5, 0x03, 0xdb, 0x42, 0xa2, 0xc4, 0xdd, 0x20, 0x25, 0x33, 0x2f, 0x49, 0x5e, 0x88, + 0x31, 0x1b, 0x4c, 0x2f, 0x66, 0xb6, 0x07, 0x29, 0x04, 0x89, ], }, TestVector { @@ -2723,9 +2723,9 @@ pub(crate) fn test_vectors() -> Vec { 0x1d, 0x40, 0x9b, 0x33, ], cmx: [ - 0x9e, 0x3d, 0x61, 0x35, 0x6b, 0x0d, 0x88, 0x95, 0x9e, 0x3f, 0x0f, 0xcc, 0x4a, 0x93, - 0x2e, 0x93, 0x2e, 0xac, 0xbc, 0x80, 0x1d, 0x48, 0xc0, 0x19, 0x5b, 0x9c, 0x8b, 0xd1, - 0x05, 0x5a, 0x8e, 0x2e, + 0xf5, 0x3a, 0x98, 0x99, 0xcd, 0x37, 0xf6, 0x2c, 0x94, 0x85, 0x84, 0xb9, 0x67, 0x7c, + 0x78, 0x4c, 0x73, 0x48, 0x43, 0x40, 0x1a, 0x3a, 0x61, 0x0a, 0xcb, 0x28, 0x2f, 0x04, + 0x30, 0xfd, 0x18, 0x3c, ], esk: [ 0x1b, 0x52, 0x63, 0x2d, 0x2a, 0x8d, 0x58, 0xd1, 0x63, 0x57, 0xa9, 0x19, 0xa2, 0x06, @@ -2839,9 +2839,9 @@ pub(crate) fn test_vectors() -> Vec { 0x1c, 0x60, 0x78, 0xb0, 0x8d, 0x72, 0x2d, 0xc4, 0x4a, 0xb7, ], ock: [ - 0x9c, 0xba, 0xd2, 0xf3, 0x8b, 0xf8, 0x8f, 0x39, 0x47, 0xce, 0xf6, 0x4d, 0xe7, 0xa6, - 0xf4, 0x3e, 0x4c, 0xbb, 0x41, 0xe6, 0xe0, 0x37, 0xf1, 0x42, 0x01, 0xae, 0xe8, 0xab, - 0xfd, 0xf8, 0xa2, 0x35, + 0x67, 0x0e, 0xa5, 0x94, 0x8e, 0x85, 0x29, 0xa9, 0x52, 0xb2, 0x0a, 0xcc, 0x17, 0x70, + 0xe2, 0xa9, 0xc0, 0x67, 0xb0, 0x7b, 0x89, 0xfd, 0xaa, 0xf7, 0x84, 0xdf, 0x83, 0xfd, + 0x53, 0x7b, 0xdd, 0x86, ], op: [ 0x84, 0xda, 0x49, 0x6b, 0x16, 0x0a, 0x81, 0x72, 0xc4, 0x8d, 0x76, 0xb4, 0xfb, 0x08, @@ -2851,12 +2851,12 @@ pub(crate) fn test_vectors() -> Vec { 0x25, 0xec, 0xff, 0x47, 0x72, 0x16, 0x8c, 0x05, ], c_out: [ - 0xf6, 0x25, 0xcd, 0x3d, 0x19, 0x97, 0xb0, 0xd3, 0xf2, 0x29, 0x5a, 0xac, 0xc0, 0x3a, - 0xe0, 0xc9, 0x47, 0x28, 0xb3, 0x3c, 0xc4, 0xf1, 0x6f, 0xd4, 0x28, 0xd6, 0x5f, 0x3c, - 0x78, 0x5e, 0x8c, 0x0b, 0xb4, 0x66, 0xc1, 0x33, 0xd4, 0x83, 0xdf, 0xc5, 0xb1, 0xb3, - 0x15, 0x1d, 0xa2, 0xd5, 0xf2, 0x4a, 0x2b, 0x32, 0x0d, 0x8e, 0x9c, 0xd3, 0x41, 0x5c, - 0x25, 0xb6, 0xf9, 0x76, 0x1f, 0x42, 0x70, 0x04, 0xce, 0xe5, 0x4f, 0x75, 0xf1, 0x25, - 0xbc, 0x50, 0x5e, 0xf6, 0x26, 0xef, 0xc9, 0xdd, 0x63, 0x66, + 0x20, 0xe0, 0x0c, 0xab, 0xc6, 0xc7, 0x06, 0xfa, 0x38, 0x19, 0x16, 0x78, 0x26, 0x44, + 0x90, 0x28, 0x9e, 0x0e, 0xd3, 0x2b, 0x9c, 0x77, 0x6d, 0xa2, 0xab, 0xe0, 0x21, 0x4f, + 0x89, 0x9b, 0xf9, 0x7b, 0x08, 0x3b, 0xe5, 0x8e, 0xdd, 0xbb, 0x57, 0x97, 0x28, 0x22, + 0xbb, 0x10, 0x8e, 0x2c, 0xad, 0xfc, 0x76, 0xab, 0xe6, 0x13, 0x13, 0x9e, 0x94, 0x1c, + 0x2c, 0xa1, 0x59, 0x21, 0x98, 0x91, 0xb1, 0x52, 0x83, 0xd8, 0x5a, 0x0d, 0xc9, 0x4d, + 0x59, 0xf9, 0x7b, 0x6c, 0x3c, 0x53, 0x6f, 0xcf, 0x93, 0x98, ], }, TestVector { @@ -2941,9 +2941,9 @@ pub(crate) fn test_vectors() -> Vec { 0x14, 0x7a, 0x27, 0x10, ], cmx: [ - 0xf2, 0x04, 0x22, 0x51, 0xa0, 0x59, 0xa2, 0xf5, 0x8a, 0xb8, 0xe9, 0x0b, 0x52, 0x64, - 0xd0, 0xa4, 0x3f, 0x96, 0xd7, 0x7e, 0xdd, 0x54, 0xf8, 0x0f, 0xf4, 0x9d, 0x43, 0x86, - 0x81, 0x4d, 0x73, 0x2e, + 0x82, 0x9c, 0x4a, 0x9c, 0x2a, 0x01, 0x66, 0xc9, 0xba, 0x2e, 0x16, 0x9e, 0xdd, 0xda, + 0xe6, 0xdb, 0x59, 0xf0, 0x12, 0xa7, 0x26, 0x29, 0xce, 0x34, 0xf6, 0xc2, 0x88, 0x7e, + 0xfb, 0xe1, 0xd9, 0x3f, ], esk: [ 0xb5, 0x9a, 0x18, 0x4d, 0x24, 0xe6, 0x1b, 0x9f, 0x9d, 0x37, 0x1d, 0xa4, 0xb1, 0x44, @@ -3057,9 +3057,9 @@ pub(crate) fn test_vectors() -> Vec { 0xbc, 0x7a, 0xf6, 0x72, 0xb2, 0x0d, 0x7a, 0x16, 0xec, 0x48, ], ock: [ - 0x97, 0x9b, 0x31, 0x5d, 0x3e, 0x1f, 0x5c, 0xa1, 0x8a, 0x92, 0x86, 0xd9, 0x2c, 0xc8, - 0x8e, 0x63, 0x62, 0x4b, 0x39, 0x9b, 0x29, 0x19, 0xbf, 0x4e, 0x67, 0xda, 0x7c, 0xd3, - 0x94, 0xf4, 0x5c, 0x49, + 0xa8, 0xa5, 0x77, 0x53, 0x40, 0x60, 0x3d, 0xad, 0x7d, 0x52, 0x3c, 0x94, 0x64, 0x4b, + 0x4d, 0x3f, 0x61, 0x92, 0xfb, 0x19, 0x8e, 0x8d, 0xe5, 0x70, 0x61, 0x52, 0xf4, 0x55, + 0x68, 0x24, 0x58, 0x73, ], op: [ 0x04, 0x47, 0x12, 0x42, 0xe1, 0xf4, 0x2b, 0xf0, 0x81, 0xf0, 0x8e, 0x9d, 0x71, 0xfe, @@ -3069,12 +3069,12 @@ pub(crate) fn test_vectors() -> Vec { 0xaf, 0x2b, 0xd1, 0xa0, 0x8c, 0x67, 0xd9, 0x3f, ], c_out: [ - 0x83, 0xf7, 0xa1, 0xda, 0x72, 0x4d, 0xd1, 0x54, 0xe7, 0xd9, 0x47, 0xc0, 0xfc, 0x83, - 0x42, 0x87, 0xf3, 0x3c, 0xd4, 0xb3, 0x4a, 0xfa, 0xc0, 0xda, 0x55, 0xe4, 0x37, 0xaf, - 0xae, 0x67, 0xa9, 0x9c, 0xbd, 0x89, 0x75, 0xc9, 0x54, 0xcf, 0x41, 0xaa, 0x1e, 0x9a, - 0x8f, 0x99, 0x98, 0x3d, 0x58, 0x6f, 0x5e, 0x35, 0x37, 0xda, 0xb7, 0x2a, 0xe1, 0x82, - 0x7a, 0xa5, 0xdf, 0xc9, 0xdd, 0xad, 0x06, 0x26, 0x78, 0x84, 0x6f, 0xf8, 0x09, 0x3d, - 0xfd, 0x15, 0xf6, 0x3d, 0x47, 0xe5, 0xa3, 0xbb, 0x74, 0x39, + 0xe3, 0x49, 0x59, 0x73, 0x78, 0x12, 0xaf, 0x29, 0xef, 0x95, 0x78, 0x3d, 0xcf, 0xb2, + 0xfd, 0x19, 0xab, 0x10, 0xd2, 0x17, 0xdd, 0x7d, 0x7f, 0xa6, 0x9e, 0x45, 0x21, 0xfe, + 0x8e, 0xce, 0x1a, 0x86, 0xee, 0x5b, 0xaf, 0x9d, 0xe8, 0x51, 0x2f, 0x84, 0xa2, 0xb9, + 0x12, 0xbf, 0xa3, 0x2e, 0x50, 0xc9, 0x1e, 0xfc, 0xfa, 0x14, 0x50, 0xb7, 0xdb, 0x82, + 0xd5, 0xa2, 0xa9, 0x9d, 0x40, 0xf7, 0xbd, 0x6d, 0x66, 0xd5, 0xaa, 0x9a, 0x13, 0xec, + 0xc1, 0x61, 0x05, 0x74, 0x0a, 0x68, 0xdb, 0xd9, 0x5e, 0x0a, ], }, TestVector { @@ -3159,9 +3159,9 @@ pub(crate) fn test_vectors() -> Vec { 0xb9, 0xd0, 0xb7, 0x32, ], cmx: [ - 0xe1, 0xc7, 0x67, 0xf3, 0x30, 0x15, 0xb5, 0xe2, 0x4a, 0x9a, 0xa5, 0x8b, 0x64, 0x7b, - 0x6b, 0x61, 0x32, 0x3c, 0xd3, 0x47, 0xe7, 0x21, 0x4c, 0x29, 0x1d, 0x09, 0x95, 0xc0, - 0xf5, 0xa6, 0x93, 0x2f, + 0xde, 0x71, 0x70, 0xc9, 0xd8, 0x0f, 0x64, 0x00, 0x29, 0x73, 0xc2, 0xc7, 0x58, 0x02, + 0x7b, 0xc4, 0x38, 0xe5, 0x83, 0x68, 0x56, 0xa7, 0x40, 0x03, 0x20, 0xb1, 0xbd, 0xe2, + 0xed, 0xa1, 0x7d, 0x31, ], esk: [ 0xc0, 0xdb, 0x43, 0x69, 0x10, 0x03, 0x45, 0x7d, 0x61, 0xfb, 0x58, 0x93, 0x20, 0x26, @@ -3275,9 +3275,9 @@ pub(crate) fn test_vectors() -> Vec { 0xb7, 0xd7, 0xef, 0xa4, 0xf4, 0xd0, 0x18, 0x2d, 0xa4, 0xc4, ], ock: [ - 0x55, 0x0e, 0xbf, 0x98, 0x83, 0x6c, 0xce, 0x43, 0x52, 0x25, 0xa1, 0x4b, 0xa6, 0x52, - 0xa7, 0xd5, 0x58, 0xcf, 0x5f, 0x3f, 0x7a, 0xfb, 0x00, 0xb0, 0x24, 0x70, 0xe8, 0xe4, - 0xd2, 0x6d, 0xb7, 0x9c, + 0x9d, 0x33, 0x8d, 0x19, 0x91, 0xba, 0x13, 0xfe, 0xe7, 0x37, 0x70, 0x9b, 0x7a, 0xbb, + 0x50, 0x77, 0x8d, 0xe1, 0xd8, 0x2f, 0xdb, 0x6b, 0x34, 0x7f, 0x58, 0xdd, 0xf5, 0x78, + 0xdd, 0x54, 0x42, 0xd7, ], op: [ 0x49, 0x19, 0x01, 0x2e, 0x40, 0x43, 0x82, 0xeb, 0xee, 0x8e, 0x60, 0xe9, 0xd4, 0xf1, @@ -3287,12 +3287,12 @@ pub(crate) fn test_vectors() -> Vec { 0x44, 0x72, 0x83, 0xf9, 0x4e, 0xd5, 0x95, 0x3d, ], c_out: [ - 0x9a, 0x01, 0xb7, 0x5e, 0x27, 0xea, 0x97, 0x51, 0x45, 0x5d, 0x54, 0xf2, 0xa5, 0x2b, - 0x88, 0x4b, 0x45, 0x6a, 0x6f, 0xc3, 0xda, 0xdb, 0xec, 0x79, 0xbf, 0x4d, 0x10, 0xbe, - 0x06, 0x7b, 0xef, 0x3e, 0xa2, 0xa5, 0xc0, 0x59, 0x81, 0xd4, 0x06, 0x05, 0x6a, 0x2f, - 0xf6, 0x4c, 0xb4, 0xc6, 0xfd, 0x46, 0x7d, 0xa8, 0x0b, 0xa1, 0x17, 0x48, 0xe9, 0xe2, - 0xae, 0x07, 0xb7, 0x62, 0xdf, 0x9d, 0x4a, 0x23, 0x58, 0x77, 0xf5, 0x8f, 0x43, 0x24, - 0xd8, 0x00, 0x3c, 0x32, 0x4f, 0xd9, 0xc6, 0x39, 0xbc, 0xa6, + 0x1f, 0x61, 0xfa, 0x64, 0x74, 0xce, 0xd5, 0x5b, 0xcf, 0xc9, 0x40, 0x5f, 0x9b, 0x07, + 0xc6, 0x02, 0xb9, 0x71, 0x4b, 0xf4, 0x02, 0x1d, 0x59, 0x4d, 0x72, 0xcf, 0xc6, 0x46, + 0x13, 0xd9, 0x01, 0x0c, 0x92, 0x4a, 0x7a, 0xc6, 0x74, 0x5d, 0x04, 0x8b, 0x15, 0xcc, + 0x94, 0xc4, 0x86, 0x4d, 0x1e, 0x0b, 0x4b, 0x43, 0x55, 0xac, 0x8e, 0xbb, 0x40, 0xee, + 0x36, 0x14, 0x00, 0x11, 0xf4, 0xc0, 0x1b, 0x3f, 0x53, 0xc0, 0xf6, 0x3a, 0xb5, 0x64, + 0x74, 0x81, 0x27, 0x73, 0x0e, 0x6c, 0x58, 0x4a, 0xf9, 0xb3, ], }, TestVector { @@ -3377,9 +3377,9 @@ pub(crate) fn test_vectors() -> Vec { 0x41, 0x84, 0x28, 0x2a, ], cmx: [ - 0xd7, 0x60, 0xac, 0xdb, 0xca, 0xda, 0xd1, 0x88, 0x08, 0x4f, 0xe4, 0x1a, 0x5c, 0x03, - 0xc2, 0xc8, 0xce, 0x34, 0xe1, 0x5f, 0x9d, 0xf4, 0x7b, 0x86, 0x9c, 0x44, 0xc7, 0x21, - 0x13, 0xa4, 0x0c, 0x3d, + 0x1e, 0xaa, 0x25, 0x97, 0xb0, 0x8f, 0x7c, 0x9c, 0x57, 0x9c, 0xe1, 0x43, 0xb7, 0xfb, + 0x2b, 0x10, 0x33, 0x82, 0xff, 0x63, 0x77, 0xb1, 0xc8, 0xbf, 0xbc, 0xcd, 0x8d, 0xa2, + 0x97, 0xe0, 0xa9, 0x0c, ], esk: [ 0x9b, 0x32, 0x77, 0x19, 0x3b, 0x63, 0x60, 0x8e, 0x6a, 0x3d, 0xdf, 0x7c, 0xe2, 0xd2, @@ -3493,9 +3493,9 @@ pub(crate) fn test_vectors() -> Vec { 0x2d, 0xb3, 0x35, 0x6e, 0x11, 0x4d, 0xbc, 0xa3, 0xc5, 0xd8, ], ock: [ - 0x53, 0x29, 0x6e, 0xed, 0x43, 0xb4, 0xeb, 0x30, 0xa4, 0x3d, 0x88, 0x90, 0x2f, 0x74, - 0x04, 0x26, 0x62, 0x1d, 0x85, 0x21, 0x3a, 0x36, 0xc5, 0x20, 0xa1, 0x84, 0xa4, 0x3a, - 0xfb, 0xd4, 0x89, 0x6d, + 0x3c, 0x85, 0x16, 0x2e, 0x48, 0x67, 0xfc, 0x45, 0x89, 0xf6, 0xc6, 0x07, 0x69, 0x3b, + 0x8f, 0x4a, 0x7e, 0x85, 0xe0, 0x19, 0xf2, 0x33, 0x2f, 0xeb, 0xff, 0x08, 0xcb, 0xad, + 0x99, 0x4b, 0x3e, 0x81, ], op: [ 0x64, 0xce, 0xac, 0xec, 0x3c, 0x2e, 0xa7, 0x9c, 0x4c, 0xd3, 0xe2, 0xf0, 0xfb, 0xb9, @@ -3505,12 +3505,12 @@ pub(crate) fn test_vectors() -> Vec { 0x86, 0x48, 0x56, 0x2c, 0xbd, 0x86, 0x3f, 0x09, ], c_out: [ - 0x38, 0xee, 0x14, 0xef, 0xb0, 0x63, 0x94, 0x64, 0x44, 0x6f, 0x5f, 0xb8, 0x79, 0x5d, - 0x23, 0xf8, 0x8c, 0xf5, 0x65, 0x37, 0xe6, 0x4e, 0x1a, 0x46, 0x63, 0x17, 0xb3, 0x6f, - 0x22, 0x2e, 0x00, 0x5b, 0x92, 0x4c, 0xc9, 0x10, 0xd6, 0x29, 0x06, 0x6e, 0x05, 0x07, - 0xcb, 0x91, 0x2b, 0x0b, 0xc1, 0xd3, 0x16, 0xc2, 0x00, 0xb1, 0xa9, 0x56, 0x49, 0xc0, - 0xc5, 0x30, 0xb4, 0xf3, 0xd0, 0x43, 0x06, 0x8e, 0xf6, 0xf4, 0x2d, 0xcb, 0xef, 0xd0, - 0x2a, 0x34, 0x80, 0xe3, 0x2a, 0xa4, 0x5e, 0x33, 0xce, 0x25, + 0x92, 0x05, 0x27, 0xe0, 0x4a, 0xa5, 0x39, 0xdd, 0x95, 0x62, 0x23, 0x36, 0xea, 0x92, + 0xa8, 0xd5, 0x7a, 0x34, 0xd8, 0x7d, 0xac, 0x1c, 0x8d, 0xfd, 0x1b, 0x95, 0x4d, 0xfb, + 0x17, 0x70, 0x72, 0xfc, 0xbd, 0x1b, 0xa0, 0x7c, 0x28, 0x45, 0x1b, 0xa0, 0x99, 0xd6, + 0x3a, 0xb0, 0xb0, 0x51, 0x6d, 0x41, 0xe4, 0xb4, 0x3f, 0x04, 0xc7, 0xe3, 0xb5, 0x3a, + 0xec, 0xd0, 0xa0, 0x48, 0x34, 0x24, 0x48, 0xa8, 0x17, 0x60, 0xa4, 0x1e, 0x6e, 0x85, + 0x48, 0x02, 0x25, 0x43, 0xd6, 0x39, 0xb8, 0x9e, 0xa7, 0x46, ], }, TestVector { @@ -3595,9 +3595,9 @@ pub(crate) fn test_vectors() -> Vec { 0x4e, 0xb3, 0xa2, 0x08, ], cmx: [ - 0x8f, 0x56, 0xd1, 0x3f, 0xd9, 0xc8, 0x3e, 0xb7, 0x1b, 0x95, 0x87, 0x7a, 0x4f, 0x29, - 0x39, 0x64, 0xbf, 0x3f, 0x73, 0x1d, 0x8d, 0xf2, 0x04, 0x32, 0x2c, 0xed, 0xcb, 0x38, - 0x68, 0x21, 0x90, 0x3c, + 0xb5, 0x62, 0x5f, 0xa5, 0xfb, 0xeb, 0xa7, 0xc9, 0xea, 0xff, 0xff, 0x7d, 0xf4, 0x75, + 0xdc, 0x82, 0x33, 0x22, 0xee, 0x88, 0x01, 0x70, 0x56, 0x45, 0xe5, 0x62, 0x7e, 0x4a, + 0xca, 0x36, 0x6c, 0x02, ], esk: [ 0x24, 0x50, 0xae, 0xde, 0xb9, 0x7e, 0x62, 0xd7, 0x9c, 0xcb, 0x44, 0xb0, 0xb0, 0x4f, @@ -3711,9 +3711,9 @@ pub(crate) fn test_vectors() -> Vec { 0xb9, 0x5e, 0x7f, 0x63, 0xcb, 0x5c, 0xfa, 0xf5, 0xca, 0xc1, ], ock: [ - 0x2a, 0x2e, 0x0d, 0x99, 0x69, 0xf0, 0x2e, 0xbd, 0xb6, 0xd9, 0xc8, 0xe7, 0xe6, 0xfd, - 0xde, 0x20, 0x85, 0x12, 0x4b, 0x19, 0xad, 0x70, 0x90, 0xcc, 0x26, 0x15, 0x1d, 0x4d, - 0xa4, 0x2a, 0x00, 0x3e, + 0xc3, 0xd1, 0x04, 0x73, 0x14, 0x50, 0x57, 0x52, 0x3a, 0x55, 0xb7, 0x25, 0xcb, 0x2b, + 0x25, 0xd4, 0xe1, 0xe0, 0x5b, 0xc2, 0xfe, 0x4b, 0xbe, 0xbe, 0xb4, 0xd4, 0x2a, 0x61, + 0x8a, 0xbc, 0xd8, 0xbc, ], op: [ 0x9a, 0xe4, 0x94, 0xa9, 0xfc, 0xff, 0x9b, 0x74, 0x49, 0x14, 0x53, 0x31, 0x04, 0x4f, @@ -3723,12 +3723,12 @@ pub(crate) fn test_vectors() -> Vec { 0xa9, 0xec, 0x88, 0x17, 0x18, 0x65, 0x40, 0x33, ], c_out: [ - 0x74, 0x6a, 0xae, 0x9d, 0xa6, 0x1c, 0x02, 0xae, 0xaa, 0x8b, 0xed, 0xbe, 0x2b, 0x6c, - 0x84, 0x1b, 0xc4, 0x36, 0x17, 0x3c, 0x7c, 0x91, 0x13, 0x66, 0x3a, 0x39, 0xc1, 0x74, - 0x69, 0x29, 0x0b, 0xd2, 0x19, 0xea, 0xdc, 0x4a, 0x97, 0x5a, 0xd0, 0x52, 0xd0, 0x5d, - 0xc0, 0xa3, 0x08, 0xf3, 0x63, 0xf9, 0x22, 0x68, 0x2d, 0x75, 0x21, 0x9d, 0xaa, 0x33, - 0x6f, 0x69, 0xb5, 0x9e, 0x86, 0x7c, 0x85, 0xd9, 0x37, 0x34, 0x4c, 0x19, 0xd3, 0x88, - 0x01, 0x63, 0x19, 0xb3, 0xf6, 0x0f, 0x76, 0xd0, 0x28, 0x93, + 0x74, 0xd2, 0x40, 0xe8, 0xbe, 0x49, 0xb2, 0xa1, 0xad, 0x31, 0x8c, 0xfe, 0xf8, 0x43, + 0x5b, 0x79, 0x7f, 0x71, 0xfa, 0x8b, 0xda, 0x90, 0xed, 0x98, 0x4b, 0x15, 0x69, 0x7c, + 0x3e, 0x34, 0x81, 0x8f, 0x48, 0x96, 0x53, 0x79, 0x0f, 0xe7, 0x04, 0xc8, 0x16, 0x62, + 0xd9, 0xfb, 0x70, 0xde, 0x53, 0x63, 0xca, 0x17, 0xf6, 0x26, 0x2b, 0xae, 0xe2, 0x4b, + 0x2f, 0x2a, 0x80, 0x46, 0x8b, 0x03, 0x94, 0x1f, 0x55, 0x6a, 0x93, 0x0c, 0x37, 0x50, + 0xe6, 0x9a, 0xce, 0xcc, 0x79, 0xc0, 0xe4, 0x72, 0x0f, 0xe5, ], }, TestVector { @@ -3813,9 +3813,9 @@ pub(crate) fn test_vectors() -> Vec { 0x4c, 0x3f, 0x8d, 0x26, ], cmx: [ - 0x69, 0x4b, 0x6f, 0x3a, 0xb8, 0x37, 0xa9, 0x26, 0xd6, 0x77, 0x3e, 0xc4, 0xa6, 0x76, - 0x5d, 0xef, 0x82, 0x89, 0x33, 0x74, 0x2d, 0x93, 0x29, 0xfc, 0x88, 0x67, 0x1c, 0xcd, - 0x81, 0x21, 0xa4, 0x23, + 0x4c, 0x6c, 0x39, 0xec, 0xcf, 0xc0, 0xce, 0xe9, 0x0b, 0x46, 0xdb, 0x88, 0x98, 0xe0, + 0xd1, 0x8b, 0x2c, 0x7a, 0x61, 0x63, 0x0a, 0xb2, 0x71, 0x5c, 0x77, 0x07, 0x17, 0x37, + 0xca, 0x2a, 0x18, 0x13, ], esk: [ 0xaa, 0x84, 0x16, 0x79, 0xd4, 0xd2, 0x40, 0xb0, 0xab, 0xc4, 0xa5, 0xd8, 0x9a, 0xa8, @@ -3929,9 +3929,9 @@ pub(crate) fn test_vectors() -> Vec { 0xa1, 0x85, 0x5a, 0xf9, 0x90, 0xcd, 0xb6, 0x77, 0xaf, 0x0d, ], ock: [ - 0x67, 0x1c, 0xed, 0xd6, 0xf5, 0x73, 0xa4, 0x6f, 0xf1, 0xea, 0xd0, 0x48, 0x21, 0x98, - 0x56, 0x36, 0xe2, 0x3f, 0xb1, 0x5c, 0x6f, 0x48, 0x05, 0xfd, 0x57, 0x63, 0x12, 0xc2, - 0x07, 0x02, 0xa4, 0x24, + 0x2b, 0x28, 0x4c, 0xea, 0xca, 0x3e, 0xe7, 0x05, 0x2b, 0xb4, 0xad, 0x16, 0x7e, 0xc4, + 0x4f, 0xbf, 0x14, 0x4f, 0x7a, 0xef, 0x67, 0x8a, 0x37, 0xe6, 0x1e, 0x0b, 0x1f, 0x6b, + 0xdc, 0x24, 0xa0, 0x0d, ], op: [ 0xcc, 0x18, 0xe4, 0xb6, 0x5f, 0x89, 0x34, 0x06, 0x31, 0x5d, 0xb7, 0x1f, 0xac, 0x06, @@ -3941,12 +3941,12 @@ pub(crate) fn test_vectors() -> Vec { 0x6a, 0x72, 0xcb, 0x74, 0xfb, 0x18, 0xd1, 0x17, ], c_out: [ - 0x59, 0x97, 0x53, 0xe4, 0x0a, 0xda, 0xea, 0xff, 0x6f, 0xaa, 0xf5, 0xa6, 0xf3, 0x0e, - 0x39, 0x13, 0x8f, 0xde, 0x82, 0x0f, 0x7b, 0xec, 0x7c, 0x8d, 0x0f, 0xd8, 0x4b, 0x48, - 0x36, 0x94, 0xe5, 0x0c, 0x4b, 0xdd, 0xee, 0x2f, 0xb1, 0xa4, 0xf9, 0x95, 0xb1, 0xa3, - 0xba, 0x40, 0xf4, 0x66, 0xb4, 0x2e, 0x8b, 0x5d, 0x01, 0x38, 0xfd, 0x30, 0xbf, 0xf6, - 0xae, 0x8c, 0xb1, 0x55, 0xf4, 0x0c, 0xdc, 0x37, 0x39, 0xfa, 0xbf, 0x2f, 0x00, 0xda, - 0x3a, 0xc6, 0xa7, 0x36, 0x3b, 0xc2, 0xf4, 0xaa, 0x10, 0xfe, + 0x4b, 0x9a, 0x5a, 0x4a, 0x4d, 0xda, 0x98, 0xfb, 0x92, 0x9a, 0xe9, 0x7b, 0x11, 0xb2, + 0x09, 0xae, 0x23, 0x42, 0x5e, 0x52, 0x26, 0x9a, 0xad, 0xca, 0x13, 0x23, 0x9c, 0xb9, + 0xb3, 0x8f, 0xbf, 0xfb, 0x85, 0x29, 0x58, 0x41, 0xd0, 0xf3, 0x2b, 0xea, 0xd9, 0x2c, + 0x4d, 0x3c, 0x88, 0xe6, 0xe7, 0x2a, 0x1b, 0xe1, 0xd6, 0x64, 0x9b, 0x1c, 0xee, 0x43, + 0x0e, 0xad, 0x38, 0x44, 0x56, 0x07, 0xc4, 0xa9, 0xb6, 0x02, 0x51, 0x83, 0x56, 0x1e, + 0x6c, 0xff, 0x55, 0x2a, 0xf0, 0x88, 0x98, 0xd4, 0x09, 0xa6, ], }, TestVector { @@ -4031,9 +4031,9 @@ pub(crate) fn test_vectors() -> Vec { 0x4b, 0xc8, 0x45, 0x10, ], cmx: [ - 0x76, 0xf1, 0xbd, 0x50, 0xf9, 0xb9, 0x06, 0xcb, 0x9f, 0xf2, 0xdd, 0x91, 0x8a, 0x36, - 0x7e, 0x5f, 0xb1, 0xa2, 0xef, 0x39, 0xf1, 0x4f, 0x6c, 0xe9, 0x4f, 0xf9, 0xf0, 0x91, - 0x55, 0xf8, 0xc2, 0x11, + 0x06, 0x65, 0x7e, 0xd7, 0x3d, 0x2a, 0x26, 0xfa, 0xfd, 0xe2, 0xb5, 0xb3, 0x73, 0xf4, + 0x60, 0x07, 0x89, 0xf5, 0x23, 0x2b, 0x57, 0x3b, 0x4e, 0xcf, 0xd5, 0x3c, 0x14, 0x03, + 0x9b, 0xeb, 0x15, 0x1c, ], esk: [ 0x2f, 0x98, 0x2d, 0xec, 0xa7, 0x60, 0x51, 0x41, 0xd9, 0xc9, 0xa1, 0xe6, 0xfb, 0x57, @@ -4147,9 +4147,9 @@ pub(crate) fn test_vectors() -> Vec { 0x4e, 0x59, 0x80, 0x45, 0x8c, 0x51, 0xfb, 0x1c, 0xd8, 0x46, ], ock: [ - 0x57, 0x97, 0xef, 0x48, 0x70, 0xb0, 0x86, 0x50, 0xfa, 0x99, 0xad, 0xae, 0x58, 0x85, - 0x19, 0x9e, 0x3b, 0x04, 0x4b, 0x2a, 0x0a, 0x8c, 0xe1, 0x61, 0x43, 0x42, 0xb5, 0xdc, - 0xb2, 0x8e, 0x6e, 0x09, + 0x59, 0xb8, 0x10, 0x2e, 0x91, 0x7f, 0xf5, 0xa4, 0x23, 0x60, 0x50, 0x7c, 0xce, 0x30, + 0xcc, 0x5b, 0xda, 0xb7, 0x76, 0x18, 0x61, 0x9f, 0x52, 0xda, 0xfa, 0xbd, 0xf5, 0x5a, + 0x3f, 0x64, 0xc1, 0xee, ], op: [ 0x6f, 0xce, 0x26, 0xab, 0xe6, 0xc0, 0xb6, 0x84, 0x37, 0x36, 0x96, 0x46, 0xee, 0xe1, @@ -4159,12 +4159,12 @@ pub(crate) fn test_vectors() -> Vec { 0xb9, 0x5f, 0xc8, 0x7e, 0xa7, 0x37, 0x3e, 0x2f, ], c_out: [ - 0xb8, 0xb4, 0x6c, 0x7e, 0xc4, 0xa8, 0x74, 0x2a, 0x22, 0xd3, 0xcd, 0x11, 0x74, 0x1c, - 0x23, 0x04, 0x22, 0x1c, 0xa5, 0x97, 0x29, 0x4e, 0x08, 0xa4, 0xc7, 0x1b, 0x17, 0xc7, - 0x26, 0x5d, 0x4d, 0xa7, 0x7c, 0xfe, 0x84, 0xb8, 0x7e, 0x76, 0xed, 0xaa, 0xec, 0xc2, - 0x24, 0xb8, 0x36, 0xde, 0x22, 0x4c, 0x73, 0x58, 0x13, 0x19, 0xa0, 0xba, 0x27, 0x88, - 0xdb, 0xf8, 0x3b, 0xcf, 0x47, 0xa4, 0x8e, 0xeb, 0x02, 0xb4, 0x3a, 0x18, 0x02, 0x7b, - 0x8f, 0x59, 0x11, 0x65, 0xc2, 0x86, 0xe8, 0xb6, 0x54, 0xec, + 0x7e, 0xaf, 0x92, 0x5e, 0x3e, 0x5c, 0xd2, 0x0c, 0xc9, 0x34, 0x9f, 0x17, 0x4b, 0xdc, + 0x8c, 0x46, 0x45, 0x65, 0xb8, 0x04, 0x68, 0x9d, 0x79, 0x8d, 0x63, 0x2f, 0x58, 0xaa, + 0x26, 0x7a, 0x2f, 0x4e, 0x65, 0xed, 0x07, 0x33, 0xc4, 0x18, 0x67, 0x7b, 0xda, 0x1a, + 0xf5, 0x6e, 0xa9, 0xfd, 0xec, 0xcc, 0xcc, 0xdc, 0x10, 0xa9, 0xb6, 0xda, 0xa4, 0x92, + 0x4b, 0x46, 0x2f, 0x1e, 0x9d, 0x08, 0x65, 0xba, 0xc3, 0xab, 0x71, 0x7a, 0xb8, 0x4f, + 0x54, 0x2c, 0x2f, 0x8d, 0x46, 0xe3, 0x20, 0x5f, 0xb0, 0x33, ], }, TestVector { @@ -4249,9 +4249,9 @@ pub(crate) fn test_vectors() -> Vec { 0x7f, 0x28, 0x4b, 0x2e, ], cmx: [ - 0x89, 0xe6, 0xa2, 0xb9, 0x70, 0x84, 0xe3, 0xd3, 0x34, 0x4f, 0xee, 0xb4, 0x64, 0x65, - 0x05, 0x72, 0x51, 0xb1, 0x9d, 0xa0, 0xce, 0xdf, 0x79, 0x71, 0x94, 0xc5, 0x97, 0xf9, - 0xf7, 0x7e, 0xf2, 0x1f, + 0x7a, 0xd4, 0xd8, 0xf5, 0xd4, 0xe7, 0xa9, 0x79, 0xfa, 0x73, 0x93, 0xed, 0x26, 0xf1, + 0x7d, 0x14, 0x2b, 0x65, 0xf5, 0x3b, 0xb4, 0x6d, 0xa6, 0x0a, 0x50, 0x22, 0x28, 0xc0, + 0x7b, 0x2c, 0xda, 0x27, ], esk: [ 0xe4, 0x00, 0x13, 0x04, 0x47, 0xc1, 0xbd, 0x1a, 0x0c, 0x13, 0x02, 0xf5, 0x10, 0xe9, @@ -4365,9 +4365,9 @@ pub(crate) fn test_vectors() -> Vec { 0x8f, 0x2c, 0xc4, 0x5a, 0xeb, 0x43, 0x52, 0x9e, 0x7d, 0x08, ], ock: [ - 0x95, 0x83, 0xf1, 0x0f, 0xed, 0x70, 0xa4, 0x1e, 0x45, 0x8c, 0x65, 0x5c, 0xc0, 0x14, - 0xe2, 0x35, 0x5a, 0x7f, 0x99, 0xae, 0xbc, 0xfe, 0xf7, 0x4a, 0x55, 0x9a, 0xcd, 0x24, - 0x25, 0xfa, 0x21, 0xcf, + 0x89, 0x5c, 0x90, 0x04, 0xec, 0x4c, 0x50, 0xd6, 0xd5, 0xfd, 0x6a, 0x51, 0x71, 0x2a, + 0xcc, 0xa4, 0x77, 0x1e, 0x1c, 0xe0, 0xb9, 0x94, 0x30, 0xf0, 0x45, 0x9d, 0x43, 0xff, + 0x16, 0x6a, 0x93, 0xf8, ], op: [ 0x3e, 0x5e, 0x46, 0xeb, 0x0f, 0xe8, 0xe6, 0xf0, 0xcf, 0x6a, 0xab, 0x2b, 0x41, 0xfb, @@ -4377,12 +4377,12 @@ pub(crate) fn test_vectors() -> Vec { 0xc4, 0x69, 0x2d, 0x0c, 0x1b, 0x30, 0x33, 0x01, ], c_out: [ - 0xb8, 0x3b, 0x74, 0x5c, 0x9c, 0x0b, 0x04, 0xdd, 0xc7, 0xf1, 0x38, 0x16, 0x94, 0x38, - 0x99, 0x55, 0x3a, 0x30, 0x6a, 0x4a, 0xd0, 0xf2, 0xf5, 0x70, 0x92, 0x2a, 0x89, 0x9b, - 0xab, 0xb9, 0xda, 0xca, 0xd2, 0xbb, 0xc9, 0x5c, 0xf6, 0x5b, 0x73, 0x08, 0x55, 0x0d, - 0xce, 0xdb, 0x64, 0x9e, 0xf1, 0x5e, 0x0b, 0x1a, 0x09, 0x1f, 0xad, 0x5a, 0x93, 0x92, - 0xd0, 0x71, 0xb7, 0x5a, 0xb5, 0x1a, 0x7e, 0x35, 0x06, 0xad, 0x58, 0xd1, 0x71, 0x95, - 0xc9, 0x9f, 0x29, 0x8a, 0xc3, 0x14, 0xec, 0x05, 0xa6, 0x6a, + 0xc7, 0xf4, 0x90, 0x67, 0x45, 0x7f, 0x0c, 0xa0, 0xbf, 0x73, 0x0e, 0x55, 0x17, 0x06, + 0x7d, 0x49, 0x39, 0x9a, 0xce, 0xb7, 0xa6, 0x32, 0x85, 0x34, 0x63, 0x90, 0x76, 0xc1, + 0x44, 0xb2, 0x96, 0xc4, 0xce, 0xd1, 0x5a, 0x49, 0xd3, 0xba, 0xe5, 0x8e, 0xc5, 0xf8, + 0xc0, 0xb5, 0x48, 0x06, 0x33, 0x4e, 0x63, 0xc1, 0x14, 0x1c, 0xb8, 0xd3, 0x04, 0x49, + 0x2a, 0xf5, 0xff, 0x0b, 0x5c, 0x14, 0x75, 0x8d, 0x45, 0x60, 0x30, 0x82, 0x0a, 0xbd, + 0xd6, 0x8f, 0x2e, 0x67, 0xa5, 0x87, 0xb2, 0x60, 0xf0, 0x48, ], }, ] From 19e79a7513e88f84c31c83192e509d07a0c2f548 Mon Sep 17 00:00:00 2001 From: Constance Date: Wed, 19 Apr 2023 15:39:10 +0200 Subject: [PATCH 03/10] Update keys test vectors --- src/test_vectors/keys.rs | 63 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/src/test_vectors/keys.rs b/src/test_vectors/keys.rs index 02c9cfc78..8fa650a37 100644 --- a/src/test_vectors/keys.rs +++ b/src/test_vectors/keys.rs @@ -1,4 +1,4 @@ -//! Test vectors for Orchard key components. +// From https://github.com/zcash-hackworks/zcash-test-vectors/ (orchard_key_components) pub(crate) struct TestVector { pub(crate) sk: [u8; 32], @@ -26,7 +26,6 @@ pub(crate) struct TestVector { } pub(crate) fn test_vectors() -> Vec { - // From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/orchard_key_components.py vec![ TestVector { sk: [ @@ -654,14 +653,14 @@ pub(crate) fn test_vectors() -> Vec { 0xcd, 0x08, 0xcb, 0x05, ], note_cmx: [ - 0x71, 0x99, 0x1e, 0xeb, 0x4b, 0x51, 0x7e, 0xd9, 0xd4, 0x31, 0xdc, 0xa9, 0xa2, 0xbb, - 0xcf, 0x1c, 0xe8, 0x75, 0xe8, 0x55, 0xdf, 0xf4, 0x8c, 0x69, 0xf4, 0xef, 0x51, 0x01, - 0x1e, 0x86, 0x1e, 0x07, + 0xf1, 0x34, 0x33, 0x5c, 0x60, 0xf3, 0x17, 0xec, 0x48, 0xd6, 0x7b, 0x49, 0x34, 0x58, + 0xde, 0x26, 0xb4, 0x06, 0xfd, 0xd2, 0x10, 0xf8, 0x60, 0xb1, 0x81, 0xaf, 0x7b, 0x82, + 0xcd, 0xe9, 0x4e, 0x37, ], note_nf: [ - 0xdf, 0x79, 0xd4, 0xa4, 0x6e, 0xca, 0xfd, 0x34, 0x50, 0x9d, 0x41, 0xfc, 0xfb, 0x61, - 0x3e, 0x1f, 0xdc, 0xbc, 0x0d, 0x3b, 0xa0, 0xaa, 0x8d, 0xe5, 0x04, 0xd6, 0xf2, 0x54, - 0xcd, 0x55, 0x12, 0x32, + 0x75, 0x6c, 0x1f, 0x4b, 0xfa, 0xae, 0xc5, 0x5b, 0x42, 0x0a, 0x4f, 0x88, 0x12, 0xdb, + 0x6c, 0x43, 0x2e, 0x48, 0x61, 0x6f, 0xb8, 0xd1, 0xbb, 0x2b, 0x1d, 0xd1, 0xe7, 0x2c, + 0x0a, 0xa3, 0xdb, 0x3a, ], }, TestVector { @@ -760,14 +759,14 @@ pub(crate) fn test_vectors() -> Vec { 0xa0, 0xd4, 0x70, 0x19, ], note_cmx: [ - 0x94, 0x81, 0xcb, 0xac, 0x4e, 0xb0, 0xc0, 0x8d, 0x12, 0x83, 0x47, 0x13, 0xb5, 0x15, - 0xfd, 0x8c, 0x61, 0x0d, 0x44, 0xc1, 0x29, 0x50, 0x97, 0xcc, 0x20, 0x13, 0x4d, 0xe2, - 0x1c, 0x63, 0x6c, 0x29, + 0x07, 0x1c, 0x49, 0x8b, 0x02, 0x6b, 0x8b, 0x1a, 0x7a, 0x1e, 0x84, 0x00, 0x13, 0x87, + 0x20, 0x82, 0x3d, 0x80, 0xec, 0xa4, 0x99, 0xac, 0xd2, 0x91, 0xfc, 0x07, 0xfd, 0x2f, + 0x41, 0x6e, 0x83, 0x38, ], note_nf: [ - 0x44, 0xc8, 0x8d, 0x03, 0x10, 0x21, 0x56, 0x11, 0x25, 0x6a, 0xad, 0x07, 0x34, 0x99, - 0x43, 0x08, 0x94, 0x59, 0x73, 0x17, 0x15, 0x75, 0xae, 0x7e, 0x89, 0xf5, 0x8d, 0x44, - 0xde, 0xa2, 0x67, 0x10, + 0x22, 0x55, 0x5e, 0xe7, 0x85, 0x46, 0x8c, 0xc7, 0x70, 0xca, 0xf9, 0x0f, 0x82, 0x61, + 0x1b, 0x80, 0x15, 0xb0, 0x3d, 0xd8, 0x85, 0x6c, 0xc9, 0xa2, 0x7c, 0xbf, 0x7f, 0x5c, + 0x31, 0x3d, 0x96, 0x0e, ], }, TestVector { @@ -866,14 +865,14 @@ pub(crate) fn test_vectors() -> Vec { 0xe5, 0xe1, 0x71, 0x1c, ], note_cmx: [ - 0xfe, 0x09, 0xf5, 0x89, 0x7c, 0xed, 0xc7, 0x67, 0x7c, 0xf5, 0x80, 0xc5, 0xf0, 0xd1, - 0x83, 0xed, 0x3b, 0xc0, 0x94, 0x5c, 0xb1, 0xc3, 0x85, 0xf3, 0x88, 0xf9, 0x3f, 0x94, - 0x3e, 0xff, 0x2a, 0x2f, + 0x7b, 0xc1, 0xdd, 0xba, 0x52, 0x06, 0x14, 0xdd, 0x4e, 0x44, 0x3e, 0xaa, 0xf2, 0x5b, + 0xea, 0xa0, 0x14, 0xc2, 0x78, 0x6d, 0x15, 0x0a, 0x3b, 0x6f, 0xea, 0x97, 0x6a, 0x9b, + 0xdf, 0x27, 0x02, 0x04, ], note_nf: [ - 0x80, 0xdf, 0x21, 0xbf, 0xeb, 0x46, 0x06, 0x16, 0x06, 0x29, 0x61, 0x03, 0x86, 0xc7, - 0x99, 0x02, 0xef, 0x49, 0x8b, 0x61, 0xb1, 0x55, 0x0c, 0xbd, 0x10, 0x55, 0xf8, 0x26, - 0x94, 0xfa, 0x5b, 0x03, + 0x78, 0x31, 0xe9, 0xc5, 0x1c, 0xc1, 0xdc, 0xa6, 0xda, 0x89, 0x1a, 0xde, 0xad, 0x3a, + 0x79, 0x24, 0xff, 0x26, 0x4b, 0xe4, 0x25, 0x0b, 0xec, 0x05, 0xc5, 0x92, 0xd3, 0x14, + 0x52, 0x6b, 0x1a, 0x2f, ], }, TestVector { @@ -972,14 +971,14 @@ pub(crate) fn test_vectors() -> Vec { 0xcd, 0xdb, 0x41, 0x87, ], note_cmx: [ - 0x5e, 0x54, 0xfe, 0x7e, 0x59, 0x52, 0xa6, 0xea, 0x26, 0xba, 0xbc, 0x32, 0xcf, 0xed, - 0xf5, 0xe6, 0x0b, 0x56, 0x82, 0x58, 0x98, 0x0d, 0x92, 0xc1, 0xe5, 0xdd, 0x3f, 0xdf, - 0x3e, 0x48, 0x7e, 0x1d, + 0xea, 0xf9, 0x49, 0x1c, 0xab, 0xca, 0x20, 0x07, 0xba, 0x91, 0xea, 0xc9, 0xb3, 0xc0, + 0xa1, 0x1c, 0x58, 0xef, 0x5f, 0xe0, 0x71, 0x86, 0x8c, 0x66, 0xf1, 0xc5, 0xf5, 0x9c, + 0x7c, 0x99, 0x25, 0x14, ], note_nf: [ - 0x45, 0x5f, 0xd0, 0xe5, 0x2e, 0x59, 0x33, 0x62, 0x57, 0x2d, 0x12, 0xdb, 0x44, 0xbb, - 0xf0, 0xe0, 0x95, 0x8a, 0xf9, 0xd5, 0x8f, 0xbd, 0xf9, 0x7b, 0x85, 0x22, 0x8e, 0xca, - 0xd0, 0xde, 0x7f, 0x05, + 0x3a, 0xbc, 0x17, 0xad, 0xee, 0x2a, 0xa8, 0x8d, 0xf8, 0x93, 0x99, 0x4f, 0x1a, 0xf2, + 0x71, 0x51, 0xc1, 0x8b, 0xa6, 0xa9, 0x89, 0xc4, 0xbf, 0xfb, 0xb9, 0xa9, 0x18, 0xd5, + 0x50, 0x71, 0x95, 0x02, ], }, TestVector { @@ -1078,14 +1077,14 @@ pub(crate) fn test_vectors() -> Vec { 0xca, 0x26, 0xfa, 0xc4, ], note_cmx: [ - 0xdf, 0x1e, 0x28, 0x2c, 0x9b, 0xf3, 0x09, 0x72, 0xb2, 0x8c, 0x46, 0xed, 0x8a, 0x54, - 0x42, 0x6d, 0xae, 0xc1, 0xae, 0x38, 0x1a, 0x38, 0x5d, 0xf2, 0x5f, 0xff, 0xfa, 0x66, - 0x79, 0x53, 0xd3, 0x33, + 0x22, 0x0c, 0xf6, 0xb7, 0xbd, 0x7d, 0xf1, 0x1a, 0xeb, 0x46, 0xb8, 0xf6, 0x52, 0x19, + 0x71, 0xe4, 0xf5, 0xce, 0xc6, 0x0e, 0x2c, 0x3a, 0xd1, 0x9e, 0x3b, 0x3f, 0x40, 0x7e, + 0x69, 0x4b, 0xe8, 0x01, ], note_nf: [ - 0x97, 0x0a, 0xff, 0xd7, 0xf1, 0x0d, 0x5b, 0x71, 0x23, 0x27, 0xe8, 0x39, 0x7e, 0x51, - 0x45, 0x3f, 0x85, 0xf4, 0xc2, 0x0f, 0x80, 0x1e, 0x97, 0xe5, 0xe6, 0x40, 0x0e, 0xb0, - 0xed, 0xc4, 0xbb, 0x03, + 0x0d, 0x35, 0x9b, 0x02, 0xf6, 0x2d, 0x72, 0x18, 0xc8, 0x93, 0xd0, 0x4e, 0xc0, 0xed, + 0xd4, 0x89, 0xb2, 0x33, 0xa3, 0xc6, 0x60, 0x15, 0xaf, 0x93, 0x93, 0x0b, 0x23, 0x30, + 0x35, 0x82, 0x07, 0x3f, ], }, ] From 40658e208b51e8fb4131bc9db3b0e60bd39314c5 Mon Sep 17 00:00:00 2001 From: Constance Date: Wed, 19 Apr 2023 11:13:04 +0200 Subject: [PATCH 04/10] Constant-time note commitment --- Cargo.toml | 6 +-- src/note/commitment.rs | 85 +++++++++++++++++++++++++++++++----------- 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d52cf36ba..b0dcf3b5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,8 @@ blake2b_simd = "1" ff = "0.12" fpe = "0.5" group = { version = "0.12.1", features = ["wnaf-memuse"] } -halo2_gadgets = {git = "https://github.com/QED-it/halo2", branch = "commit_doamin_from_two_personalizations"} -halo2_proofs = {git = "https://github.com/QED-it/halo2", branch = "commit_doamin_from_two_personalizations"} +halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "add_sinsemilla_functionalities_v2" } +halo2_proofs = { git = "https://github.com/QED-it/halo2", branch = "add_sinsemilla_functionalities_v2"} hex = "0.4" lazy_static = "1" memuse = { version = "0.2.1", features = ["nonempty"] } @@ -52,7 +52,7 @@ plotters = { version = "0.3.0", optional = true } [dev-dependencies] criterion = "0.3" -halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "commit_doamin_from_two_personalizations", features = ["test-dependencies"] } +halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "add_sinsemilla_functionalities_v2", features = ["test-dependencies"] } hex = "0.4" proptest = "1.0.0" zcash_note_encryption = { version = "0.2", features = ["pre-zip-212"] } diff --git a/src/note/commitment.rs b/src/note/commitment.rs index 55b13ecd7..c14e48fad 100644 --- a/src/note/commitment.rs +++ b/src/note/commitment.rs @@ -63,31 +63,35 @@ impl NoteCommitment { .chain(rho_bits.iter().by_vals().take(L_ORCHARD_BASE)) .chain(psi_bits.iter().by_vals().take(L_ORCHARD_BASE)); - // TODO: make this constant-time. - if asset.is_native().into() { - // Commit to ZEC notes as per the Orchard protocol. - Self::commit(NOTE_COMMITMENT_PERSONALIZATION, zec_note_bits, rcm) - } else { - // Commit to non-ZEC notes as per the ZSA protocol. - // Append the note type to the Orchard note encoding. - let type_bits = BitArray::<_, Lsb0>::new(asset.to_bytes()); - let zsa_note_bits = zec_note_bits.chain(type_bits.iter().by_vals()); - - // Commit in a different domain than Orchard notes. - Self::commit(NOTE_ZSA_COMMITMENT_PERSONALIZATION, zsa_note_bits, rcm) - } - } + let type_bits = BitArray::<_, Lsb0>::new(asset.to_bytes()); + let zsa_note_bits = iter::empty() + .chain(g_d_bits.iter().by_vals()) + .chain(pk_d_bits.iter().by_vals()) + .chain(v_bits.iter().by_vals()) + .chain(rho_bits.iter().by_vals().take(L_ORCHARD_BASE)) + .chain(psi_bits.iter().by_vals().take(L_ORCHARD_BASE)) + .chain(type_bits.iter().by_vals()); - fn commit( - personalization: &str, - bits: impl Iterator, - rcm: NoteCommitTrapdoor, - ) -> CtOption { - let domain = sinsemilla::CommitDomain::new_with_two_personalizations( - personalization, + let zec_domain = sinsemilla::CommitDomain::new(NOTE_COMMITMENT_PERSONALIZATION); + let zsa_domain = sinsemilla::CommitDomain::new_with_two_personalizations( + NOTE_ZSA_COMMITMENT_PERSONALIZATION, NOTE_COMMITMENT_PERSONALIZATION, ); - domain.commit(bits, &rcm.0).map(NoteCommitment) + + let zec_hash_point = zec_domain.M.hash_to_point(zec_note_bits); + let zsa_hash_point = zsa_domain.M.hash_to_point(zsa_note_bits); + + let hash_point = if asset.is_native().into() { + zec_hash_point + } else { + zsa_hash_point + }; + + // To evaluate the commitment from the hash_point, we could use either zec_domain or + // zsa_domain because they have both the same `R` constant. + zec_domain + .commit_from_hash_point(hash_point, &rcm.0) + .map(NoteCommitment) } } @@ -143,3 +147,40 @@ impl PartialEq for ExtractedNoteCommitment { } impl Eq for ExtractedNoteCommitment {} + +#[cfg(test)] +mod tests { + use crate::constants::fixed_bases::{ + NOTE_COMMITMENT_PERSONALIZATION, NOTE_ZSA_COMMITMENT_PERSONALIZATION, + }; + use crate::note::commitment::NoteCommitTrapdoor; + use ff::Field; + use halo2_gadgets::sinsemilla::primitives as sinsemilla; + use pasta_curves::pallas; + use rand::{rngs::OsRng, Rng}; + + #[test] + fn test_note_commit() { + let mut os_rng = OsRng::default(); + let msg: Vec = (0..36).map(|_| os_rng.gen::()).collect(); + + let rcm = NoteCommitTrapdoor(pallas::Scalar::random(&mut os_rng)); + + let domain_zec = sinsemilla::CommitDomain::new(NOTE_COMMITMENT_PERSONALIZATION); + let domain_zsa = sinsemilla::CommitDomain::new_with_two_personalizations( + NOTE_ZSA_COMMITMENT_PERSONALIZATION, + NOTE_COMMITMENT_PERSONALIZATION, + ); + + let expected_commit = domain_zsa.commit(msg.clone().into_iter(), &rcm.0); + + // Evaluating the commitment in one step with `commit` or in two steps with `hash_to_point` + // and `commit_from_hash_point` must give the same commitment. + let hash_point = domain_zsa.M.hash_to_point(msg.into_iter()); + let commit_r_zsa = domain_zsa.commit_from_hash_point(hash_point, &rcm.0); + assert_eq!(expected_commit.unwrap(), commit_r_zsa.unwrap()); + + // ZEC and ZSA note commitments must use the same R constant + assert_eq!(domain_zec.R(), domain_zsa.R()); + } +} From 103485ab2d469b31e4f4f0bafc71ea0b95e306c3 Mon Sep 17 00:00:00 2001 From: Constance Date: Fri, 21 Apr 2023 10:51:09 +0200 Subject: [PATCH 05/10] Compute the mutual part once --- src/note/commitment.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/note/commitment.rs b/src/note/commitment.rs index c14e48fad..3c528470f 100644 --- a/src/note/commitment.rs +++ b/src/note/commitment.rs @@ -56,20 +56,19 @@ impl NoteCommitment { let rho_bits = rho.to_le_bits(); let psi_bits = psi.to_le_bits(); - let zec_note_bits = iter::empty() + let common_note_bits = iter::empty() .chain(g_d_bits.iter().by_vals()) .chain(pk_d_bits.iter().by_vals()) .chain(v_bits.iter().by_vals()) .chain(rho_bits.iter().by_vals().take(L_ORCHARD_BASE)) - .chain(psi_bits.iter().by_vals().take(L_ORCHARD_BASE)); + .chain(psi_bits.iter().by_vals().take(L_ORCHARD_BASE)) + .collect::>(); + + let zec_note_bits = common_note_bits.clone().into_iter(); let type_bits = BitArray::<_, Lsb0>::new(asset.to_bytes()); - let zsa_note_bits = iter::empty() - .chain(g_d_bits.iter().by_vals()) - .chain(pk_d_bits.iter().by_vals()) - .chain(v_bits.iter().by_vals()) - .chain(rho_bits.iter().by_vals().take(L_ORCHARD_BASE)) - .chain(psi_bits.iter().by_vals().take(L_ORCHARD_BASE)) + let zsa_note_bits = common_note_bits + .into_iter() .chain(type_bits.iter().by_vals()); let zec_domain = sinsemilla::CommitDomain::new(NOTE_COMMITMENT_PERSONALIZATION); From 59c1cb11f70afd36dd4a587e8f9df5192385d2e8 Mon Sep 17 00:00:00 2001 From: Constance Date: Fri, 21 Apr 2023 15:42:10 +0200 Subject: [PATCH 06/10] Update Cargo.toml to use zsa1 branch for halo2 --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b0dcf3b5b..17656f550 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,8 @@ blake2b_simd = "1" ff = "0.12" fpe = "0.5" group = { version = "0.12.1", features = ["wnaf-memuse"] } -halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "add_sinsemilla_functionalities_v2" } -halo2_proofs = { git = "https://github.com/QED-it/halo2", branch = "add_sinsemilla_functionalities_v2"} +halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "zsa1" } +halo2_proofs = { git = "https://github.com/QED-it/halo2", branch = "zsa1"} hex = "0.4" lazy_static = "1" memuse = { version = "0.2.1", features = ["nonempty"] } @@ -52,7 +52,7 @@ plotters = { version = "0.3.0", optional = true } [dev-dependencies] criterion = "0.3" -halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "add_sinsemilla_functionalities_v2", features = ["test-dependencies"] } +halo2_gadgets = { git = "https://github.com/QED-it/halo2", branch = "zsa1", features = ["test-dependencies"] } hex = "0.4" proptest = "1.0.0" zcash_note_encryption = { version = "0.2", features = ["pre-zip-212"] } From e35aca4bca46c78b1a9cb36cdf3252c3724f34f1 Mon Sep 17 00:00:00 2001 From: Constance Date: Fri, 21 Apr 2023 15:45:05 +0200 Subject: [PATCH 07/10] Replace new_with_two_personalizations by new_with_personlization --- src/note/commitment.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/note/commitment.rs b/src/note/commitment.rs index 3c528470f..f619f968b 100644 --- a/src/note/commitment.rs +++ b/src/note/commitment.rs @@ -72,7 +72,7 @@ impl NoteCommitment { .chain(type_bits.iter().by_vals()); let zec_domain = sinsemilla::CommitDomain::new(NOTE_COMMITMENT_PERSONALIZATION); - let zsa_domain = sinsemilla::CommitDomain::new_with_two_personalizations( + let zsa_domain = sinsemilla::CommitDomain::new_with_personalization( NOTE_ZSA_COMMITMENT_PERSONALIZATION, NOTE_COMMITMENT_PERSONALIZATION, ); @@ -166,7 +166,7 @@ mod tests { let rcm = NoteCommitTrapdoor(pallas::Scalar::random(&mut os_rng)); let domain_zec = sinsemilla::CommitDomain::new(NOTE_COMMITMENT_PERSONALIZATION); - let domain_zsa = sinsemilla::CommitDomain::new_with_two_personalizations( + let domain_zsa = sinsemilla::CommitDomain::new_with_personalization( NOTE_ZSA_COMMITMENT_PERSONALIZATION, NOTE_COMMITMENT_PERSONALIZATION, ); From 3a0758998c47befece0c23f503a4335fc7978bd7 Mon Sep 17 00:00:00 2001 From: Constance Date: Mon, 24 Apr 2023 12:39:43 +0200 Subject: [PATCH 08/10] Replace if to a constant-time conditional selector --- src/note/commitment.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/note/commitment.rs b/src/note/commitment.rs index f619f968b..b267bb7be 100644 --- a/src/note/commitment.rs +++ b/src/note/commitment.rs @@ -4,7 +4,7 @@ use bitvec::{array::BitArray, order::Lsb0}; use group::ff::{PrimeField, PrimeFieldBits}; use halo2_gadgets::sinsemilla::primitives as sinsemilla; use pasta_curves::pallas; -use subtle::{ConstantTimeEq, CtOption}; +use subtle::{ConditionallySelectable, ConstantTimeEq, CtOption}; use crate::{ constants::{ @@ -80,11 +80,12 @@ impl NoteCommitment { let zec_hash_point = zec_domain.M.hash_to_point(zec_note_bits); let zsa_hash_point = zsa_domain.M.hash_to_point(zsa_note_bits); - let hash_point = if asset.is_native().into() { - zec_hash_point - } else { - zsa_hash_point - }; + // Select the desired hash point in constant-time + let hash_point = zsa_hash_point.and_then(|zsa_hash| { + zec_hash_point.map(|zec_hash| { + pallas::Point::conditional_select(&zsa_hash, &zec_hash, asset.is_native().into()) + }) + }); // To evaluate the commitment from the hash_point, we could use either zec_domain or // zsa_domain because they have both the same `R` constant. From b8099d066ecffe0c4d1da15b6f892ae5d5a835c1 Mon Sep 17 00:00:00 2001 From: Constance Date: Mon, 24 Apr 2023 12:43:52 +0200 Subject: [PATCH 09/10] Fix clippy warnings --- src/note/commitment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/note/commitment.rs b/src/note/commitment.rs index b267bb7be..80f6d3870 100644 --- a/src/note/commitment.rs +++ b/src/note/commitment.rs @@ -83,7 +83,7 @@ impl NoteCommitment { // Select the desired hash point in constant-time let hash_point = zsa_hash_point.and_then(|zsa_hash| { zec_hash_point.map(|zec_hash| { - pallas::Point::conditional_select(&zsa_hash, &zec_hash, asset.is_native().into()) + pallas::Point::conditional_select(&zsa_hash, &zec_hash, asset.is_native()) }) }); From cc2adbb74fbf52486e36077575bf6fc6a30f8bc7 Mon Sep 17 00:00:00 2001 From: Constance Date: Tue, 25 Apr 2023 09:50:46 +0200 Subject: [PATCH 10/10] Rename note commit test --- src/note/commitment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/note/commitment.rs b/src/note/commitment.rs index 80f6d3870..18024afe8 100644 --- a/src/note/commitment.rs +++ b/src/note/commitment.rs @@ -160,7 +160,7 @@ mod tests { use rand::{rngs::OsRng, Rng}; #[test] - fn test_note_commit() { + fn test_commit_in_several_steps() { let mut os_rng = OsRng::default(); let msg: Vec = (0..36).map(|_| os_rng.gen::()).collect();