Public key tweaks are often talked about in the context of taproot but I cannot find a definition of what precisely "tweaking" means.
2 Answers
The Bitcoin Optech Taproot workshop defines it as:
Tweaking a public key means to alter it with a value (the tweak) such that it remains spendable with knowledge of the original private key and tweak.
A tweak is positive scalar value
t
where0 < t < SECP256K1_ORDER
. There is an associated tweak pointT
such thatT = t*G
. The private key is tweaked by the tweak scalar:x' = x + t
and the public key is tweaked by the tweak point:P' = P + T
.The tweaked private key
x'
can be used to produce a valid signature for the tweaked pubkeyP'
.
A very simple explanation is that it is just appending some extra text in the case of a mnemnonic key, or if a numeric key is being used to just add some number to that, making an altogether new key.
An example is an app I worked on that needed to be able to create new wallets on demand and scale up or down in terms of the size of the array of wallets that were used, so I just had a loop like this basically which created them:
keys = array[NUM_WALLETS];
master_key = "RANDOM_LETTERS_AS_MAIN_MNEMONIC_PRIVATE_KEY";
for(counter=0; counter < NUM_WALLETS; counter++)
{
keys[counter] = master_key + counter
}
So it is really just a way of easily creating new keys using an existing key, because as long as the main key is created properly so that it is as random as it can be, then you can add simple values like a counter to that key and have a new key that is easy to generate but still secure.