Implements public announcements encrypted via symmetric keys
This is most useful for utxos that transfer funds within a single wallet such as change addresses.
Compared to on-chain pub-key public announcements:
Data encrypted with symmetric keys is smaller than data encrypted with asymmetric keys so there is a blockchain space (and thus fee) savings.
Compared to off-chain expected utxos:
symmetric-key announcements exist on the blockchain and thus are immune to local data-loss situations. off-chain expected utxos do not use any blockchain space but require that the wallet holder make ongoing backups of wallet state and never lose them.
Design choices, please review:
SymmetricKey presently uses Aes256Gcm. Is this our final choice?
Symmetric keys are derived from a seed and are unique for each utxo. (rather than using a single sym-key per wallet shared for all utxo.) This is because we want the receiver_id to be unique to avoid linking utxos.
Symmetric keys derive from the same root seed WalletSecret::secret_seed as generation addresses but the derivation in ::nth_symmetric_key() uses a SYMMETRIC_KEY_FLAG. This means that end-user should only require a single mnemonic phrase for the root seed. A symmetric-key derivation counter must be stored in wallet state.
efficiency: SymmetricKey presently derives all fields from seed as needed, rather than pre-calc and store when created. see doc-comment for the struct.
change notify method now defaults to on-chain symmetric key, rather than offchain (expected utxo) in dashboard and neptune-cli. (note: this could easily be made an end-user option)
Summary of changes:
Cargo.toml:
aead dep now requires feature std so that the aead::Error impls std::error::Error trait.
New code:
add struct AnnouncedUtxo to represent a found/claimed utxo and its secrets.
add enum UtxoNotifyMethodSpecifier that further simplifies create_transaction() params and impl.
add struct SymmetricKey
add WalletSecret::next_unused_symmetric_key() and ::nth_symmetric_key()
add WalletState::get_known_symmetric_keys()
Modified code:
added SymmetricKey to SpendingKeyType and ReceivingAddressType.
added some missing doc-comments
minor refactors to generation_address to match and share code with symmetric_key.
closes #161.
Implements public announcements encrypted via symmetric keys
This is most useful for utxos that transfer funds within a single wallet such as change addresses.
Compared to on-chain pub-key public announcements:
Data encrypted with symmetric keys is smaller than data encrypted with asymmetric keys so there is a blockchain space (and thus fee) savings.
Compared to off-chain expected utxos:
symmetric-key announcements exist on the blockchain and thus are immune to local data-loss situations. off-chain expected utxos do not use any blockchain space but require that the wallet holder make ongoing backups of wallet state and never lose them.
Design choices, please review:
SymmetricKey
presently usesAes256Gcm
. Is this our final choice?Symmetric keys are derived from a seed and are unique for each utxo. (rather than using a single sym-key per wallet shared for all utxo.) This is because we want the receiver_id to be unique to avoid linking utxos.
Symmetric keys derive from the same root seed
WalletSecret::secret_seed
as generation addresses but the derivation in::nth_symmetric_key()
uses aSYMMETRIC_KEY_FLAG
. This means that end-user should only require a single mnemonic phrase for the root seed. A symmetric-key derivation counter must be stored in wallet state.efficiency:
SymmetricKey
presently derives all fields from seed as needed, rather than pre-calc and store when created. see doc-comment for the struct.change notify method now defaults to on-chain symmetric key, rather than offchain (expected utxo) in dashboard and neptune-cli. (note: this could easily be made an end-user option)
Summary of changes:
Cargo.toml:
std
so that the aead::Error impls std::error::Error trait.New code:
AnnouncedUtxo
to represent a found/claimed utxo and its secrets.UtxoNotifyMethodSpecifier
that further simplifies create_transaction() params and impl.SymmetricKey
WalletSecret::next_unused_symmetric_key()
and::nth_symmetric_key()
WalletState::get_known_symmetric_keys()
Modified code:
SymmetricKey
toSpendingKeyType
andReceivingAddressType
.UtxoNotificationPool::scan_for_expected_utxos()
WalletState::scan_for_announced_utxos()
to include symmetric keys.WalletState::find_spending_key_for_utxo()
to include symmetric keys.WalletState::update_wallet_state_with_new_block()
GlobalState::create_transaction()
. simplify args and impl.rpc_server::send()
andsend_to_many()
to acceptchange_utxo_notify_method
param.OffChainSymmetricKey
flag forsend()
parameterchange_notify_method
.New Tests:
symmetric_key::test::test_encrypt_decrypt()
symmetric_key::test::scan_for_announced_utxos_test()