Type-2 is a bit less obvious and understanding it requires you to know about a property of ECC keys, roughly:
A_public_key = A_private_key*point
Which means you can do:
B_public_key = A_public_key+B_secret*point
and have a new key which has a private key:
B_private_key = A_private_key+B_secret
So a type2 wallet stores:
Master_private_key
A large Random_seed S.
and keys are given by
Privatekey(type,n) = Master_private_key + H(n|S|type)
Just to confirm my understanding.
Capital letter = point (used for public keys)
Lower letter = integer (used for private keys)
a = master private
A = master public
b = generated private
B = generated public
G = generation point (constant for curve)
v(n, t, s) = hash function
s = random seed
n = transaction/key id
t = type id
The standard rule is
A = a*G
We can generate a new private key using
b = a + v(n, t, s)
The corresponding public key is
B = b*G = (a+v)*G = a*G + v(n, t, s)*G
However, a*G is the master public key
B = A + v(n, t, s)*G
So, all of the public keys can be computed with just the master public key and S.
n and t are assumed to be pretty small numbers.
The private keys are
b = a + v(n, t, s)
They need a (the master private key) to be generated, as well as all the other values.
As long as a and s are protected, the user can never be unable to spend his coins and as long as a is kept secret, nobody else can spend his coins.