mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-25 03:11:21 +00:00
refactor(key-protocol)!: introduce constitent domain separators for key protocol (#717)
* feat(key_protocol): version-independent domain separators for normal keys Introduce a /LEE-Keys/v1/... namespace for account key derivation (private and public), distinct from LEE protocol versioning (/LEE/v0.3/...). This lets the key derivation protocol evolve independently of the transaction/message format version, so a LEE version bump doesn't silently rotate or orphan user keys. Covers master/child private and public key derivation, authorization and viewing secret keys, and nullifier secret/public key derivation (the latter also used by the privacy-preserving guest circuit). Pinned regression tests updated to match the new derivation outputs. * chore(artifacts): rebuild guest ELFs and test fixture for key protocol change Regenerated via just build-artifacts after the /LEE-Keys/v1/... domain separator migration touched lee_core::nullifier, which every guest program links against, and changed derived account IDs embedded in the prebuilt sequencer fixture. * test(testnet_initial_state): update pinned private-account values for new key domain separators initial_priv_accounts_private_keys() derives from fixed SSK roots through the key_protocol chain the /LEE-Keys/v1/... migration changed, so the derived viewing secret keys and account addresses shifted even though the SSK roots themselves didn't. Public account addresses are unaffected since they sign with a raw PrivateKey outside this chain. * chore(artifacts): rebuild guest ELFs and test fixture after dev rebase The rebase onto dev conflicted on these binaries (dev had independently rebuilt them since this branch diverged). Conflicts were resolved provisionally during the rebase and are now replaced with a fresh build-artifacts run against the fully merged tree. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
89815f19fb
commit
2a7a586a59
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -357,8 +357,8 @@ mod tests {
|
||||
let account_id = AccountId::for_private_pda(&program_id, &seed, &npk, &vpk, u128::MAX);
|
||||
|
||||
let expected_npk = NullifierPublicKey([
|
||||
73, 227, 101, 209, 210, 127, 85, 171, 217, 20, 52, 68, 63, 127, 88, 157, 162, 165, 221,
|
||||
15, 86, 162, 128, 15, 56, 89, 95, 33, 216, 229, 181, 123,
|
||||
59, 136, 7, 185, 56, 46, 38, 4, 195, 155, 85, 32, 161, 24, 119, 14, 148, 100, 26, 152,
|
||||
239, 255, 145, 142, 122, 166, 219, 75, 200, 9, 168, 7,
|
||||
]);
|
||||
// AccountId is derived from (program_id, seed, npk), so it changes when npk changes.
|
||||
// We verify npk is pinned, and AccountId is deterministically derived from it.
|
||||
|
||||
@@ -24,7 +24,7 @@ pub struct ChildKeysPrivate {
|
||||
impl ChildKeysPrivate {
|
||||
#[must_use]
|
||||
pub fn root(seed: [u8; 64]) -> Self {
|
||||
let hash_value = hmac_sha512::HMAC::mac(seed, b"LEE_master_priv");
|
||||
let hash_value = hmac_sha512::HMAC::mac(seed, b"/LEE-Keys/v1/Master/Private");
|
||||
let (first, ccc) = split_hash(&hash_value);
|
||||
|
||||
let ssk = SecretSpendingKey(first);
|
||||
@@ -34,7 +34,7 @@ impl ChildKeysPrivate {
|
||||
|
||||
#[must_use]
|
||||
pub fn nth_child(&self, cci: u32) -> Self {
|
||||
const DOMAIN: &[u8; 21] = b"/LEE/v0.3/Keys/Parent";
|
||||
const DOMAIN: &[u8; 27] = b"/LEE-Keys/v1/Parent/Private";
|
||||
|
||||
// `parent_hash`` is used to incorporate entropy based on the parent node's keys
|
||||
// to generate the `ssk` and `ccc` values.
|
||||
@@ -48,7 +48,7 @@ impl ChildKeysPrivate {
|
||||
// Each child (of the same parent node) share the same `parent_pt`.
|
||||
// To ensure that each child generates unique keys, we include the child index.
|
||||
let mut input = vec![];
|
||||
input.extend_from_slice(b"LEE_seed_priv");
|
||||
input.extend_from_slice(b"/LEE-Keys/v1/Seed/Private");
|
||||
input.extend_from_slice(&parent_pt);
|
||||
#[expect(clippy::big_endian_bytes, reason = "BIP-032 uses big endian")]
|
||||
input.extend_from_slice(&cci.to_be_bytes());
|
||||
@@ -125,38 +125,38 @@ mod tests {
|
||||
let keys = ChildKeysPrivate::root(SEED);
|
||||
|
||||
let expected_ssk = key_management::secret_holders::SecretSpendingKey([
|
||||
246, 79, 26, 124, 135, 95, 52, 51, 201, 27, 48, 194, 2, 144, 51, 219, 245, 128, 139,
|
||||
222, 42, 195, 105, 33, 115, 97, 186, 0, 97, 14, 218, 191,
|
||||
89, 83, 219, 205, 176, 131, 82, 74, 181, 52, 131, 240, 254, 155, 208, 126, 153, 157,
|
||||
15, 191, 143, 255, 97, 11, 215, 173, 222, 16, 183, 7, 202, 121,
|
||||
]);
|
||||
|
||||
let expected_ccc = [
|
||||
56, 114, 70, 249, 67, 169, 206, 9, 192, 11, 180, 168, 149, 129, 42, 95, 43, 157, 130,
|
||||
111, 13, 5, 195, 75, 20, 255, 162, 85, 40, 251, 8, 168,
|
||||
186, 27, 116, 2, 28, 54, 110, 48, 7, 169, 72, 98, 9, 24, 12, 67, 109, 226, 251, 203,
|
||||
24, 253, 128, 147, 135, 32, 56, 255, 46, 230, 70, 10,
|
||||
];
|
||||
|
||||
let expected_ask = lee_core::AuthorizationSecretKey([
|
||||
3, 154, 34, 187, 166, 138, 64, 10, 172, 210, 224, 75, 165, 157, 94, 27, 81, 209, 194,
|
||||
189, 60, 171, 252, 226, 25, 136, 158, 59, 56, 39, 60, 175,
|
||||
101, 181, 188, 132, 20, 141, 124, 205, 63, 12, 23, 238, 2, 74, 87, 224, 188, 155, 99,
|
||||
63, 14, 60, 27, 126, 47, 106, 97, 114, 103, 158, 103, 60,
|
||||
]);
|
||||
|
||||
let expected_nsk: NullifierSecretKey = [
|
||||
227, 13, 41, 248, 160, 185, 37, 158, 48, 134, 157, 185, 50, 249, 13, 114, 128, 43, 92,
|
||||
148, 161, 91, 158, 206, 209, 246, 46, 49, 114, 165, 72, 64,
|
||||
46, 160, 51, 114, 77, 129, 41, 210, 140, 244, 36, 67, 95, 17, 96, 147, 113, 144, 67,
|
||||
94, 198, 153, 220, 206, 59, 61, 18, 52, 63, 0, 51, 102,
|
||||
];
|
||||
|
||||
let expected_npk = lee_core::NullifierPublicKey([
|
||||
42, 60, 83, 112, 244, 198, 238, 159, 150, 105, 13, 134, 103, 228, 213, 247, 121, 42,
|
||||
65, 51, 122, 196, 228, 163, 244, 251, 219, 119, 8, 14, 68, 16,
|
||||
31, 162, 180, 178, 183, 165, 42, 194, 236, 199, 174, 146, 241, 104, 255, 171, 249, 138,
|
||||
18, 132, 96, 10, 57, 210, 159, 169, 66, 238, 104, 132, 226, 13,
|
||||
]);
|
||||
|
||||
let expected_vsk = ViewingSecretKey::new(
|
||||
[
|
||||
92, 182, 50, 80, 228, 152, 149, 83, 44, 33, 179, 59, 237, 153, 45, 46, 216, 142,
|
||||
62, 31, 28, 18, 44, 27, 130, 54, 10, 13, 148, 111, 214, 107,
|
||||
239, 105, 105, 155, 13, 89, 203, 100, 162, 108, 87, 128, 65, 88, 101, 217, 214,
|
||||
126, 200, 51, 35, 146, 251, 207, 76, 44, 218, 2, 51, 113, 171, 167,
|
||||
],
|
||||
[
|
||||
135, 73, 174, 183, 171, 136, 40, 174, 28, 18, 73, 1, 183, 13, 208, 39, 113, 79,
|
||||
136, 163, 234, 119, 117, 192, 103, 49, 193, 16, 188, 111, 4, 78,
|
||||
107, 52, 23, 158, 102, 144, 107, 47, 137, 52, 56, 143, 52, 225, 107, 228, 152, 23,
|
||||
24, 172, 164, 21, 92, 89, 87, 175, 51, 190, 34, 219, 52, 47,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -164,69 +164,68 @@ mod tests {
|
||||
// implementation, unlike every other vector here; its trailing 32 bytes are
|
||||
// rho = SHA3-512(d || 3)[..32] per FIPS-203, checked against the independent `d`.
|
||||
let expected_vpk: [u8; 1184] = [
|
||||
95, 42, 170, 49, 164, 173, 200, 156, 66, 32, 71, 126, 122, 140, 148, 144, 114, 143,
|
||||
233, 199, 104, 82, 179, 49, 43, 114, 130, 182, 71, 4, 45, 101, 65, 136, 196, 72, 129,
|
||||
128, 204, 239, 137, 84, 230, 210, 18, 214, 252, 40, 198, 210, 24, 158, 53, 151, 166,
|
||||
24, 47, 143, 8, 158, 119, 240, 204, 210, 242, 96, 191, 147, 106, 98, 198, 93, 193, 163,
|
||||
31, 132, 36, 16, 50, 83, 24, 225, 250, 106, 55, 231, 188, 90, 194, 128, 10, 225, 186,
|
||||
41, 225, 165, 126, 57, 32, 163, 129, 42, 68, 113, 177, 239, 106, 144, 217, 188, 192,
|
||||
174, 38, 161, 189, 24, 107, 14, 54, 167, 221, 120, 194, 6, 22, 163, 86, 96, 47, 220,
|
||||
227, 176, 173, 52, 150, 183, 25, 40, 200, 19, 134, 51, 172, 126, 35, 147, 79, 207, 235,
|
||||
9, 243, 197, 84, 4, 194, 142, 207, 118, 121, 133, 58, 12, 58, 226, 22, 106, 172, 56,
|
||||
223, 161, 145, 60, 28, 47, 95, 84, 127, 1, 235, 72, 0, 131, 202, 15, 151, 93, 52, 18,
|
||||
13, 247, 91, 80, 240, 229, 85, 72, 135, 84, 230, 113, 196, 162, 3, 24, 87, 176, 80,
|
||||
202, 99, 44, 87, 229, 96, 254, 27, 181, 181, 58, 191, 116, 19, 68, 235, 35, 86, 227,
|
||||
89, 49, 70, 102, 54, 153, 224, 117, 34, 113, 57, 121, 202, 42, 248, 24, 125, 134, 134,
|
||||
57, 126, 204, 131, 191, 181, 71, 197, 184, 137, 48, 76, 29, 174, 137, 154, 253, 50, 68,
|
||||
184, 122, 173, 106, 144, 207, 48, 213, 156, 182, 26, 103, 203, 133, 131, 47, 184, 189,
|
||||
109, 4, 182, 126, 71, 180, 153, 18, 82, 77, 201, 23, 176, 92, 12, 146, 48, 26, 236,
|
||||
139, 157, 174, 214, 77, 253, 163, 94, 52, 133, 88, 200, 251, 156, 197, 201, 7, 239,
|
||||
117, 83, 57, 188, 85, 31, 196, 106, 164, 147, 36, 32, 241, 143, 54, 121, 195, 183, 98,
|
||||
182, 135, 90, 84, 118, 212, 91, 115, 41, 75, 193, 156, 44, 9, 196, 199, 241, 123, 148,
|
||||
31, 105, 126, 160, 234, 16, 196, 149, 192, 66, 34, 199, 132, 160, 98, 229, 90, 158, 46,
|
||||
108, 112, 126, 165, 115, 234, 128, 164, 241, 132, 171, 186, 212, 121, 74, 217, 165,
|
||||
111, 216, 21, 169, 89, 86, 173, 163, 183, 61, 28, 117, 104, 211, 206, 30, 194, 180, 34,
|
||||
180, 151, 150, 212, 90, 75, 139, 138, 253, 52, 60, 252, 5, 126, 152, 12, 153, 77, 232,
|
||||
167, 14, 163, 130, 76, 18, 117, 96, 113, 144, 234, 22, 56, 106, 210, 78, 83, 50, 43,
|
||||
99, 120, 20, 172, 89, 61, 10, 75, 121, 118, 226, 153, 53, 161, 144, 53, 246, 37, 213,
|
||||
216, 48, 183, 124, 58, 161, 145, 126, 238, 120, 112, 103, 65, 176, 40, 104, 60, 47, 10,
|
||||
138, 154, 89, 174, 164, 69, 182, 168, 196, 131, 68, 18, 189, 204, 74, 180, 16, 233,
|
||||
178, 175, 57, 180, 212, 58, 148, 92, 2, 16, 255, 103, 27, 212, 117, 12, 10, 54, 105,
|
||||
253, 9, 124, 250, 210, 14, 127, 151, 74, 49, 209, 59, 125, 184, 183, 175, 251, 200,
|
||||
172, 120, 59, 41, 89, 199, 3, 161, 189, 138, 50, 69, 108, 102, 155, 210, 17, 73, 235,
|
||||
75, 145, 132, 67, 89, 88, 225, 182, 156, 248, 199, 112, 52, 22, 134, 80, 40, 250, 42,
|
||||
185, 57, 200, 90, 137, 16, 158, 98, 114, 48, 151, 35, 128, 49, 49, 118, 195, 57, 40,
|
||||
94, 103, 156, 186, 1, 112, 130, 178, 59, 22, 71, 153, 173, 195, 178, 216, 149, 24, 202,
|
||||
245, 123, 117, 106, 44, 55, 128, 37, 165, 26, 103, 158, 52, 10, 188, 10, 195, 146, 204,
|
||||
85, 66, 66, 162, 73, 25, 59, 107, 57, 149, 100, 216, 24, 69, 49, 134, 233, 96, 29, 176,
|
||||
8, 188, 121, 145, 44, 35, 199, 4, 48, 24, 76, 69, 250, 92, 126, 40, 52, 162, 72, 113,
|
||||
81, 96, 116, 105, 150, 59, 211, 236, 141, 87, 178, 9, 17, 117, 43, 139, 17, 150, 153,
|
||||
114, 195, 212, 2, 192, 56, 91, 70, 200, 75, 2, 57, 171, 147, 184, 236, 15, 64, 26, 191,
|
||||
131, 179, 13, 195, 195, 166, 208, 180, 93, 186, 155, 102, 189, 57, 82, 73, 39, 44, 249,
|
||||
249, 183, 33, 112, 59, 130, 20, 193, 41, 40, 128, 131, 106, 136, 51, 75, 56, 188, 167,
|
||||
119, 5, 118, 73, 84, 168, 38, 121, 182, 190, 252, 182, 87, 142, 33, 66, 131, 75, 36,
|
||||
216, 181, 186, 213, 148, 191, 182, 115, 159, 83, 1, 14, 170, 55, 21, 251, 65, 135, 117,
|
||||
171, 147, 38, 210, 129, 251, 151, 177, 213, 1, 18, 22, 241, 62, 173, 80, 76, 85, 129,
|
||||
139, 192, 137, 205, 203, 114, 181, 121, 40, 141, 9, 194, 58, 20, 200, 126, 151, 51,
|
||||
129, 146, 92, 156, 93, 192, 72, 26, 33, 138, 107, 138, 124, 193, 138, 8, 244, 84, 116,
|
||||
28, 156, 123, 1, 19, 186, 119, 231, 157, 70, 160, 5, 34, 80, 201, 4, 39, 38, 217, 85,
|
||||
53, 10, 40, 136, 145, 225, 26, 65, 32, 76, 33, 245, 72, 166, 5, 165, 44, 67, 86, 99,
|
||||
87, 9, 148, 131, 72, 223, 71, 179, 243, 39, 36, 34, 145, 86, 134, 12, 127, 103, 3, 191,
|
||||
254, 216, 195, 12, 197, 184, 238, 67, 34, 226, 4, 100, 135, 165, 40, 164, 113, 110,
|
||||
132, 68, 100, 72, 217, 67, 169, 199, 96, 120, 152, 27, 26, 241, 103, 61, 162, 154, 113,
|
||||
55, 75, 156, 17, 114, 105, 145, 158, 13, 251, 50, 221, 219, 150, 88, 5, 184, 92, 137,
|
||||
164, 25, 117, 51, 87, 233, 93, 5, 84, 125, 251, 162, 110, 231, 36, 2, 235, 251, 185,
|
||||
45, 180, 132, 53, 104, 206, 144, 133, 67, 164, 76, 84, 152, 236, 157, 253, 115, 97,
|
||||
195, 177, 172, 233, 51, 161, 196, 66, 59, 233, 88, 133, 12, 146, 172, 148, 236, 58, 5,
|
||||
226, 48, 53, 219, 185, 72, 86, 7, 249, 151, 205, 32, 57, 163, 17, 71, 37, 162, 97, 137,
|
||||
142, 252, 190, 58, 196, 70, 181, 4, 48, 123, 9, 75, 198, 100, 134, 36, 18, 45, 99, 18,
|
||||
191, 75, 55, 30, 144, 197, 0, 44, 71, 199, 78, 121, 92, 76, 84, 43, 133, 139, 77, 105,
|
||||
83, 178, 221, 215, 108, 55, 58, 7, 106, 96, 146, 9, 70, 140, 250, 187, 206, 95, 54, 74,
|
||||
30, 146, 15, 182, 5, 79, 41, 135, 59, 75, 103, 82, 63, 39, 69, 178, 215, 49, 234, 146,
|
||||
127, 186, 192, 189, 107, 140, 11, 39, 162, 120, 90, 133, 106, 184, 87, 144, 5, 80, 80,
|
||||
22, 241, 181, 128, 201, 61, 186, 124, 9, 165, 192, 78, 67, 141, 57, 10, 94, 36, 75,
|
||||
118, 21, 105, 252, 45, 196, 60, 23, 182, 189, 252, 152, 182, 72, 229, 213, 89, 165,
|
||||
222, 151, 52, 182, 110, 127, 158,
|
||||
9, 112, 59, 246, 41, 55, 116, 67, 166, 192, 83, 50, 213, 177, 26, 20, 243, 125, 9, 35,
|
||||
156, 82, 73, 55, 138, 66, 88, 141, 179, 140, 141, 50, 149, 79, 181, 43, 174, 200, 31,
|
||||
111, 9, 154, 216, 90, 4, 89, 136, 130, 6, 139, 36, 142, 27, 168, 149, 210, 2, 105, 25,
|
||||
39, 94, 244, 7, 242, 108, 19, 64, 72, 25, 237, 105, 3, 215, 75, 21, 211, 196, 58, 39,
|
||||
116, 34, 24, 215, 25, 152, 56, 62, 70, 136, 98, 188, 21, 138, 18, 214, 75, 140, 185,
|
||||
77, 4, 192, 71, 202, 76, 158, 212, 161, 37, 48, 171, 156, 254, 192, 68, 19, 89, 83, 83,
|
||||
131, 194, 135, 250, 59, 239, 40, 22, 15, 211, 140, 112, 7, 154, 36, 196, 152, 144, 72,
|
||||
64, 117, 249, 134, 46, 21, 36, 101, 242, 103, 182, 226, 93, 207, 243, 0, 214, 3, 117,
|
||||
129, 65, 45, 181, 1, 44, 82, 71, 145, 188, 128, 21, 205, 56, 125, 31, 64, 16, 245, 247,
|
||||
55, 10, 32, 112, 67, 164, 57, 63, 124, 10, 111, 251, 15, 21, 23, 132, 206, 122, 29, 16,
|
||||
137, 206, 109, 193, 192, 132, 98, 140, 125, 41, 22, 41, 7, 208, 33, 160, 121, 143, 0,
|
||||
24, 224, 149, 107, 141, 196, 129, 187, 181, 23, 21, 86, 62, 160, 185, 134, 185, 151,
|
||||
165, 11, 72, 118, 163, 49, 182, 67, 0, 142, 101, 42, 2, 99, 102, 200, 92, 105, 53, 53,
|
||||
144, 9, 84, 32, 119, 14, 12, 129, 26, 247, 173, 118, 193, 24, 252, 131, 99, 22, 97,
|
||||
207, 213, 75, 199, 238, 197, 143, 153, 60, 13, 156, 236, 11, 218, 171, 106, 58, 52, 99,
|
||||
236, 149, 153, 249, 147, 49, 179, 57, 20, 100, 38, 78, 62, 235, 110, 113, 72, 77, 177,
|
||||
225, 51, 114, 172, 28, 150, 246, 190, 164, 43, 60, 3, 225, 85, 160, 38, 205, 189, 163,
|
||||
72, 231, 56, 111, 2, 163, 74, 114, 218, 10, 45, 181, 35, 59, 119, 124, 4, 92, 45, 44,
|
||||
53, 154, 122, 161, 65, 244, 130, 78, 83, 9, 198, 204, 134, 11, 214, 75, 156, 178, 151,
|
||||
19, 212, 10, 140, 133, 128, 45, 93, 178, 121, 169, 108, 170, 134, 200, 0, 215, 172, 43,
|
||||
111, 105, 182, 82, 235, 132, 236, 7, 37, 239, 235, 142, 173, 246, 150, 61, 8, 140, 159,
|
||||
41, 166, 23, 218, 153, 65, 151, 91, 137, 132, 180, 141, 163, 113, 16, 209, 201, 63, 65,
|
||||
121, 236, 66, 47, 74, 177, 74, 80, 117, 34, 44, 27, 22, 238, 154, 140, 90, 12, 50, 47,
|
||||
5, 64, 121, 227, 36, 156, 233, 19, 85, 89, 1, 96, 137, 77, 187, 235, 124, 226, 3, 6,
|
||||
219, 70, 126, 89, 247, 70, 85, 208, 200, 99, 37, 89, 18, 249, 128, 233, 245, 123, 18,
|
||||
49, 32, 227, 163, 20, 184, 131, 203, 153, 4, 60, 188, 243, 157, 172, 120, 176, 72, 210,
|
||||
146, 177, 54, 4, 125, 33, 82, 99, 184, 93, 186, 106, 54, 57, 156, 27, 96, 177, 89, 81,
|
||||
12, 11, 83, 161, 153, 253, 160, 132, 28, 192, 34, 221, 184, 46, 51, 171, 203, 36, 121,
|
||||
83, 229, 80, 39, 168, 115, 36, 126, 86, 153, 228, 115, 137, 127, 162, 189, 222, 200,
|
||||
67, 231, 38, 3, 186, 66, 62, 69, 26, 166, 9, 99, 149, 134, 178, 0, 87, 120, 150, 11,
|
||||
216, 124, 191, 136, 129, 130, 115, 101, 143, 195, 134, 79, 118, 197, 177, 165, 179,
|
||||
117, 19, 50, 215, 51, 171, 123, 236, 193, 172, 24, 9, 5, 74, 28, 237, 43, 187, 114, 90,
|
||||
187, 41, 188, 204, 64, 19, 147, 114, 0, 23, 16, 53, 89, 32, 36, 184, 145, 165, 6, 57,
|
||||
134, 80, 102, 66, 59, 16, 60, 43, 132, 101, 73, 84, 161, 11, 192, 229, 163, 160, 117,
|
||||
26, 11, 113, 50, 51, 98, 34, 220, 98, 143, 102, 105, 97, 156, 241, 34, 138, 136, 160,
|
||||
129, 216, 89, 171, 42, 92, 178, 90, 5, 168, 84, 189, 223, 52, 33, 218, 203, 27, 89,
|
||||
188, 184, 138, 172, 34, 166, 171, 156, 180, 161, 130, 94, 252, 166, 148, 114, 39, 138,
|
||||
156, 66, 222, 146, 171, 40, 118, 29, 14, 5, 147, 53, 226, 24, 85, 1, 68, 28, 98, 99,
|
||||
236, 65, 91, 131, 145, 152, 159, 198, 202, 144, 6, 125, 93, 247, 26, 149, 51, 159, 164,
|
||||
100, 142, 239, 66, 105, 106, 155, 177, 96, 216, 160, 20, 198, 10, 186, 113, 83, 85, 51,
|
||||
7, 246, 227, 69, 80, 22, 38, 129, 198, 7, 66, 130, 95, 32, 224, 110, 62, 231, 70, 123,
|
||||
55, 175, 115, 219, 199, 234, 43, 73, 93, 198, 188, 196, 231, 76, 72, 193, 179, 47, 153,
|
||||
182, 203, 193, 116, 70, 37, 57, 198, 67, 82, 24, 119, 60, 68, 16, 94, 206, 178, 173,
|
||||
135, 89, 90, 238, 245, 30, 112, 59, 76, 110, 217, 188, 135, 68, 155, 184, 16, 27, 168,
|
||||
203, 44, 101, 96, 164, 184, 48, 24, 84, 56, 169, 44, 179, 19, 6, 66, 143, 3, 71, 128,
|
||||
181, 244, 43, 70, 67, 168, 17, 58, 184, 74, 35, 167, 50, 198, 180, 205, 85, 126, 11,
|
||||
151, 116, 238, 21, 83, 146, 34, 69, 233, 32, 87, 117, 107, 28, 116, 102, 62, 74, 26,
|
||||
80, 38, 201, 44, 145, 248, 129, 136, 243, 177, 191, 215, 107, 93, 56, 99, 35, 252, 183,
|
||||
220, 23, 47, 173, 7, 14, 238, 5, 159, 88, 242, 101, 223, 68, 112, 158, 40, 148, 198,
|
||||
26, 27, 128, 231, 177, 17, 101, 191, 12, 103, 91, 62, 216, 112, 75, 188, 64, 65, 218,
|
||||
29, 122, 177, 204, 50, 66, 123, 84, 91, 15, 238, 220, 41, 24, 17, 36, 169, 231, 152,
|
||||
245, 59, 25, 35, 49, 141, 205, 67, 5, 102, 162, 146, 41, 89, 49, 215, 58, 35, 106, 7,
|
||||
110, 209, 231, 123, 2, 27, 170, 25, 1, 163, 200, 120, 142, 73, 202, 16, 156, 162, 133,
|
||||
182, 186, 171, 153, 181, 179, 230, 225, 202, 184, 149, 73, 210, 51, 201, 134, 227, 80,
|
||||
51, 108, 103, 171, 201, 107, 237, 18, 197, 4, 167, 121, 210, 53, 156, 245, 120, 117,
|
||||
174, 167, 83, 220, 73, 125, 3, 179, 87, 70, 25, 59, 182, 103, 164, 134, 193, 51, 16,
|
||||
137, 23, 27, 194, 18, 98, 112, 93, 18, 220, 137, 37, 97, 123, 161, 232, 157, 231, 44,
|
||||
147, 11, 179, 89, 88, 4, 45, 192, 36, 124, 12, 203, 84, 109, 164, 19, 151, 183, 145,
|
||||
108, 233, 122, 115, 227, 104, 186, 128, 38, 185, 87, 89, 220, 198, 174, 160, 165, 152,
|
||||
40, 236, 0, 167, 106, 175, 244, 4, 55, 213, 18, 133, 255, 153, 9, 188, 247, 38, 225,
|
||||
140, 52, 45, 186, 134, 255, 10, 138, 132, 237, 79, 72, 133, 108, 147, 85, 247, 55, 61,
|
||||
252, 187, 135, 75, 170, 63, 63, 239, 196, 99, 147, 72, 117, 111, 126,
|
||||
];
|
||||
assert!(expected_ssk == keys.value.0.secret_spending_key);
|
||||
assert!(expected_ccc == keys.ccc);
|
||||
@@ -243,37 +242,37 @@ mod tests {
|
||||
let child_node = ChildKeysPrivate::nth_child(&root_node, 42_u32);
|
||||
|
||||
let expected_ssk = key_management::secret_holders::SecretSpendingKey([
|
||||
109, 21, 107, 97, 112, 105, 143, 134, 185, 35, 168, 205, 138, 110, 125, 155, 193, 57,
|
||||
36, 19, 214, 180, 194, 46, 107, 235, 43, 80, 132, 19, 254, 231,
|
||||
255, 91, 0, 255, 146, 9, 219, 224, 232, 0, 145, 114, 101, 34, 207, 151, 203, 96, 120,
|
||||
175, 228, 160, 182, 56, 113, 198, 151, 158, 223, 183, 121, 111,
|
||||
]);
|
||||
|
||||
let expected_ccc = [
|
||||
64, 218, 41, 59, 115, 126, 128, 3, 77, 77, 54, 84, 87, 253, 181, 112, 244, 254, 176,
|
||||
243, 86, 127, 219, 255, 64, 164, 218, 129, 83, 65, 176, 179,
|
||||
149, 233, 214, 67, 128, 214, 160, 223, 4, 243, 147, 157, 59, 9, 140, 26, 30, 60, 246,
|
||||
175, 98, 220, 192, 241, 47, 25, 197, 150, 25, 192, 2, 229,
|
||||
];
|
||||
|
||||
let expected_ask = lee_core::AuthorizationSecretKey([
|
||||
33, 29, 199, 63, 191, 14, 196, 15, 51, 70, 236, 125, 93, 120, 78, 99, 90, 239, 220,
|
||||
168, 226, 46, 208, 238, 70, 117, 17, 28, 163, 89, 177, 129,
|
||||
181, 178, 105, 190, 28, 96, 174, 62, 65, 157, 130, 133, 57, 64, 9, 248, 208, 87, 211,
|
||||
185, 124, 194, 181, 148, 243, 25, 63, 35, 38, 65, 48, 74,
|
||||
]);
|
||||
|
||||
let expected_nsk: NullifierSecretKey = [
|
||||
97, 83, 94, 170, 125, 55, 27, 105, 106, 42, 73, 99, 169, 221, 210, 124, 117, 52, 98,
|
||||
131, 98, 202, 79, 95, 151, 196, 239, 242, 6, 127, 160, 160,
|
||||
9, 95, 3, 185, 154, 73, 180, 31, 241, 193, 141, 13, 247, 72, 210, 198, 29, 39, 33, 149,
|
||||
238, 157, 50, 138, 162, 227, 70, 164, 93, 169, 83, 231,
|
||||
];
|
||||
let expected_npk = lee_core::NullifierPublicKey([
|
||||
81, 199, 141, 154, 209, 135, 105, 75, 106, 240, 124, 190, 245, 233, 152, 34, 225, 234,
|
||||
212, 221, 121, 68, 255, 97, 231, 142, 26, 54, 169, 53, 69, 242,
|
||||
220, 138, 42, 117, 37, 161, 212, 202, 29, 17, 97, 186, 118, 172, 21, 159, 163, 147, 39,
|
||||
65, 114, 231, 255, 39, 207, 253, 76, 171, 57, 141, 34, 11,
|
||||
]);
|
||||
|
||||
let expected_vsk = ViewingSecretKey::new(
|
||||
[
|
||||
14, 173, 255, 235, 8, 1, 246, 119, 243, 18, 235, 31, 209, 92, 142, 7, 175, 223,
|
||||
228, 201, 173, 165, 148, 137, 141, 160, 175, 161, 110, 139, 54, 183,
|
||||
122, 167, 237, 237, 86, 162, 1, 146, 79, 10, 160, 65, 61, 77, 8, 65, 241, 247, 144,
|
||||
153, 109, 134, 20, 7, 229, 52, 249, 30, 32, 109, 23, 112,
|
||||
],
|
||||
[
|
||||
10, 253, 101, 172, 213, 221, 88, 85, 178, 89, 218, 73, 28, 212, 1, 2, 105, 161,
|
||||
180, 24, 49, 6, 182, 155, 22, 220, 121, 42, 175, 59, 233, 109,
|
||||
112, 168, 129, 117, 127, 160, 73, 110, 21, 164, 82, 213, 253, 135, 11, 26, 213, 53,
|
||||
120, 199, 254, 143, 28, 169, 170, 187, 92, 12, 43, 217, 129, 58,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -281,69 +280,68 @@ mod tests {
|
||||
// implementation, unlike every other vector here; its trailing 32 bytes are
|
||||
// rho = SHA3-512(d || 3)[..32] per FIPS-203, checked against the independent `d`.
|
||||
let expected_vpk: [u8; 1184] = [
|
||||
153, 195, 136, 113, 42, 34, 28, 116, 169, 190, 53, 81, 59, 6, 163, 170, 199, 98, 201,
|
||||
54, 24, 171, 26, 191, 144, 248, 95, 63, 199, 113, 27, 67, 97, 49, 210, 66, 190, 74, 54,
|
||||
252, 12, 143, 197, 243, 27, 111, 198, 43, 23, 146, 3, 183, 171, 41, 72, 92, 46, 112,
|
||||
184, 160, 0, 25, 155, 109, 203, 70, 196, 88, 135, 121, 147, 12, 96, 230, 205, 217, 66,
|
||||
55, 78, 215, 196, 6, 8, 160, 186, 73, 56, 218, 76, 10, 31, 148, 182, 170, 131, 26, 101,
|
||||
210, 125, 125, 242, 160, 146, 35, 195, 59, 182, 55, 130, 198, 67, 109, 245, 66, 229,
|
||||
226, 154, 189, 112, 5, 160, 39, 7, 139, 152, 58, 197, 167, 81, 160, 37, 96, 175, 250,
|
||||
78, 232, 181, 152, 131, 41, 92, 45, 33, 184, 142, 25, 157, 62, 166, 111, 148, 137, 143,
|
||||
241, 176, 74, 176, 243, 178, 26, 232, 204, 119, 181, 17, 128, 91, 134, 8, 90, 35, 11,
|
||||
124, 98, 76, 76, 43, 82, 135, 85, 215, 72, 177, 37, 218, 131, 158, 139, 59, 155, 104,
|
||||
13, 13, 150, 34, 192, 54, 115, 90, 44, 84, 132, 51, 174, 155, 64, 26, 42, 246, 28, 30,
|
||||
252, 136, 227, 69, 174, 27, 233, 56, 214, 102, 117, 141, 177, 133, 181, 177, 8, 150,
|
||||
85, 104, 243, 123, 22, 25, 7, 42, 152, 226, 88, 93, 213, 201, 197, 235, 17, 185, 84,
|
||||
57, 161, 179, 37, 251, 129, 62, 214, 48, 161, 247, 124, 147, 120, 180, 197, 9, 83, 63,
|
||||
38, 182, 206, 20, 116, 28, 143, 134, 173, 55, 54, 1, 254, 86, 9, 67, 213, 144, 95, 48,
|
||||
29, 47, 119, 156, 188, 70, 18, 37, 202, 65, 173, 22, 177, 14, 244, 120, 166, 20, 82,
|
||||
203, 162, 24, 56, 240, 154, 249, 11, 31, 182, 55, 71, 171, 196, 3, 20, 151, 112, 159,
|
||||
131, 91, 201, 80, 116, 228, 6, 184, 140, 55, 205, 4, 91, 116, 46, 224, 32, 216, 146,
|
||||
46, 232, 75, 156, 109, 54, 193, 146, 248, 2, 49, 17, 102, 214, 150, 202, 1, 6, 110, 2,
|
||||
202, 34, 162, 107, 205, 241, 123, 83, 108, 152, 145, 231, 219, 158, 24, 171, 48, 121,
|
||||
2, 193, 15, 21, 9, 173, 172, 30, 111, 58, 94, 0, 18, 1, 140, 7, 52, 209, 214, 59, 127,
|
||||
228, 30, 154, 102, 119, 233, 170, 160, 120, 108, 154, 117, 28, 23, 70, 56, 35, 11, 9,
|
||||
39, 198, 86, 79, 119, 213, 88, 193, 5, 15, 214, 139, 199, 236, 243, 159, 171, 185, 22,
|
||||
35, 216, 20, 149, 137, 17, 74, 117, 165, 55, 116, 139, 171, 181, 204, 196, 104, 178,
|
||||
246, 103, 73, 249, 165, 108, 237, 234, 155, 133, 35, 139, 98, 136, 51, 220, 98, 181,
|
||||
40, 151, 80, 58, 242, 84, 206, 242, 199, 145, 156, 160, 61, 116, 100, 77, 89, 184, 213,
|
||||
119, 25, 4, 107, 26, 23, 87, 101, 85, 68, 115, 221, 171, 170, 123, 246, 26, 51, 108,
|
||||
13, 101, 217, 17, 0, 103, 110, 15, 136, 70, 255, 12, 197, 89, 225, 158, 25, 116, 32,
|
||||
53, 169, 122, 4, 32, 108, 30, 181, 180, 142, 250, 141, 217, 8, 33, 111, 89, 48, 196,
|
||||
90, 158, 207, 213, 165, 97, 196, 21, 193, 114, 199, 167, 123, 95, 118, 101, 107, 130,
|
||||
161, 186, 67, 27, 27, 161, 192, 157, 252, 98, 131, 186, 124, 64, 224, 199, 126, 47,
|
||||
230, 66, 92, 97, 38, 0, 35, 197, 178, 219, 121, 240, 149, 197, 18, 165, 39, 3, 137, 58,
|
||||
8, 227, 152, 124, 247, 103, 85, 150, 194, 140, 108, 96, 151, 57, 117, 182, 177, 47,
|
||||
168, 112, 184, 214, 42, 48, 65, 3, 30, 179, 187, 137, 179, 122, 98, 210, 3, 7, 102,
|
||||
235, 3, 145, 107, 200, 72, 4, 153, 135, 43, 202, 155, 170, 174, 148, 161, 37, 43, 219,
|
||||
16, 229, 65, 45, 225, 49, 126, 168, 215, 93, 153, 179, 49, 108, 51, 131, 227, 82, 134,
|
||||
77, 28, 175, 237, 136, 49, 137, 164, 197, 224, 42, 85, 250, 48, 109, 196, 70, 12, 236,
|
||||
65, 121, 254, 3, 37, 183, 201, 124, 246, 130, 174, 89, 7, 81, 235, 147, 148, 40, 147,
|
||||
174, 204, 99, 22, 150, 133, 195, 22, 108, 119, 59, 21, 104, 37, 251, 61, 92, 82, 9,
|
||||
122, 73, 48, 97, 82, 52, 170, 10, 79, 134, 17, 8, 247, 96, 108, 186, 230, 6, 138, 90,
|
||||
16, 36, 56, 45, 179, 121, 179, 17, 1, 174, 106, 4, 170, 81, 185, 60, 47, 201, 26, 67,
|
||||
199, 160, 52, 60, 63, 12, 82, 114, 122, 87, 166, 141, 168, 101, 177, 129, 197, 127,
|
||||
226, 166, 159, 168, 108, 218, 112, 31, 246, 4, 73, 134, 155, 197, 192, 8, 71, 135, 163,
|
||||
9, 122, 183, 127, 156, 60, 178, 124, 135, 129, 7, 185, 105, 232, 250, 199, 173, 80, 18,
|
||||
15, 118, 183, 3, 105, 56, 189, 107, 157, 44, 101, 103, 60, 99, 69, 187, 220, 146, 116,
|
||||
202, 85, 115, 219, 87, 241, 209, 39, 14, 184, 154, 236, 211, 31, 117, 106, 24, 68, 233,
|
||||
161, 49, 229, 105, 179, 58, 171, 215, 194, 178, 6, 243, 155, 2, 148, 202, 45, 145, 118,
|
||||
210, 233, 112, 208, 186, 157, 150, 68, 148, 94, 184, 49, 69, 36, 16, 33, 89, 36, 188,
|
||||
156, 122, 117, 124, 48, 83, 99, 153, 72, 148, 163, 14, 116, 15, 162, 169, 50, 10, 244,
|
||||
155, 136, 105, 76, 118, 209, 144, 130, 88, 102, 85, 234, 137, 222, 195, 37, 93, 169,
|
||||
179, 227, 195, 162, 203, 242, 19, 175, 252, 19, 197, 230, 97, 174, 167, 72, 10, 169,
|
||||
184, 26, 249, 41, 49, 199, 54, 205, 183, 178, 241, 5, 35, 142, 227, 196, 245, 2, 91,
|
||||
201, 6, 41, 62, 214, 158, 48, 39, 106, 189, 134, 27, 86, 2, 83, 27, 170, 30, 140, 103,
|
||||
7, 87, 65, 87, 163, 117, 188, 132, 38, 15, 116, 251, 23, 157, 113, 156, 165, 96, 41,
|
||||
112, 103, 3, 81, 200, 3, 166, 137, 98, 14, 86, 183, 200, 161, 100, 212, 199, 206, 167,
|
||||
114, 15, 235, 131, 103, 77, 103, 188, 254, 5, 30, 172, 183, 174, 176, 252, 9, 29, 90,
|
||||
78, 178, 188, 101, 158, 74, 200, 231, 75, 89, 233, 113, 206, 254, 122, 136, 41, 148,
|
||||
20, 10, 217, 144, 177, 108, 42, 124, 210, 7, 40, 138, 167, 223, 156, 151, 106, 236, 94,
|
||||
84, 183, 48, 39, 81, 77, 54, 129, 140, 133, 183, 107, 9, 8, 193, 99, 90, 185, 41, 229,
|
||||
43, 138, 11, 86, 161, 39, 124, 40, 114, 119, 122, 101, 124, 226, 227, 192, 241, 54,
|
||||
182, 89, 37, 186, 17, 90, 171, 245, 185, 119, 76, 21, 11, 170, 146, 46, 110, 228, 51,
|
||||
213, 162, 5, 193, 211, 153, 112, 148, 208, 43, 3, 254, 16, 173, 51, 88, 252, 219, 69,
|
||||
48, 242, 206, 198, 185, 105, 26,
|
||||
65, 58, 16, 29, 18, 146, 252, 162, 117, 98, 133, 1, 86, 200, 127, 2, 35, 59, 88, 227,
|
||||
203, 23, 97, 155, 214, 138, 119, 145, 232, 190, 40, 8, 202, 43, 194, 147, 48, 246, 95,
|
||||
103, 232, 203, 34, 203, 50, 46, 4, 65, 209, 74, 112, 3, 183, 4, 102, 71, 80, 232, 148,
|
||||
53, 102, 71, 87, 246, 99, 161, 208, 197, 127, 244, 115, 136, 37, 201, 60, 45, 25, 24,
|
||||
181, 88, 141, 151, 149, 135, 121, 242, 184, 195, 138, 23, 247, 195, 56, 183, 51, 166,
|
||||
176, 119, 101, 130, 177, 15, 126, 85, 163, 226, 98, 17, 154, 134, 159, 188, 231, 49,
|
||||
64, 25, 183, 21, 59, 119, 203, 22, 143, 113, 136, 89, 202, 9, 8, 233, 24, 125, 11, 87,
|
||||
18, 178, 240, 33, 13, 106, 55, 148, 2, 145, 164, 105, 15, 233, 43, 202, 169, 10, 151,
|
||||
68, 92, 100, 137, 22, 155, 153, 91, 14, 96, 2, 43, 183, 97, 133, 77, 6, 99, 238, 26,
|
||||
163, 123, 53, 41, 221, 83, 19, 46, 243, 52, 252, 168, 187, 195, 241, 148, 57, 149, 118,
|
||||
92, 188, 47, 177, 234, 57, 78, 229, 188, 194, 108, 55, 254, 24, 75, 25, 19, 143, 28,
|
||||
84, 105, 245, 50, 41, 255, 176, 84, 41, 58, 87, 171, 33, 117, 14, 112, 109, 136, 168,
|
||||
28, 53, 90, 35, 135, 145, 200, 209, 136, 123, 58, 28, 138, 241, 193, 64, 118, 187, 29,
|
||||
228, 50, 11, 179, 134, 161, 251, 245, 100, 148, 224, 103, 97, 103, 132, 222, 72, 176,
|
||||
26, 39, 186, 246, 44, 19, 125, 131, 156, 243, 16, 121, 77, 33, 60, 72, 17, 43, 229, 70,
|
||||
69, 74, 41, 166, 109, 88, 195, 9, 154, 193, 25, 107, 41, 12, 82, 126, 68, 251, 131, 84,
|
||||
69, 31, 60, 226, 26, 236, 185, 11, 238, 147, 23, 72, 80, 170, 124, 201, 96, 173, 242,
|
||||
24, 186, 114, 44, 129, 72, 35, 170, 115, 18, 30, 218, 137, 50, 21, 62, 145, 227, 76,
|
||||
107, 146, 196, 72, 249, 122, 137, 91, 97, 127, 120, 19, 199, 21, 10, 20, 187, 182, 109,
|
||||
160, 103, 224, 155, 182, 38, 148, 48, 203, 166, 188, 243, 181, 153, 34, 88, 108, 75,
|
||||
114, 178, 25, 5, 84, 168, 10, 162, 249, 49, 197, 100, 57, 94, 211, 12, 178, 174, 229,
|
||||
192, 146, 210, 166, 37, 209, 124, 207, 98, 69, 146, 244, 164, 102, 182, 69, 156, 201,
|
||||
184, 70, 117, 11, 20, 64, 151, 125, 235, 80, 144, 165, 58, 4, 32, 162, 46, 82, 92, 244,
|
||||
180, 153, 58, 225, 39, 53, 34, 194, 181, 149, 148, 204, 117, 167, 245, 24, 108, 229,
|
||||
119, 114, 149, 171, 122, 54, 182, 171, 36, 117, 117, 181, 44, 152, 228, 85, 19, 183,
|
||||
172, 157, 201, 236, 28, 232, 216, 143, 203, 34, 131, 38, 91, 108, 104, 170, 147, 54,
|
||||
66, 115, 254, 246, 165, 50, 97, 24, 167, 49, 206, 118, 41, 74, 143, 28, 75, 160, 211,
|
||||
183, 93, 181, 142, 209, 40, 70, 218, 151, 170, 138, 69, 37, 33, 118, 9, 143, 148, 92,
|
||||
149, 114, 84, 161, 8, 107, 34, 7, 142, 78, 169, 157, 245, 20, 32, 189, 245, 2, 254, 92,
|
||||
43, 161, 155, 69, 23, 60, 33, 208, 70, 149, 44, 70, 131, 241, 119, 134, 95, 7, 10, 188,
|
||||
89, 44, 62, 44, 40, 60, 178, 34, 227, 187, 152, 63, 169, 145, 197, 217, 6, 227, 55, 59,
|
||||
62, 145, 5, 235, 107, 35, 147, 7, 106, 240, 144, 24, 45, 161, 118, 112, 16, 169, 45,
|
||||
150, 36, 207, 184, 161, 51, 64, 93, 198, 226, 97, 167, 163, 120, 211, 165, 198, 151,
|
||||
130, 44, 133, 249, 201, 198, 52, 190, 156, 83, 158, 104, 131, 0, 57, 132, 69, 53, 33,
|
||||
86, 83, 70, 173, 121, 108, 80, 164, 234, 169, 74, 155, 158, 242, 187, 139, 31, 213, 65,
|
||||
188, 135, 49, 86, 105, 18, 48, 91, 142, 123, 181, 50, 26, 26, 199, 176, 128, 102, 28,
|
||||
210, 100, 237, 186, 112, 22, 147, 10, 175, 196, 154, 73, 151, 194, 230, 90, 56, 213,
|
||||
34, 44, 250, 231, 120, 232, 89, 193, 116, 244, 39, 82, 149, 135, 248, 0, 181, 98, 68,
|
||||
185, 83, 194, 8, 200, 166, 74, 187, 200, 75, 177, 194, 67, 248, 91, 63, 83, 33, 36, 14,
|
||||
39, 99, 17, 194, 47, 209, 51, 138, 113, 227, 23, 171, 236, 26, 217, 229, 199, 27, 3,
|
||||
14, 22, 6, 93, 150, 136, 182, 162, 146, 103, 24, 71, 31, 26, 131, 201, 177, 71, 25, 53,
|
||||
7, 70, 126, 99, 22, 240, 240, 43, 124, 234, 83, 8, 67, 166, 220, 7, 128, 49, 165, 165,
|
||||
19, 145, 78, 121, 215, 177, 73, 58, 150, 211, 50, 74, 243, 150, 107, 41, 196, 146, 238,
|
||||
180, 67, 28, 58, 78, 237, 229, 164, 220, 60, 90, 93, 169, 51, 76, 166, 195, 59, 250,
|
||||
22, 199, 68, 57, 149, 74, 102, 68, 164, 207, 161, 213, 132, 156, 228, 144, 163, 165,
|
||||
68, 37, 227, 62, 115, 41, 112, 141, 162, 71, 169, 92, 22, 84, 22, 132, 90, 132, 141,
|
||||
196, 182, 25, 252, 240, 117, 142, 172, 144, 243, 209, 5, 167, 247, 142, 58, 49, 139,
|
||||
55, 73, 103, 112, 149, 185, 134, 103, 73, 243, 194, 137, 70, 144, 178, 47, 182, 10, 78,
|
||||
144, 60, 83, 26, 108, 205, 165, 60, 73, 91, 203, 73, 36, 111, 157, 241, 180, 203, 145,
|
||||
3, 233, 131, 87, 54, 34, 201, 178, 232, 195, 214, 80, 98, 234, 19, 22, 170, 195, 123,
|
||||
169, 56, 170, 40, 112, 112, 91, 139, 25, 222, 99, 98, 228, 50, 97, 115, 2, 44, 175, 55,
|
||||
147, 130, 12, 158, 167, 161, 63, 45, 48, 81, 63, 48, 68, 61, 88, 92, 225, 26, 104, 129,
|
||||
74, 21, 89, 212, 147, 229, 216, 11, 90, 51, 5, 45, 22, 158, 243, 8, 69, 67, 133, 4, 31,
|
||||
138, 58, 77, 101, 200, 125, 52, 181, 56, 36, 73, 40, 178, 187, 254, 71, 138, 174, 187,
|
||||
76, 172, 6, 164, 8, 84, 184, 72, 11, 112, 63, 138, 123, 44, 241, 90, 108, 71, 113, 108,
|
||||
83, 87, 67, 168, 9, 236, 210, 23, 130, 162, 108, 108, 103, 112, 136, 248, 38, 94, 156,
|
||||
64, 15, 219, 108, 193, 199, 131, 81, 188, 53, 236, 57, 181, 253, 6, 164, 70, 202, 121,
|
||||
214, 149, 161, 252, 132, 74, 106, 82, 160, 17, 83, 196, 103, 70, 159, 176, 55, 19, 224,
|
||||
91, 153, 155, 53, 48, 240, 133, 28, 180, 44, 121, 102, 82, 70, 28, 17, 130, 155, 91,
|
||||
31, 51, 33, 34, 149, 33, 121, 74, 39, 16, 157, 86, 90, 81, 74, 152, 98, 59, 204, 153,
|
||||
220, 136, 219, 231, 161, 198, 232, 60, 243, 227, 220, 48, 189, 105, 166, 191, 118, 202,
|
||||
76, 193, 226, 21, 183, 54, 157, 96, 84, 1, 235, 248, 25, 18, 152, 102, 177, 171, 246,
|
||||
];
|
||||
|
||||
assert!(expected_ssk == child_node.value.0.secret_spending_key);
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct ChildKeysPublic {
|
||||
impl ChildKeysPublic {
|
||||
#[must_use]
|
||||
pub fn root(seed: [u8; 64]) -> Self {
|
||||
let hash_value = hmac_sha512::HMAC::mac(seed, "LEE_master_pub");
|
||||
let hash_value = hmac_sha512::HMAC::mac(seed, "/LEE-Keys/v1/Master/Public");
|
||||
let (first, cc) = split_hash(&hash_value);
|
||||
|
||||
let sk = lee::PrivateKey::try_new(first).expect("Expect a valid Private Key");
|
||||
@@ -120,25 +120,25 @@ mod tests {
|
||||
let keys = ChildKeysPublic::root(SEED);
|
||||
|
||||
let expected_cc = [
|
||||
238, 94, 84, 154, 56, 224, 80, 218, 133, 249, 179, 222, 9, 24, 17, 252, 120, 127, 222,
|
||||
13, 146, 126, 232, 239, 113, 9, 194, 219, 190, 48, 187, 155,
|
||||
184, 94, 197, 114, 84, 79, 170, 62, 107, 107, 141, 196, 11, 255, 15, 165, 7, 40, 93,
|
||||
211, 244, 153, 12, 70, 10, 174, 141, 69, 117, 167, 165, 81,
|
||||
];
|
||||
|
||||
let expected_sk: PrivateKey = PrivateKey::try_new([
|
||||
40, 35, 239, 19, 53, 178, 250, 55, 115, 12, 34, 3, 153, 153, 72, 170, 190, 36, 172, 36,
|
||||
202, 148, 181, 228, 35, 222, 58, 84, 156, 24, 146, 86,
|
||||
142, 140, 44, 81, 255, 159, 131, 163, 210, 67, 198, 176, 43, 243, 163, 35, 242, 200,
|
||||
232, 99, 69, 240, 63, 16, 33, 104, 8, 152, 243, 153, 180, 169,
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
let expected_ssk: PrivateKey = PrivateKey::try_new([
|
||||
207, 4, 246, 223, 104, 72, 19, 85, 14, 122, 194, 82, 32, 163, 60, 57, 8, 25, 209, 91,
|
||||
254, 107, 76, 238, 31, 68, 236, 192, 154, 78, 105, 118,
|
||||
241, 47, 167, 208, 182, 77, 106, 158, 182, 41, 17, 3, 91, 229, 165, 35, 90, 33, 145,
|
||||
202, 246, 65, 127, 65, 124, 240, 165, 152, 127, 50, 60, 198,
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
let expected_pk: PublicKey = PublicKey::try_new([
|
||||
188, 163, 203, 45, 151, 154, 230, 254, 123, 114, 158, 130, 19, 182, 164, 143, 150, 131,
|
||||
176, 7, 27, 58, 204, 116, 5, 247, 0, 255, 111, 160, 52, 201,
|
||||
43, 138, 92, 79, 223, 49, 90, 162, 205, 76, 143, 151, 96, 77, 10, 85, 179, 208, 244,
|
||||
71, 251, 191, 237, 226, 120, 247, 194, 57, 117, 180, 96, 65,
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
@@ -155,25 +155,25 @@ mod tests {
|
||||
let child_keys = ChildKeysPublic::nth_child(&root_keys, cci);
|
||||
|
||||
let expected_cc = [
|
||||
149, 226, 13, 4, 194, 12, 69, 29, 9, 234, 209, 119, 98, 4, 128, 91, 37, 103, 192, 31,
|
||||
130, 126, 123, 20, 90, 34, 173, 209, 101, 248, 155, 36,
|
||||
184, 162, 65, 125, 129, 202, 96, 126, 157, 15, 189, 122, 22, 152, 31, 107, 244, 188,
|
||||
215, 30, 70, 205, 164, 142, 6, 152, 106, 147, 160, 1, 168, 168,
|
||||
];
|
||||
|
||||
let expected_sk: PrivateKey = PrivateKey::try_new([
|
||||
9, 65, 33, 228, 25, 82, 219, 117, 91, 217, 11, 223, 144, 85, 246, 26, 123, 216, 107,
|
||||
213, 33, 52, 188, 22, 198, 246, 71, 46, 245, 174, 16, 47,
|
||||
222, 78, 224, 138, 167, 32, 235, 208, 192, 129, 121, 150, 204, 149, 151, 33, 82, 109,
|
||||
238, 245, 20, 106, 70, 126, 120, 66, 165, 169, 241, 242, 224, 10,
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
let expected_ssk: PrivateKey = PrivateKey::try_new([
|
||||
100, 37, 212, 81, 40, 233, 72, 156, 177, 139, 50, 114, 136, 157, 202, 132, 203, 246,
|
||||
252, 242, 13, 81, 42, 100, 159, 240, 187, 252, 202, 108, 25, 105,
|
||||
103, 101, 18, 63, 86, 198, 110, 120, 163, 160, 181, 249, 184, 163, 7, 38, 132, 223, 72,
|
||||
208, 74, 223, 16, 110, 60, 227, 167, 192, 89, 28, 14, 222,
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
let expected_pk: PublicKey = PublicKey::try_new([
|
||||
210, 59, 119, 137, 21, 153, 82, 22, 195, 82, 12, 16, 80, 156, 125, 199, 19, 173, 46,
|
||||
224, 213, 144, 165, 126, 70, 129, 171, 141, 77, 212, 108, 233,
|
||||
107, 153, 105, 58, 6, 157, 131, 253, 141, 130, 168, 182, 82, 2, 99, 26, 211, 22, 55,
|
||||
203, 23, 34, 236, 147, 86, 156, 194, 114, 89, 77, 219, 173,
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -361,8 +361,8 @@ mod tests {
|
||||
|
||||
assert!(tree.key_map.contains_key(&ChainIndex::root()));
|
||||
assert!(tree.account_id_map.contains_key(&AccountId::new([
|
||||
10, 231, 159, 65, 236, 46, 205, 5, 172, 89, 250, 29, 123, 195, 212, 137, 155, 111, 40,
|
||||
120, 53, 28, 124, 54, 224, 170, 119, 208, 2, 72, 75, 50
|
||||
215, 164, 47, 51, 250, 90, 227, 248, 132, 109, 120, 59, 116, 142, 34, 79, 242, 112, 89,
|
||||
142, 210, 12, 183, 217, 160, 19, 169, 147, 203, 173, 172, 105
|
||||
])));
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ impl SecretSpendingKey {
|
||||
#[must_use]
|
||||
#[expect(clippy::big_endian_bytes, reason = "BIP-032 uses big endian")]
|
||||
pub fn generate_authorization_secret_key(&self, index: Option<u32>) -> AuthorizationSecretKey {
|
||||
const DOMAIN: &[u8; 35] = b"/LEE/v0.3/Keys/Authorization/Secret";
|
||||
const DOMAIN: &[u8; 33] = b"/LEE-Keys/v1/Authorization/Secret";
|
||||
|
||||
let index = index.unwrap_or(0);
|
||||
|
||||
@@ -110,16 +110,16 @@ impl SecretSpendingKey {
|
||||
#[must_use]
|
||||
#[expect(clippy::big_endian_bytes, reason = "BIP-032 uses big endian")]
|
||||
pub fn generate_viewing_secret_seed_key(&self, index: Option<u32>) -> ViewingSecretKey {
|
||||
const DOMAIN: &[u8; 29] = b"/LEE/v0.3/Keys/Viewing/Secret";
|
||||
const DOMAIN: &[u8; 27] = b"/LEE-Keys/v1/Viewing/Secret";
|
||||
|
||||
let index = index.unwrap_or(0);
|
||||
|
||||
let mut bytes = [0_u8; 29 + 32 + 4];
|
||||
bytes[..29].copy_from_slice(DOMAIN);
|
||||
bytes[29..61].copy_from_slice(&self.0);
|
||||
bytes[61..].copy_from_slice(&index.to_be_bytes());
|
||||
let mut bytes = [0_u8; 27 + 32 + 4];
|
||||
bytes[..27].copy_from_slice(DOMAIN);
|
||||
bytes[27..59].copy_from_slice(&self.0);
|
||||
bytes[59..].copy_from_slice(&index.to_be_bytes());
|
||||
|
||||
let full_seed = hmac_sha512::HMAC::mac(bytes, b"LEE_viewing_seed");
|
||||
let full_seed = hmac_sha512::HMAC::mac(bytes, b"/LEE-Keys/v1/Viewing/Seed");
|
||||
|
||||
Self::generate_viewing_secret_key(full_seed)
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ pub struct AuthorizationSecretKey(pub [u8; 32]);
|
||||
|
||||
impl From<&AuthorizationSecretKey> for NullifierSecretKey {
|
||||
fn from(value: &AuthorizationSecretKey) -> Self {
|
||||
const DOMAIN: &[u8; 31] = b"/LEE/v0.3/Keys/Nullifier/Secret";
|
||||
let mut bytes = [0_u8; 31 + 32];
|
||||
bytes[..31].copy_from_slice(DOMAIN);
|
||||
bytes[31..].copy_from_slice(&value.0);
|
||||
const DOMAIN: &[u8; 29] = b"/LEE-Keys/v1/Nullifier/Secret";
|
||||
let mut bytes = [0_u8; 29 + 32];
|
||||
bytes[..29].copy_from_slice(DOMAIN);
|
||||
bytes[29..].copy_from_slice(&value.0);
|
||||
Impl::hash_bytes(&bytes)
|
||||
.as_bytes()
|
||||
.try_into()
|
||||
@@ -67,10 +67,10 @@ impl From<&AuthorizationSecretKey> for NullifierSecretKey {
|
||||
|
||||
impl From<&NullifierSecretKey> for NullifierPublicKey {
|
||||
fn from(value: &NullifierSecretKey) -> Self {
|
||||
const DOMAIN: &[u8; 31] = b"/LEE/v0.3/Keys/Nullifier/Public";
|
||||
let mut bytes = [0_u8; 31 + 32];
|
||||
bytes[..31].copy_from_slice(DOMAIN);
|
||||
bytes[31..].copy_from_slice(value);
|
||||
const DOMAIN: &[u8; 29] = b"/LEE-Keys/v1/Nullifier/Public";
|
||||
let mut bytes = [0_u8; 29 + 32];
|
||||
bytes[..29].copy_from_slice(DOMAIN);
|
||||
bytes[29..].copy_from_slice(value);
|
||||
Self(
|
||||
Impl::hash_bytes(&bytes)
|
||||
.as_bytes()
|
||||
@@ -171,8 +171,8 @@ mod tests {
|
||||
fn from_authorization_key() {
|
||||
let ask = AuthorizationSecretKey([0; 32]);
|
||||
let expected_nsk: NullifierSecretKey = [
|
||||
31, 33, 90, 89, 193, 14, 149, 46, 107, 38, 51, 65, 178, 242, 118, 11, 235, 198, 242,
|
||||
144, 192, 64, 39, 205, 244, 122, 210, 55, 11, 245, 117, 29,
|
||||
135, 144, 25, 255, 27, 190, 82, 191, 49, 83, 55, 248, 251, 98, 149, 55, 143, 129, 2,
|
||||
201, 237, 77, 248, 237, 15, 11, 188, 41, 219, 213, 10, 74,
|
||||
];
|
||||
let nsk = NullifierSecretKey::from(&ask);
|
||||
assert_eq!(nsk, expected_nsk);
|
||||
@@ -185,8 +185,8 @@ mod tests {
|
||||
196, 134, 22, 224, 211, 237, 120, 136, 225, 188, 220, 249, 28,
|
||||
];
|
||||
let expected_npk = NullifierPublicKey([
|
||||
58, 181, 207, 24, 227, 133, 192, 231, 242, 216, 230, 219, 31, 227, 236, 94, 99, 245,
|
||||
206, 251, 237, 189, 88, 218, 215, 106, 66, 227, 136, 152, 140, 218,
|
||||
44, 121, 113, 131, 34, 101, 53, 97, 87, 111, 83, 78, 157, 34, 59, 248, 105, 103, 194,
|
||||
137, 127, 221, 25, 17, 105, 84, 114, 129, 183, 83, 168, 193,
|
||||
]);
|
||||
let npk = NullifierPublicKey::from(&nsk);
|
||||
assert_eq!(npk, expected_npk);
|
||||
@@ -201,8 +201,8 @@ mod tests {
|
||||
let npk = NullifierPublicKey::from(&nsk);
|
||||
let vpk = ViewingPublicKey::from_seed(&[1_u8; 32], &[2_u8; 32]);
|
||||
let expected_account_id = AccountId::new([
|
||||
226, 149, 99, 147, 82, 211, 97, 152, 31, 46, 87, 113, 237, 244, 197, 108, 71, 191, 161,
|
||||
199, 140, 177, 247, 73, 95, 64, 202, 90, 8, 157, 188, 147,
|
||||
6, 35, 121, 102, 237, 184, 156, 247, 28, 185, 212, 214, 51, 229, 66, 170, 10, 75, 126,
|
||||
12, 93, 139, 88, 61, 65, 246, 230, 184, 223, 232, 252, 124,
|
||||
]);
|
||||
|
||||
let account_id = AccountId::for_regular_private_account(&npk, &vpk, 0);
|
||||
@@ -219,8 +219,8 @@ mod tests {
|
||||
let npk = NullifierPublicKey::from(&nsk);
|
||||
let vpk = ViewingPublicKey::from_seed(&[1_u8; 32], &[2_u8; 32]);
|
||||
let expected_account_id = AccountId::new([
|
||||
44, 36, 222, 50, 57, 159, 215, 6, 246, 54, 45, 150, 94, 148, 148, 71, 212, 113, 165,
|
||||
10, 187, 162, 184, 70, 96, 35, 42, 230, 251, 72, 237, 80,
|
||||
56, 217, 214, 244, 51, 212, 184, 73, 217, 85, 4, 126, 54, 35, 135, 225, 75, 253, 183,
|
||||
19, 96, 182, 189, 138, 62, 101, 131, 30, 2, 236, 157, 235,
|
||||
]);
|
||||
|
||||
let account_id = AccountId::for_regular_private_account(&npk, &vpk, 1);
|
||||
@@ -238,8 +238,8 @@ mod tests {
|
||||
let npk = NullifierPublicKey::from(&nsk);
|
||||
let vpk = ViewingPublicKey::from_seed(&[1_u8; 32], &[2_u8; 32]);
|
||||
let expected_account_id = AccountId::new([
|
||||
50, 122, 67, 122, 59, 36, 150, 204, 128, 54, 55, 152, 14, 220, 163, 211, 246, 221, 197,
|
||||
75, 12, 199, 163, 151, 234, 194, 188, 13, 27, 120, 249, 220,
|
||||
14, 231, 97, 140, 18, 163, 250, 222, 102, 223, 118, 160, 65, 228, 201, 232, 182, 198,
|
||||
230, 213, 216, 143, 78, 95, 163, 95, 32, 1, 20, 240, 97, 95,
|
||||
]);
|
||||
|
||||
let account_id = AccountId::for_regular_private_account(&npk, &vpk, identifier);
|
||||
|
||||
@@ -277,30 +277,30 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
const VSK_D_PRIV_ACC_A: [u8; 32] = [
|
||||
4, 118, 187, 42, 14, 254, 144, 150, 125, 176, 205, 240, 109, 81, 234, 177, 244, 236, 108,
|
||||
71, 107, 10, 107, 169, 95, 134, 75, 193, 213, 57, 81, 218,
|
||||
37, 79, 203, 133, 143, 28, 149, 228, 53, 195, 241, 240, 40, 28, 11, 81, 126, 209, 253, 79,
|
||||
167, 213, 4, 162, 9, 183, 132, 78, 248, 92, 134, 198,
|
||||
];
|
||||
|
||||
const VSK_Z_PRIV_ACC_A: [u8; 32] = [
|
||||
117, 29, 113, 136, 175, 148, 38, 38, 110, 220, 157, 155, 245, 13, 239, 244, 106, 126, 188,
|
||||
90, 204, 28, 82, 70, 200, 16, 219, 33, 43, 210, 125, 239,
|
||||
197, 94, 192, 175, 68, 106, 201, 229, 125, 33, 51, 144, 81, 154, 230, 37, 209, 230, 150,
|
||||
29, 73, 203, 166, 56, 65, 178, 205, 15, 101, 81, 111, 150,
|
||||
];
|
||||
|
||||
const VSK_D_PRIV_ACC_B: [u8; 32] = [
|
||||
100, 59, 111, 232, 245, 32, 102, 179, 205, 119, 145, 238, 9, 235, 62, 38, 55, 252, 179,
|
||||
217, 219, 211, 6, 188, 85, 160, 68, 54, 61, 114, 102, 81,
|
||||
221, 28, 168, 185, 246, 234, 210, 245, 219, 3, 116, 190, 178, 31, 49, 79, 246, 147, 101,
|
||||
161, 120, 32, 218, 191, 23, 209, 8, 38, 184, 92, 104, 177,
|
||||
];
|
||||
|
||||
const VSK_Z_PRIV_ACC_B: [u8; 32] = [
|
||||
123, 246, 87, 46, 116, 95, 39, 122, 251, 71, 207, 144, 70, 227, 120, 27, 98, 59, 67, 247,
|
||||
209, 194, 110, 231, 250, 247, 205, 243, 31, 142, 104, 208,
|
||||
167, 68, 2, 131, 197, 10, 239, 237, 52, 80, 87, 51, 21, 153, 205, 222, 117, 159, 204, 16,
|
||||
66, 136, 209, 158, 243, 254, 168, 14, 19, 222, 8, 97,
|
||||
];
|
||||
|
||||
const PUB_ACC_A_TEXT_ADDR: &str = "6iArKUXxhUJqS7kCaPNhwMWt3ro71PDyBj7jwAyE2VQV";
|
||||
const PUB_ACC_B_TEXT_ADDR: &str = "7wHg9sbJwc6h3NP1S9bekfAzB8CHifEcxKswCKUt3YQo";
|
||||
|
||||
const PRIV_ACC_A_TEXT_ADDR: &str = "GSx3EttJzQqhFPibttxguyhKXkiD4DJmA2dMmuszEmFv";
|
||||
const PRIV_ACC_B_TEXT_ADDR: &str = "Dec1rT4DynCafh6k5pmywLGUU16RpxcxCdrSVYq8ukaN";
|
||||
const PRIV_ACC_A_TEXT_ADDR: &str = "As5oeEYgbwFwHCB8xCnRJA5uQV1eYCcU86Pfir3D29fX";
|
||||
const PRIV_ACC_B_TEXT_ADDR: &str = "GhB15jD2Yig2h2SnDXqxsZii1B3EhnmSucvwodfXKhAa";
|
||||
|
||||
#[test]
|
||||
fn pub_state_consistency() {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user